Skip to content

Commit

Permalink
Merge pull request #1387 from mvdbeek/skipped_state
Browse files Browse the repository at this point in the history
Support for testing workflows with conditional steps
  • Loading branch information
mvdbeek authored Sep 14, 2023
2 parents 95db94d + 052b1cb commit 0b34f34
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
8 changes: 5 additions & 3 deletions planemo/galaxy/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _execute( # noqa C901

if not kwds.get("no_wait"):
final_state = _wait_for_invocation_jobs(ctx, user_gi, invocation_id, polling_backoff)
if final_state != "ok":
if final_state not in ("ok", "skipped"):
msg = "Failed to run workflow final history state is [%s]." % final_state
error_message = msg if not error_message else f"{error_message}. {msg}"
ctx.vlog(msg)
Expand Down Expand Up @@ -698,7 +698,7 @@ def _invocation(self):

@property
def was_successful(self):
return self.history_state in ["ok", None] and self.invocation_state == "scheduled"
return self.history_state in ["ok", "skipped", None] and self.invocation_state == "scheduled"


def _tool_id(tool_path):
Expand Down Expand Up @@ -740,7 +740,7 @@ def _retry_on_timeouts(ctx, gi, f):
except RequestException:
end_time = time.time()
if end_time - start_time > 45 and (try_num + 1) < try_count:
ctx.vlog("Galaxy seems to have timedout, retrying to fetch status.")
ctx.vlog("Galaxy seems to have timed out, retrying to fetch status.")
continue
else:
raise
Expand Down Expand Up @@ -815,6 +815,8 @@ def get_state():
return terminal_state
if current_non_terminal_states:
return None
if len(current_states) > 1:
current_states = current_states - {"skipped"}
assert len(current_states) == 1, f"unexpected state(s) found: {current_states}"
return current_states.pop()

Expand Down
7 changes: 7 additions & 0 deletions tests/data/wf18_simple_conditional-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- doc: Simple conditional concat workflow test
job:
some_file:
class: File
path: hello.txt
should_run: false
outputs: {}
13 changes: 13 additions & 0 deletions tests/data/wf18_simple_conditional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class: GalaxyWorkflow
inputs:
should_run:
type: boolean
some_file:
type: data
steps:
cat1:
tool_id: cat1
in:
input1: some_file
should_run: should_run
when: $(inputs.should_run)
10 changes: 10 additions & 0 deletions tests/test_cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,13 @@ def test_workflow_test_output_sanitization(self):
test_command = self.append_profile_argument_if_needed(test_command)
test_command.append(test_artifact)
self._check_exit_code(test_command, exit_code=0)

@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
def test_workflow_test_skipped_invocation(self):
cat = os.path.join(PROJECT_TEMPLATES_DIR, "demo", "cat.xml")
with self._isolate():
test_artifact = os.path.join(TEST_DATA_DIR, "wf18_simple_conditional.yml")
test_command = self._test_command("--extra_tools", cat)
test_command = self.append_profile_argument_if_needed(test_command)
test_command.append(test_artifact)
self._check_exit_code(test_command, exit_code=0)

0 comments on commit 0b34f34

Please sign in to comment.