Skip to content

Commit

Permalink
Renamed workflow method, added property decorator and added test.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwieters committed Oct 18, 2023
1 parent 03b6e24 commit b3b5fb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/esm_runscripts/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def __init__(self, phases, always_run_with=[]):
self.phases = phases
self.always_run_with = always_run_with

def num_phases_in_workflow(self):
@property
def num_phases(self):
"""
Return the number of phases in workflow.
"""
Expand Down Expand Up @@ -509,7 +510,7 @@ def init_default_workflow(default_workflow, config):
default_workflow.phases.append(WorkflowPhase(phase))

for ind, phase in enumerate(default_workflow.phases):
if ind < default_workflow.num_phases_in_workflow() - 1:
if ind < default_workflow.num_phases - 1:
phase.run_before = default_workflow.phases[ind+1].name
else:
phase.run_after = default_workflow.phases[ind-1].name
Expand Down
4 changes: 4 additions & 0 deletions tests/test_esm_runscripts/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def test_config():
'submit_to_batch_system': True}}}}}
return config

def test_num_phases(test_workflow_object, test_config):
test_workflow_object = workflow.init_default_workflow(test_workflow_object, test_config)
assert test_workflow_object.num_phases == 3

def test_check_user_workflow_dependency(test_workflow_object, test_config):
test_workflow_object = workflow.init_default_workflow(test_workflow_object, test_config)
test_workflow_object = workflow.collect_all_user_workflows(test_workflow_object, test_config)
Expand Down

0 comments on commit b3b5fb1

Please sign in to comment.