Skip to content

Commit 9afb0b7

Browse files
committed
add job runnner select field
1 parent 6800249 commit 9afb0b7

File tree

4 files changed

+107
-11
lines changed

4 files changed

+107
-11
lines changed

form.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ form:
55
- bc_num_hours
66
- node_type
77
- num_cores
8+
- job_runner
89
- bc_email_on_started
910
attributes:
1011
num_cores:
@@ -37,3 +38,17 @@ attributes:
3738
- [ "any", "any" ]
3839
- [ "hugemem", "hugemem" ]
3940
- [ "debug", "debug" ]
41+
job_runner:
42+
widget: select
43+
label: "Galaxy tool runner"
44+
help: |
45+
- **local** - When running tools locally, they are child processes of the Galaxy server.
46+
The maximum number of concurrent jobs is the number of cores.
47+
When session ends, you lose contact with those jobs still running,
48+
and they must be restarted.
49+
- **cluster** - When running tools in a cluster, they are separate processes from the Galaxy server.
50+
They are jobs submitted to Owens Cluster as configured above and there is no maximum number of concurrent jobs.
51+
When session ends, the jobs will continue to run and finish.
52+
options:
53+
- [ "local", "local"]
54+
- [ "cluster", "pbs" ]

install-galaxy.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@ fi
77
cd galaxy
88
git checkout release_19.09
99

10+
11+
# Add job rules
12+
(
13+
umask 077
14+
cat > "./lib/galaxy/jobs/rules/destinations.py" << EOL
15+
import logging
16+
from galaxy.jobs.mapper import JobMappingException
17+
from galaxy.jobs import JobDestination
18+
19+
log = logging.getLogger(__name__)
20+
21+
FAILURE_MESSAGE = 'This tool could not be run because of a misconfiguration in the Galaxy job running system, please report this error'
22+
23+
24+
def dynamic_cores_time(app, tool, job, user_email, resource_params):
25+
# handle job resource parameters
26+
if not resource_params.get("cores") and not resource_params.get("time"):
27+
default_destination_id = app.job_config.get_destination(None)
28+
log.warning('(%s) has no input parameter cores or time. Run with default runner: %s' % (job.id, default_destination_id.runner))
29+
return default_destination_id
30+
31+
try:
32+
cores = resource_params.get("cores")
33+
time = resource_params.get("time")
34+
resource_list = 'walltime=%s:00:00,nodes=1:ppn=%s' % (time, cores)
35+
except:
36+
default_destination_id = app.job_config.get_destination(None)
37+
log.warning('(%s) failed to run with customized configuration. Run with default runner: %s' % (job.id, default_destination_id.runner))
38+
return default_destination_id
39+
40+
log.info('returning pbs runner with configuration %s', resource_list)
41+
return JobDestination(runner="pbs", params={"Resource_List": resource_list})
42+
EOL
43+
)
44+
1045
# Install dependencies
1146
# Retrieved from line 1-54 in https://github.com/galaxyproject/galaxy/blob/release_19.09/run.sh
1247
. ./scripts/common_startup_functions.sh

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ role: batch_connect
66
description: |
77
This app will launch [Galaxy 19.09] on the [Owens cluster].
88
9-
[Galaxy]: https://galaxyproject.org/
9+
[Galaxy 19.09]: https://galaxyproject.org/
1010
[Owens cluster]: https://www.osc.edu/resources/technical_support/supercomputers/owens

template/before.sh.erb

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ MOUNT="/node/${HOSTNAME}/8080=galaxy.webapps.galaxy.buildapp:uwsgi_app()"
1111
DATAROOT=${HOME}/.galaxy
1212
EMAIL="${USER}@osc.edu"
1313
export JOB_CONFIG_FILE_PATH="${PWD}/job_conf.xml"
14+
export JOB_RESOURCE_PARAMS_CONF_FILE_PATH="${PWD}/job_resource_params_conf.xml"
15+
export WORKFLOW_RESOURCE_PARAMS_CONF_FILE_PATH="${PWD}/workflow_resource_params_conf.xml"
1416

