Skip to content

Commit 0efbe14

Browse files
Merge pull request #176 from fair-workflows/use-noodles-from-call
Use noodles.workflows.from_call for execute method
2 parents 966ec62 + 9888080 commit 0efbe14

2 files changed

Lines changed: 2 additions & 34 deletions

File tree

fairworkflows/fairworkflow.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -379,37 +379,15 @@ def execute(self, *args, **kwargs):
379379
logger = logging.getLogger('noodles')
380380
logger.setLevel(logging.INFO)
381381
logger.handlers = [log_handler]
382-
self.workflow_level_promise = self._replace_input_arguments(self.workflow_level_promise, args, kwargs)
382+
self.workflow_level_promise = noodles.workflow.from_call(
383+
noodles.get_workflow(self.workflow_level_promise).root_node.foo, args, kwargs, {})
383384
result = noodles.run_single(self.workflow_level_promise)
384385

385386
# Generate the retrospective provenance as a (nano-) Publication object
386387
retroprov = self._generate_retrospective_prov_publication(log.getvalue())
387388

388389
return result, retroprov
389390

390-
def _replace_input_arguments(self, promise: noodles.interface.PromisedObject, args, kwargs):
391-
"""
392-
Replace the input arguments of the promise so we can run the workflow with the right
393-
inputs. This goes into the guts of noodles, doing something noodles was not intended to be
394-
used for.
395-
TODO: find a better solution for this
396-
"""
397-
workflow = noodles.get_workflow(promise)
398-
signature = inspect.signature(workflow.root_node.foo)
399-
arguments_dict = self._get_arguments_dict(args, kwargs, signature)
400-
workflow.root_node.bound_args = inspect.BoundArguments(signature, arguments_dict)
401-
return promise
402-
403-
@staticmethod
404-
def _get_arguments_dict(args, kwargs, signature):
405-
"""
406-
Create dictionary of keyword arguments from positional and keyword arguments and the
407-
signature of the function.
408-
"""
409-
arguments_dict = {key: arg for arg, key in zip(args, signature.parameters.keys())}
410-
arguments_dict.update(kwargs)
411-
return arguments_dict
412-
413391
def _generate_retrospective_prov_publication(self, log:str) -> nanopub.Publication:
414392
"""
415393
Utility method for generating a Publication object for the retrospective

tests/test_fairworkflow.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,6 @@ def process_image(im: OtherType):
373373
assert result.message == obj.message
374374
assert isinstance(prov, Publication)
375375

376-
def test_get_arguments_dict(self):
377-
args = (1, 2)
378-
kwargs = {'c': 3, 'd': 4}
379-
380-
def func(a, b, c, d):
381-
return
382-
383-
result = FairWorkflow._get_arguments_dict(args, kwargs, inspect.signature(func))
384-
assert result == {'a': 1, 'b': 2, 'c': 3, 'd': 4}
385-
386376
def test_workflow_non_decorated_step(self):
387377
def return_value(a: float) -> float:
388378
"""Return the input value. NB: no is_fairstep decorator!"""

0 commit comments

Comments
 (0)