1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

from metaflow import FlowSpec, step
class MyFlow():

	def start(self):
		print('hello')

	def end(self):
		print('world')

 if __name__ == '__main__':
	 MyFlow()
					from metaflow import FlowSpec, step
class MyFlow(FlowSpec):

	@step
	def start(self):
		print('hello')
		self.next(self.end)

	@step
	def end(self):
		print('world')

 if __name__ == '__main__':
	 MyFlow()
					from metaflow import FlowSpec, step, card
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple', 'orange']
		self.next(self.end)

	@step
	def end(self):
		self.fruits.append('kiwi')
		print('fruits', self.fruits)

 if __name__ == '__main__':
	 MyFlow()
					from metaflow import FlowSpec, step, conda
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple', 'orange']
		self.next(self.end)

	@step
	def train(self):

	@step
	def end(self):
		print('model', self.model)

 if __name__ == '__main__':
	 MyFlow()
					from metaflow import FlowSpec, step, conda, resources
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple', 'orange']
		self.next(self.train)

	@step
	def train(self):

	@step
	def end(self):
		pass

 if __name__ == '__main__':
	 MyFlow()
					from metaflow import FlowSpec, step, conda, resources
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple', 'orange']
		self.next(self.train)

	@conda(libraries={'stable-diffusion': '1.0.0'})
	@resources(memory=64000, gpu=2)
	@step
	def train(self):
		from stable_diffusion import from_prompt
		self.image = from_prompt("Robot eating " + self.input)
		self.next(self.end)

	@step
	def join(self, inputs):

	@step
	def end(self):
		pass

 if __name__ == '__main__':
	 MyFlow()from metaflow import FlowSpec, step, conda, resources, schedule
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple'] * 4
		self.next(self.train, foreach="fruits")

	@conda(libraries={'stable-diffusion': '1.0.0'})
	@resources(memory=64000, gpu=2)
	@step
	def train(self):
		from stable_diffusion import from_prompt
		self.image = from_prompt("Robot eating " + self.input)
		self.next(self.join)

	@step
	def join(self, inputs):
		self.next(self.end)

	@step
	def end(self):
		pass

 if __name__ == '__main__':
	 MyFlow()from metaflow import FlowSpec, step, conda, resources, project
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple'] * 4
		self.next(self.train, foreach="fruits")

	@conda(libraries={'stable-diffusion': '1.0.0'})
	@resources(memory=64000, gpu=2)
	@step
	def train(self):
		from stable_diffusion import from_prompt
		self.image = from_prompt("Robot eating " + self.input)
		self.next(self.join)

	@step
	def join(self, inputs):
		self.next(self.end)

	@step
	def end(self):
		pass

 if __name__ == '__main__':
	 MyFlow()from metaflow import FlowSpec, step, conda, resources
class MyFlow(FlowSpec):

	@step
	def start(self):
		self.fruits = ['apple', 'orange']
		self.next(self.train)

	@conda(libraries={'stable-diffusion': '1.0.0'})
	@resources(memory=64000, gpu=2)
	@step
	def train(self):
		from stable_diffusion import from_prompt
		self.image = from_prompt("Robot eating " + self.fruits[0])
		self.next(self.end)

	@step
	def end(self):
		self.output = self.img

 if __name__ == '__main__':
	 MyFlow()
	
In []:
from metaflow import Run
run = Run("MyFlow/2")
run["end"].task.data.fruits
from metaflow.cards import get_cards
get_cards("MyFlow/3/end/1")
from metaflow import Run
run = Run("MyFlow/4")
run["train"].task.data.model
from metaflow import Run
run = Run("MyFlow/5")
run["train"].task.data.image
from metaflow import Run
run = Run("MyFlow/6")
[t.data.image for t in run["train"]]
from metaflow import Flow, namespace
namespace(None)
f = Flow("MyFlow")
r = f.runs("runtime:argo-workflows")
for run in r:
	print(run.id, run.created_at)
from metaflow import Flow, namespace
namespace(None)
f = Flow("MyFlow")
v1 = f.runs("project_branch:prod")
v2 = f.runs("project_branch:cnn_v2")
compare_performance(v1, v2)
from metaflow import Run, namespace
namespace(None)
Run("argo-44234")['end'].stderr
Out []:
["apple", "orange", "kiwi"]

Metaflow Custom Card

Visualizing artifact: fruits


"argo-43567" "2022-09-14T00:00:00Z"
"argo-43564" "2022-09-13T00:00:00Z"
"argo-43561" "2022-09-12T00:00:00Z"
						

Scheduled run argo-44234 FAILED

Exception in MyFlow/end:
AttributeError:
Flow MyFlow has no attribute 'img'