Skip to content

Commit

Permalink
Dispatch only interactive tools to docker by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dometto committed Oct 22, 2024
1 parent 8edf3de commit a6b5a25
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ The component takes the following parameters:
* `src_galaxy_version`: String. Set to e.g. `23.2` (default) to control the version of Galaxy that will be installed.
* `src_galaxy_api_exposed`: Boolean. if `true` (default), the `/api` route does not require authentication via Single Sign-On.
* `src_ibridges`: Boolean (default: `true`). Whether to enable support for the [iBridges](https://github.com/UtrechtUniversity/galaxy-tools-ibridges) tool for connecting to Yoda and iRODS instances. Implies `src_galaxy_bootstrap`, and adds iBridges to the list of tools to be installed automatically.
* `src_galaxy_jobs_docker`: Boolean. Enables Galaxy support for running jobs in Docker containers. Any jobs that *can* be run in a docker container will be---jobs that cannot will be run in the default manner (in a `conda` env). Runnings jobs in a container may be slower than running them locally, so consider turning this feature off if not needed.
* `src_galaxy_interactive_tools`: if `true` (default), support for [interactive tools](https://docs.galaxyproject.org/en/master/admin/special_topics/interactivetools.html) is enabled. **Note**: this implies *src_galaxy_jobs_docker*, and the accompanying performance hits.
* `src_galaxy_jobs_default`: String. What runner to use for jobs by default. Valid values: `singularity`, `docker`, `local`.
* `src_galaxy_interactive_tools`: if `true` (default), support for [interactive tools](https://docs.galaxyproject.org/en/master/admin/special_topics/interactivetools.html) is enabled.
* `src_galaxy_co_admin_group`: String group corresponding to an SRAM group. Members of this SRAM group will be made Galaxy admin users.
* `src_galaxy_bootstrap`: if `true` (default), will attempt to install workflows, dataproviders and tools as configured by the following options:
* `src_galaxy_tool_files`: String of comma-separated paths to YAML files (in this repo) containing tool specifications.
Expand Down
2 changes: 1 addition & 1 deletion galaxysrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

roles:
- role: geerlingguy.docker
when: not _molecule_active and _galaxy_jobs_docker
when: not _molecule_active and _galaxy_enable_docker
- role: uusrc.general.nginx_reverse_proxy
vars:
nginx_reverse_proxy_locations: "{{ galaxy_nginx_vhost_config }}"
Expand Down
5 changes: 5 additions & 0 deletions tasks/interactive_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
path: "{{ galaxy_config_dir }}/tool_conf.xml"
regexp: '\s*<!--\s*\n.*(<section id="interactivetools" name="Interactive tools">[\d\D\n]*</section>)\n\s*-->'
replace: '\n \1'

- name: Copy script to dynamically determine if a job should use Docker
ansible.builtin.template:
src: default_dispatch.py.j2
dest: "{{ galaxy_server_dir }}/lib/galaxy/jobs/rules/{{ _galaxy_default_dispatcher }}.py"
7 changes: 7 additions & 0 deletions tasks/set_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
- name: Load component variables
ansible.builtin.include_vars: vars/src_galaxy_vars.yml

- name: Sanity check
block:
- name: Assert default handler is valid
ansible.builtin.assert:
that:
- "['singularity', 'docker', 'local'] is contains(_galaxy_jobs_default)"

- name: Load interactive tools variables
ansible.builtin.include_vars: vars/interactive_tools_vars.yml

Expand Down
8 changes: 8 additions & 0 deletions templates/default_dispatch.py.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from galaxy.jobs import JobDestination
import os

def {{ _galaxy_default_dispatcher }}(tool):
if tool.tool_type == 'interactive':
return 'docker'
else:
return '{{ _galaxy_jobs_default }}'
14 changes: 7 additions & 7 deletions templates/galaxy/config/job_conf.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ runners:
workers: 4

execution:
default: docker_dispatch
default: {{ _galaxy_default_dispatcher if _galaxy_use_interactive_tools else _galaxy_jobs_default }}
environments:
local:
runner: local

docker_local:
docker:
runner: local
docker_enabled: true
docker_set_user:
docker_sudo: false

docker_dispatch:
{% if _galaxy_use_interactive_tools %}
{{ _galaxy_default_dispatcher }}:
runner: dynamic
type: docker_dispatch
docker_destination_id: docker_local
default_destination_id: local

type: python
function: {{ _galaxy_default_dispatcher }}
{% endif %}
tools:
- class: local # these special tools that aren't parameterized for remote execution - expression tools, upload, etc
environment: local
2 changes: 2 additions & 0 deletions vars/internal_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ _galaxy_local_address: localhost:8080

galaxy_src_documentation: https://github.com/UtrechtUniversity/vre-docs

_galaxy_default_dispatcher: default_dispatcher # function and file name for the dynamic job handler used by interactive tools

# Variables for the docker role

docker_install_compose: false
Expand Down
3 changes: 2 additions & 1 deletion vars/src_galaxy_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ _galaxy_custom_repo_branch: "{{ src_galaxy_custom_repo_branch | default('main',
_galaxy_api_exposed: "{{ src_galaxy_api_exposed | default(true, true) }}"
_galaxy_use_interactive_tools: "{{ src_galaxy_interactive_tools | default(true, true) | bool }}"
_galaxy_server_fqdn: "{{ workspace_fqdn | default('localhost', true) }}"
_galaxy_jobs_docker: "{{ _galaxy_use_interactive_tools or (src_galaxy_jobs_docker | default(true, false) | bool ) }}"
_galaxy_jobs_default: "{{ src_galaxy_jobs_default | default('local', true) }}"
_galaxy_enable_docker: "{{ _galaxy_use_interactive_tools or (_galaxy_jobs_default == 'docker' ) }}"

# Build the final lists of tool and workflow installation files
_galaxy_tool_files: "{{ src_galaxy_tool_files | default('', true) | split(',') | select() + _galaxy_default_tool_files_list }}" # select() necessary because split on the default '' yields ['']
Expand Down

0 comments on commit a6b5a25

Please sign in to comment.