important-london-94970
01/29/2025, 4:28 PMimport pandas as pd
from metaflow import FlowSpec, step, pypi_base, kubernetes
@pypi_base(packages={"pandas": "2.2.3"})
class KubernetesFlow(FlowSpec):
"""Sample Metaflow Flow"""
@step
def start(self):
"""Start step"""
self.x = 1
print("MF pipe is starting.")
self.next(self.p1, self.p2)
# When running on macbooks with an M-chip, we need to specify an
# image that has specifically been built with --platform=linux/amd64
# in order to prevent some wonky file system issues.
@kubernetes(cpu=2, memory=1200)
@step
def p1(self):
"""First parallel step"""
self.hi = pd.DataFrame([{"hello": "there"}])
print("Executing first parallel step.")
self.next(self.join)
@step
def p2(self):
"""Second parallel step"""
print("Executing second parallel step.")
self.next(self.join)
@step
def join(self, artifacts):
"""Join step"""
print("Executing join step.")
print(f"Artifacts from p1: {artifacts}")
self.next(self.end)
@step
def end(self):
"""End step"""
print("MF pipe is all done.")
if __name__ == "__main__":
KubernetesFlow()
ancient-application-36103
01/29/2025, 4:29 PMimportant-london-94970
01/29/2025, 4:30 PM