ancient-guitar-13766
01/21/2025, 4:06 PMcrooked-jordan-29960
01/21/2025, 6:20 PMfrom metaflow import FlowSpec, step, current
class ParentLookupFlow(FlowSpec):
@step
def start(self):
self.next(self.a, self.b)
@step
def a(self):
self.step_name = current.step_name
self.next(self.join)
@step
def b(self):
self.step_name = current.step_name
self.next(self.join)
@step
def join(self, inputs):
parents = [inp.step_name for inp in inputs]
print("My parents are:", parents)
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
ParentLookupFlow()
Option 2: Messier Metaflow internals approach without polluting upstream steps
from metaflow import FlowSpec, step
class ParentLookupFlow(FlowSpec):
@step
def start(self):
self.next(self.a, self.b)
@step
def a(self):
self.next(self.join)
@step
def b(self):
self.next(self.join)
@step
def join(self, inputs):
my_name = self._current_step
parents = []
for k,v in self._graph_info['steps'].items():
if my_name in v['next']:
parents.append(v['name'])
print("My parents are:", parents)
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
ParentLookupFlow()