Skip to content

Commit

Permalink
Merge pull request #18 from galaxyproject/rename_match_to_if
Browse files Browse the repository at this point in the history
Rename match clause to if for better readability
  • Loading branch information
nuwang authored May 23, 2022
2 parents 272317f + 652712c commit 0e65d9a
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 59 deletions.
12 changes: 6 additions & 6 deletions docs/topics/vortex_by_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,30 @@ Rules provide a means by which to conditionally change entity requirements.
mem: cores * 3
rules:
- id: my_overridable_rule
match: input_size < 5
if: input_size < 5
fail: We don't run piddling datasets of {input_size}GB
bwa:
scheduling:
require:
- pulsar
rules:
- id: my_overridable_rule
match: input_size < 1
if: input_size < 1
fail: We don't run piddling datasets
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
execute: |
from galaxy.jobs.mapper import JobNotReadyException
raise JobNotReadyException()
- match: input_size > 10 and input_size < 20
- if: input_size > 10 and input_size < 20
scheduling:
require:
- highmem
- match: input_size >= 20
- if: input_size >= 20
fail: Input size: {input_size} is too large shouldn't run
The match clause can contain arbitrary python code, including multi-line python code. The only requirement is that the
The if clause can contain arbitrary python code, including multi-line python code. The only requirement is that the
last statement in the code block must evaluate to a boolean value. In this example, the `input_size` variable is an
automatically available contextual variable which is computed by totalling the sizes of all inputs to the job.
Additional available variables include app, job, tool, and user.
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/mapping-inheritance-invalid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
gpus: 2
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
- match: input_size > 10 and input_size < 20
- if: input_size > 10 and input_size < 20
scheduling:
require:
- highmem
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run
trinity:
inherits: bwa
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/mapping-inheritance-no-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
gpus: 2
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run
trinity:
inherits: bwa
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/mapping-inheritance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
gpus: 2
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run
trinity:
inherits: bwa
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/mapping-merge-multiple-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
mem: cores * 4
- id: highmem_rule
match: input_size > 40
if: input_size > 40
fail: ""
scheduling:
require:
- highmem
- match: input_size >= 20 and input_size <= 30
- if: input_size >= 20 and input_size <= 30
fail: Too much data, shouldn't run
users:
[email protected]:
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/mapping-merge-multiple-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ tools:
mem: 8
env: {}
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
rules:
- id: highmem_rule
match: input_size > 40
if: input_size > 40
fail: a different kind of error
scheduling:
require:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/mapping-rule-argument-based.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tools:
- general
limbo:
rules:
- match: |
- if: |
helpers.job_args_match(job, app, {'input_opts': {'db_selector': 'db'}})
scheduling:
prefer:
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/mapping-rule-execute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
execute: |
from galaxy.jobs.mapper import JobNotReadyException
raise JobNotReadyException()
- match: input_size > 10 and input_size < 20
- if: input_size > 10 and input_size < 20
scheduling:
require:
- highmem
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run

destinations:
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/mapping-rule-tool-limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ tools:
- general
toolshed.g2.bx.psu.edu/repos/rnateam/mafft/rbc_mafft/.*:
rules:
- match: |
- if: |
helpers.concurrent_job_count_for_tool(app, tool, user) >= 2 # concurrent jobs per user
execute: |
from galaxy.jobs.mapper import JobNotReadyException
raise JobNotReadyException()
toolshed.g2.bx.psu.edu/repos/artbio/repenrich/repenrich/.*:
rules:
- match: |
- if: |
helpers.concurrent_job_count_for_tool(app, tool) >= 3 # total concurrent jobs
execute: |
from galaxy.jobs.mapper import JobNotReadyException
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/mapping-rules-changed-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ tools:
- pulsar
rules:
- id: firstrule
match: input_size <= 10
if: input_size <= 10
cores: 5
mem: cores * 4
12 changes: 6 additions & 6 deletions tests/fixtures/mapping-rules-changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
- match: input_size > 10 and input_size < 20
- if: input_size > 10 and input_size < 20
scheduling:
require:
- highmem
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run
users:
[email protected]:
Expand All @@ -47,10 +47,10 @@ users:
require:
- earth
rules:
- match: True
- if: True
cores: 6
mem: cores * 6
- match: input_size >= 5
- if: input_size >= 5
fail: Just because
[email protected]:
scheduling:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/mapping-rules-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ tools:
- pulsar
rules:
- id: firstrule
match: input_size <= 10
if: input_size <= 10
cores: 3
mem: cores * 4
12 changes: 6 additions & 6 deletions tests/fixtures/mapping-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ tools:
reject:
- pulsar
rules:
- match: input_size < 5
- if: input_size < 5
fail: We don't run piddling datasets
bwa:
scheduling:
require:
- pulsar
rules:
- match: input_size <= 10
- if: input_size <= 10
cores: 4
mem: cores * 4
- match: input_size > 10 and input_size < 20
- if: input_size > 10 and input_size < 20
scheduling:
require:
- highmem
- match: input_size >= 20
- if: input_size >= 20
fail: Too much data, shouldn't run
users:
[email protected]:
Expand All @@ -47,10 +47,10 @@ users:
require:
- earth
rules:
- match: True
- if: True
cores: 6
mem: cores * 6
- match: input_size >= 5
- if: input_size >= 5
fail: Just because
[email protected]:
scheduling:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/scenario-admin-group-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tools:
reject:
- offline
rules:
- match: input_size >= 0.1
- if: input_size >= 0.1
scheduling:
require:
- highmem
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/scenario-jenkins-bot-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tools:
reject:
- offline
rules:
- match: input_size >= 0.1
- if: input_size >= 0.1
scheduling:
require:
- highmem
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/scenario-job-too-small-for-highmem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ tools:
reject:
- offline
rules:
- match: input_size >= 10
- if: input_size >= 10
cores: 16
- match: input_size >= 20
- if: input_size >= 20
scheduling:
require:
- highmem
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/scenario-node-offline-high-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ tools:
reject:
- offline
rules:
- match: input_size >= 10
- if: input_size >= 10
cores: 16
- match: input_size >= 20
- if: input_size >= 20
scheduling:
require:
- highmem
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/scenario-too-many-highmem-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ tools:
reject:
- offline
rules:
- match: input_size >= 0.1
- if: input_size >= 0.1
scheduling:
require:
- highmem

users:
default:
rules:
- match: |
- if: |
from galaxy.jobs.rule_helper import RuleHelper
from vortex.core.entities import TagType
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/scenario-trinity-job-too-much-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ tools:
reject:
- offline
rules:
- match: input_size >= 0.1
- if: input_size >= 0.1
scheduling:
require:
- highmem
- match: input_size >= 200
- if: input_size >= 200
fail: "Input file size of {input_size}GB is > maximum allowed 200GB limit"
destinations:
slurm:
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/scenario-trinity-job-with-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tools:
reject:
- offline
rules:
- match: input_size >= 0.1
- if: input_size >= 0.1
scheduling:
require:
- highmem
Expand Down
5 changes: 2 additions & 3 deletions tests/fixtures/scenario-usegalaxy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ tools:
prefer:
- pulsar
rules:
- match: input_size >= 0.2
- if: input_size >= 0.2
cores: 16

users:
default:
rules:
- match: |
False
- if: False
fail: "You cannot have more than 4 high-mem jobs running concurrently"
destinations:
slurm:
Expand Down
Loading

0 comments on commit 0e65d9a

Please sign in to comment.