@@ -75,6 +75,30 @@ def from_noodles_promise(cls, noodles_promise, description: str = None, label: s
7575 is_pplan_plan : bool = True , derived_from = None ):
7676 self = cls (description = description , label = label , is_pplan_plan = is_pplan_plan , derived_from = derived_from )
7777 self .noodles_promise = noodles_promise
78+
79+ from noodles import get_workflow
80+ workflow = get_workflow (self .noodles_promise )
81+
82+ steps_dict = {}
83+ for i , n in workflow .nodes .items ():
84+ steps_dict [i ] = n .foo ._fairstep
85+
86+ for i , step in steps_dict .items ():
87+ self ._add_step (step )
88+
89+ for i in workflow .links :
90+ current_step = steps_dict [i ]
91+ from_uri = rdflib .URIRef (steps_dict [i ].uri + '#' + current_step .outputs [0 ].name )
92+ for j in workflow .links [i ]:
93+ linked_step = steps_dict [j [0 ]]
94+ linked_var_name = str (j [1 ].name )
95+ to_uri = rdflib .URIRef (linked_step .uri + '#' + linked_var_name )
96+ self ._rdf .add ((from_uri , namespaces .PPLAN .bindsTo , to_uri ))
97+
98+ if len (workflow .links [i ]) == 0 :
99+ to_uri = rdflib .BNode ('result' )
100+ self ._rdf .add ((from_uri , namespaces .PPLAN .bindsTo , to_uri ))
101+
78102 return self
79103
80104 def _extract_steps (self , rdf , uri , fetch_steps = False ):
@@ -172,7 +196,9 @@ def first_step(self, step: FairStep):
172196
173197 def _add_step (self , step : FairStep ):
174198 """Add a step to workflow (low-level method)."""
199+
175200 self ._steps [step .uri ] = step
201+
176202 self ._rdf .add ((rdflib .URIRef (step .uri ), namespaces .PPLAN .isStepOfPlan ,
177203 self .self_ref ))
178204 self ._last_step_added = step
0 commit comments