Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tpv on production to version 2.2.0 #1158

Merged
merged 23 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
265f613
Production tpv v2
cat-bro Jan 30, 2023
db8aa30
remove destionations.yml, add destinations.yml.j2
cat-bro Mar 13, 2023
9920465
sort out docker volumes for alphafold and ITs
cat-bro Mar 13, 2023
23dda00
add tags to pulsar-qld
cat-bro Mar 15, 2023
47fa60c
put destination tags and limits in host_vars/aarnet
cat-bro Mar 17, 2023
29c00e0
set version to 2.1.0
cat-bro Mar 20, 2023
c8c0a09
update roles.yml
cat-bro Mar 20, 2023
c5a329a
get rid of high-mem tag in destinations, add min_accepted_mem
cat-bro Mar 20, 2023
0587ecc
Add linting step to check templates and lint resulting files
cat-bro Mar 21, 2023
35f3109
role rule ids
cat-bro Mar 21, 2023
c5dbf02
tools.yml: add mem values and rule names. Flip values for each tool s…
cat-bro Mar 22, 2023
ca3b291
tpv format
cat-bro Mar 22, 2023
c190cdd
enable the shared database
cat-bro Mar 22, 2023
75b55da
Update .github/workflows/check_tpv_config.yml
cat-bro Mar 22, 2023
39124c2
Update .github/workflows/check_tpv_config.yml
cat-bro Mar 22, 2023
880208e
update version to 2.2.0 and use helper function in role rules
cat-bro Mar 22, 2023
68ff673
whitespace
cat-bro Mar 22, 2023
596e00d
update tpv version in ci
cat-bro Mar 22, 2023
dab4e9b
pulsars inherit _pulsar_destination
cat-bro Mar 23, 2023
e367335
max_accepted not max_allowed
cat-bro Mar 23, 2023
32c1342
replace missing tool rules
cat-bro Mar 23, 2023
d662ada
mem adjustment to fit with slurm configuration: 122.8G per 32 cores …
cat-bro Mar 26, 2023
9c60780
memory adjustments for destinations based on slurm config
cat-bro Mar 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 65 additions & 19 deletions .github/workflows/check_tpv_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,72 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install total-perspective-vortex==$TPV_VERSION pyyaml galaxy-data
pip install total-perspective-vortex==$TPV_VERSION pyyaml galaxy-app
env:
TPV_VERSION: '1.2.0'
# Run check files script
- name: Check vortex destination ids against job conf environment ids (aarnet)
TPV_VERSION: '2.2.0'
- name: Check TPV files and job conf
env:
SETTING: github
run: |
import yaml
with open('templates/galaxy/config/aarnet_job_conf.yml.j2') as handle:
job_conf_destinations = yaml.safe_load(handle).get('execution', {}).get('environments', [])
with open('files/galaxy/dynamic_job_rules/production/total_perspective_vortex/destinations.yml') as handle:
vortex_destinations = yaml.safe_load(handle).get('destinations', [])
for vd in vortex_destinations:
try:
job_conf_env = job_conf_destinations[vd]
except KeyError as e:
raise Exception(f'Destination id {vd} not found in job config file')
shell: python
- name: Run tpv lint on all vortex config files
env:
SETTING: github
run: for f in files/galaxy/dynamic_job_rules/production/total_perspective_vortex/*; do tpv lint $f; done
run: |
"""This code uses ansible to template out the jinja templates for tpv configs and job config,
then runs the tpv linter on the resultant files."""
import re
cat-bro marked this conversation as resolved.
Show resolved Hide resolved
import subprocess
import os
import shutil

working_dir = '.github/workflows/check_tpv_config'
hosts_file = os.path.join(working_dir, 'hosts')
playbook_file = os.path.join(working_dir, 'template_playbook.yml')
files_dir = os.path.join(working_dir, 'files')
templates_dir = os.path.join(working_dir, 'templates')
os.mkdir(files_dir)
os.mkdir(templates_dir)

tpv_dir = 'files/galaxy/dynamic_job_rules/production/total_perspective_vortex'
tpv_config_files = [os.path.join(tpv_dir, f) for f in os.listdir(tpv_dir)]
job_conf_template = 'templates/galaxy/config/aarnet_job_conf.yml.j2'
tpv_files = []

replace_patterns = ['\{\{\s?vault_\w+\s?\}\}', '\{\{\s?hostname\s?\}\}']

with open('.vault_pass.txt', 'w') as password_file:
password_file.write('FalsePassword')

def template_file(fname):
output_fname = fname.replace(templates_dir, files_dir).replace('.j2', '')
extra_vars = f'src={fname.replace(templates_dir+"/", "")} dest={os.path.realpath(output_fname)}'
ansible_command = f'ansible-playbook -i {hosts_file} {playbook_file} --extra-vars \'{extra_vars}\''
try:
subprocess.check_output(ansible_command, shell=True)
except subprocess.CalledProcessError as e:
print(e.output)
raise Exception('Failed to template {os.path.basename(fname)}')
return output_fname

def sanitize_text(fname):
"""Replaces any references to vault variables with a constant string as the
vault is not decrypted during tests"""
with open(fname) as handle:
text = handle.read()
for rp in replace_patterns:
text = re.sub(rp, 'text_replaced', text)
with open(fname, 'w') as handle:
handle.write(text)

for t in tpv_config_files + [job_conf_template]:
if t.endswith('.yml'):
test_fname = os.path.join(files_dir, os.path.basename(t))
shutil.copy(t, test_fname)
tpv_files.append(test_fname)
elif t.endswith('.yml.j2'):
test_fname = os.path.join(templates_dir, os.path.basename(t))
shutil.copy(t, test_fname)
sanitize_text(test_fname)
templated_file = template_file(test_fname)
if 'tpv_dir' in t:
tpv_files.append(templated_file)

for t in tpv_files:
subprocess.check_output(f'tpv lint {t}', shell=True)
2 changes: 2 additions & 0 deletions .github/workflows/check_tpv_config/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
localhost ansible_connection=local
11 changes: 11 additions & 0 deletions .github/workflows/check_tpv_config/template_playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- hosts: localhost
vars_files:
- ../../../group_vars/aarnet.yml
- ../../../group_vars/galaxyservers.yml
- ../../../host_vars/aarnet.usegalaxy.org.au.yml
tasks:
- name: Template file
template:
src: "{{ src }}"
dest: "{{ dest }}"
42 changes: 23 additions & 19 deletions aarnet_update_configs_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,38 @@
- group_vars/aarnet_slurm.yml
- host_vars/aarnet.usegalaxy.org.au.yml
- secret_group_vars/stats_server_vault
vars:
- tpv_files:
- tools.yml
- users.yml
- roles.yml
- destinations.yml
- tpv_templates:
- default_tool.yml.j2
handlers:
- name: galaxy gravity restart
become: True
become_user: galaxy
command: "{{ galaxy_venv_dir }}/bin/galaxyctl graceful"
environment:
GRAVITY_STATE_DIR: "{{ galaxy_gravity_state_dir }}"
- name: galaxy handler restart
become: True
become_user: galaxy
command: "{{ galaxy_venv_dir }}/bin/galaxyctl handler_0 handler_1 handler_2 handler_3 handler_4"
environment:
GRAVITY_STATE_DIR: "{{ galaxy_gravity_state_dir }}"
tasks:
- name: copy job_conf file
template:
src: "{{ galaxy_config_template_src_dir }}/config/aarnet_job_conf.yml.j2"
dest: "{{ galaxy_config_dir }}/job_conf.yml"
notify: galaxy gravity restart
notify: galaxy handler restart
# TODO: better linting of job conf, then it is probably entirely acceptable to let the jenkins_bot trigger a graceful restart of handlers
when: not ansible_user == 'jenkins_bot' # do not let the automatic process update the job conf
- name: template object store conf file
template:
src: "{{ galaxy_config_template_src_dir }}/config/aarnet_object_store_conf.xml.j2"
dest: "{{ galaxy_config_dir }}/object_store_conf.xml"
# notify: Restart Galaxy # TODO: appropriate handler for galaxyctl restart
notify: galaxy gravity restart
when: not ansible_user == 'jenkins_bot' # do not let the automatic process object store or restart galaxy
- name: template toolbox filters
template:
src: "{{ galaxy_config_template_src_dir }}/toolbox/filters/ga_filters.py.j2"
dest: "{{ galaxy_server_dir }}/lib/galaxy/tools/toolbox/filters/ga_filters.py"
notify: galaxy gravity restart # TODO: check whether graceful restart is enough in this case
notify: galaxy gravity restart
when: not ansible_user == 'jenkins_bot' # do not let the automatic process restart galaxy
- name: Copy local tool conf file
copy:
Expand All @@ -50,13 +48,19 @@
with_items:
- local_tool_conf.xml
when: not ansible_user == 'jenkins_bot'
- name: copy total perspective vortex files
- name: Install dynamic job rules (static) # dynamic job rules tasks copied from https://github.com/galaxyproject/ansible-galaxy/blob/main/tasks/static_setup.yml
copy:
src: "{{ galaxy_dynamic_job_rules_src_dir }}/total_perspective_vortex/{{ item }}"
dest: "{{ galaxy_dynamic_job_rules_dir }}/total_perspective_vortex/{{ item }}"
with_items: "{{ tpv_files }}"
- name: copy total perspective vortex templates
src: "{{ galaxy_dynamic_job_rules_src_dir }}/{{ item }}"
dest: "{{ galaxy_dynamic_job_rules_dir }}/{{ item }}"
mode: 0644
with_items: "{{ galaxy_dynamic_job_rules }}"
when: not item.endswith(".j2")
- name: Install dynamic job rules (template)
template:
src: "{{ galaxy_dynamic_job_rules_src_dir }}/total_perspective_vortex/{{ item }}"
dest: "{{ galaxy_dynamic_job_rules_dir }}/total_perspective_vortex/{{ item | replace('.j2', '') }}"
with_items: "{{ tpv_templates }}"
src: "{{ galaxy_dynamic_job_rules_src_dir }}/{{ item }}"
dest: "{{ galaxy_dynamic_job_rules_dir }}/{{ item | regex_replace(regex) }}"
mode: 0644
vars:
regex: '\.j2$'
with_items: "{{ galaxy_dynamic_job_rules }}"
when: item.endswith(".j2")

This file was deleted.

Loading