Skip to content

Commit a39d644

Browse files
Michele BerselliMichele Berselli
Michele Berselli
authored and
Michele Berselli
committed
added extra_dimension, added reset_failed ff_function
1 parent 79ed08a commit a39d644

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

docs/ff_functions.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,18 @@ The function ``reset_all(metawfr_uuid<str>, ff_key<key>, verbose=False)`` allows
158158
# -> key generated by ff_utils to authenticate on the portal
159159
160160
reset_metawfr.reset_all(metawfr_uuid, ff_key, verbose=False)
161+
162+
163+
The function ``reset_failed(metawfr_uuid<str>, ff_key<key>, verbose=False)`` allows to re-set all workflow-runs in meta-workflow-run with status ``failed``.
164+
165+
.. code-block:: python
166+
167+
from magma_ff import reset_metawfr
168+
169+
# UUIDs
170+
metawfr_uuid = '' # uuid for meta-workflow-run
171+
172+
# ff_key
173+
# -> key generated by ff_utils to authenticate on the portal
174+
175+
reset_metawfr.reset_failed(metawfr_uuid, ff_key, verbose=False)

docs/meta-workflow.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Structure
100100
# These are optional fields that can be used to change input argument dimension
101101
"scatter": 2, # dimension to scatter list argument if any
102102
"gather": 1, # increment for input argument dimension if previous steps were scattered
103+
"extra_dimension": 1, # additional increment for input dimension on top of gather
103104
104105
# These are optional fields
105106
# It is possible to skip these fields or add custom ones

magma/inputgenerator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ def _match_argument_file(self, arg_obj, run_obj):
259259
#end if
260260
#end for
261261
gather = getattr(arg_obj, 'gather', 0)
262+
gather += getattr(arg_obj, 'extra_dimension', 0) # extra input dimension
262263
if gather == 1: # gather 1 dimension
263264
arg_obj.files = file_
264-
elif gather > 1: # gather 2 dimensions
265+
elif gather > 1: # gather 2+ dimensions
265266
arg_obj.files = file_
266267
for i in range(1, gather):
267268
arg_obj.files = [arg_obj.files]

magma_ff/reset_metawfr.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def reset_shards(metawfr_uuid, shards_name, ff_key, verbose=False):
7979
################################################
8080
def reset_status(metawfr_uuid, status, step_name, ff_key, verbose=False):
8181
"""
82+
reset shards with status in status and with name in step_name
83+
8284
metawfr_uuid, uuid for meta-workflow-run
8385
status, status or list of status to reset
8486
step_name, name or list of names for step-workflows that need to be reset
@@ -122,6 +124,8 @@ def reset_status(metawfr_uuid, status, step_name, ff_key, verbose=False):
122124
################################################
123125
def reset_all(metawfr_uuid, ff_key, verbose=False):
124126
"""
127+
reset all shards
128+
125129
metawfr_uuid, uuid for meta-workflow-run
126130
"""
127131
# Get meta-workflow-run json from the portal
@@ -147,3 +151,38 @@ def reset_all(metawfr_uuid, ff_key, verbose=False):
147151
print(res_post)
148152
#end if
149153
#end def
154+
155+
################################################
156+
# reset_failed
157+
################################################
158+
def reset_failed(metawfr_uuid, ff_key, verbose=False):
159+
"""
160+
reset all shards with status failed
161+
162+
metawfr_uuid, uuid for meta-workflow-run
163+
"""
164+
# Get meta-workflow-run json from the portal
165+
run_json = ff_utils.get_metadata(metawfr_uuid, add_on='?frame=raw&datastore=database', key=ff_key)
166+
# Create MetaWorkflowRun object for meta-workflow-run
167+
run_obj = MetaWorkflowRun(run_json)
168+
169+
# Get shards to reset
170+
to_reset = []
171+
for shard_name, obj in run_obj.runs.items():
172+
if obj.status == 'failed':
173+
to_reset.append(shard_name)
174+
#end if
175+
#end for
176+
177+
# Create RunUpdate object for new meta-workflow-run
178+
runupd_obj = RunUpdate(run_obj)
179+
180+
# Reset shards
181+
patch_dict = runupd_obj.reset_shards(to_reset)
182+
183+
# Patch
184+
res_post = ff_utils.patch_metadata(patch_dict, metawfr_uuid, key=ff_key)
185+
if verbose:
186+
print(res_post)
187+
#end if
188+
#end def

test/files/CGAP_WGS_trio.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"argument_name": "input_bams",
110110
"argument_type": "file",
111111
"gather": 1,
112+
"extra_dimension": 1,
112113
"mount": true,
113114
"source": "workflow_add-readgroups-check",
114115
"source_argument_name": "bam_w_readgroups"

test/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_inputgen_WGS_trio_scatter():
180180
'env': 'env'
181181
},
182182
'input_files': [
183-
{'workflow_argument_name': 'input_bams', 'uuid': ['uuid-bam_w_readgroups-2:0', 'uuid-bam_w_readgroups-2:1', 'uuid-bam_w_readgroups-2:2'], 'mount': True}]}
183+
{'workflow_argument_name': 'input_bams', 'uuid': [['uuid-bam_w_readgroups-2:0', 'uuid-bam_w_readgroups-2:1', 'uuid-bam_w_readgroups-2:2']], 'mount': True}]}
184184
]
185185
shard = [
186186
'workflow_bwa-mem_no_unzip-check:0:0',

0 commit comments

Comments
 (0)