Skip to content

Commit 035bf5b

Browse files
committed
Add new class method to build from noodles promise, and add execute() method
1 parent eafcdc3 commit 035bf5b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

fairworkflows/fairworkflow.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def from_rdf(cls, rdf: rdflib.Graph, uri: str,
6868
self.anonymise_rdf()
6969
return self
7070

71+
@classmethod
72+
def from_noodles_promise(cls, noodles_promise):
73+
self.noodles_promise = noodles_promise
74+
7175
def _extract_steps(self, rdf, uri, fetch_steps=False):
7276
"""Extract FairStep objects from rdf.
7377
@@ -327,6 +331,12 @@ def display(self):
327331
rdf2dot(self._rdf, f)
328332
return graphviz.Source.from_file(filename)
329333

334+
def execute(self, num_threads=1):
335+
if num_threads==1:
336+
return run_single(self.noodles_promise)
337+
elif num_threads>1:
338+
return run_parallel(self.noodles_promise, num_threads)
339+
330340
def draw(self, filepath):
331341
"""Visualize workflow.
332342

0 commit comments

Comments
 (0)