1517
echo "GALAXY location: '${GALAXY_PATH}'"
1618
echo "Data location: '${DATAROOT}'"
@@ -33,27 +35,67 @@ cat > "${JOB_CONFIG_FILE_PATH}" << EOL
3335
<?xml version="1.0"?>
3436
<!-- A sample job config that explicitly configures job running the way it is configured by default (if there is no explicit config). -->
3537
<job_conf>
38+
<resources>
39+
<group id="basic">cores,time</group>
40+
</resources>
41+
<tools>
42+
<tool id="bed2gff1" destination="dynamic_cores_time" resources="basic"/>
43+
</tools>
3644
<plugins>
45+
<plugin id="local" type="runner" load="galaxy.jobs.runners.local:LocalJobRunner"/>
3746
<plugin id="pbs" type="runner" load="galaxy.jobs.runners.pbs:PBSJobRunner"/>
47+
<plugin id="dynamic" type="runner">
48+
<param id="rules_module">galaxy.jobs.rules</param>
49+
</plugin>
3850
</plugins>
39-
<destinations default="pbs_default">
40-
<destination id="pbs_default" runner="pbs">
41-
<param id="Resource_List">walltime=5:00:00,nodes=1:ppn=<%= ppn %></param>
42-
<param id="-p">128</param>
51+
<destinations default="<%= context.job_runner %>">
52+
<destination id="dynamic_cores_time" runner="dynamic">
53+
<param id="type">python</param>
54+
<param id="function">dynamic_cores_time</param>
4355
</destination>
44-
<destination id="other_cluster" runner="pbs">
45-
<param id="destination">@other.cluster</param>
56+
<destination id="pbs" runner="pbs">
57+
<param id="Resource_List">walltime=5:00:00,nodes=1:ppn=<%= ppn %></param>
4658
</destination>
47-
<destination id="long_jobs" runner="pbs">
48-
<param id="Resource_List">walltime=5:00:00,nodes=1:ppn=1</param>
49-
<param id="-p">128</param>
50-
<param id="Output_Path"></param>
59+
<destination id="local" runner="local">
60+
<param id="local_slots"><%= ppn %></param>
5161
</destination>
5262
</destinations>
5363
</job_conf>
5464
EOL
5565
)
5666

67+
# Generate Galaxy job resource parameter configuration file
68+
(
69+
umask 077
70+
cat > "${JOB_RESOURCE_PARAMS_CONF_FILE_PATH}" << EOL
71+
<parameters>
72+
<param label="Cores" name="cores" type="integer" min="1" max="28" value="1" help="Number of processing cores, 'ppn' value (1-28). Leave blank to use default value." />
73+
<param label="Walltime" name="time" type="integer" size="3" min="1" max="24" value="1" help="Maximum job time in hours, 'walltime' value (1-24). Leave blank to use default value." />
74+
</parameters>
75+
EOL
76+
)
77+
78+
79+
# Generate Galaxy workflow resource parameter configuration file
80+
(
81+
umask 077
82+
cat > "${WORKFLOW_RESOURCE_PARAMS_CONF_FILE_PATH}" << EOL
83+
<parameters>
84+
<param label="Processors" name="processors" type="integer" min="1" max="28" value="" help="Number of processing cores, 'ppn' value (1-28). Leave blank to use default value." />
85+
<param label="Memory" name="memory" type="integer" min="1" max="256" value="" help="Memory size in gigabytes, 'pmem' value (1-256). Leave blank to use default value." />
86+
<param label="Time" name="time" type="integer" min="1" max="744" value="" help="Maximum job time in hours, 'walltime' value (1-744). Leave blank to use default value." />
87+
<param label="Project" name="project" type="text" value="" help="Project to assign resource allocation to. Leave blank to use default value." />
88+
<param label="Workflow Job Priority" name="priority" type="select" value="med" help="What priority should the jobs in this workflow run at? (Overrides any declared job priority)">
89+
<option value="low" label="Low"/>
90+
<option value="med" label="Medium"/>
91+
<option value="high" label="High"/>
92+
<option value="ultra" label="Ultra"/>
93+
<option value="plus_ultra" label="Plus Ultra"/>
94+
</param>
95+
</parameters>
96+
EOL
97+
)
98+
5799
# Generate Galaxy configuration file
58100
(
59101
umask 077
@@ -82,5 +124,9 @@ galaxy:
82124
data_dir: ${DATAROOT}
83125
single_user: ${EMAIL}
84126
tool_dependency_dir: ${GALAXY_PATH}/database/dependencies
127+
job_resource_params_file: ${JOB_RESOURCE_PARAMS_CONF_FILE_PATH}
128+
workflow_resource_params_file: ${WORKFLOW_RESOURCE_PARAMS_CONF_FILE_PATH}
129+
admin_users: ${EMAIL}
130+
job_config_file: ${JOB_CONFIG_FILE_PATH}
85131
EOL
86132
)

0 commit comments

Comments
 (0)