great-computer-6335
09/04/2024, 9:13 PMgreat-computer-6335
09/04/2024, 11:03 PMancient-application-36103
09/05/2024, 4:56 PMgreat-computer-6335
09/05/2024, 10:19 PMsquare-wire-39606
09/05/2024, 10:58 PMsquare-wire-39606
09/05/2024, 10:58 PMsquare-wire-39606
09/05/2024, 10:59 PMfrom metaflow import FlowSpec, step, kubernetes
class ForeachFlow(FlowSpec):
@step
def start(self):
self.titles = ['Stranger Things',
'House of Cards',
'Narcos']
self.next(self.a, foreach='titles')
@kubernetes(cpu=2, gpu=1)
@step
def a(self):
self.title = '%s processed' % self.input
self.next(self.join)
@step
def join(self, inputs):
self.results = [input.title for input in inputs]
self.next(self.end)
@step
def end(self):
print('\n'.join(self.results))
if __name__ == '__main__':
ForeachFlow()square-wire-39606
09/05/2024, 10:59 PMgreat-computer-6335
09/05/2024, 11:02 PMsquare-wire-39606
09/05/2024, 11:02 PMforeach attributegreat-computer-6335
09/05/2024, 11:03 PMsquare-wire-39606
09/05/2024, 11:03 PMdef start - self.next(self.a, foreach='titles') - instructs metaflow to launch a pod for every element in titlesquare-wire-39606
09/05/2024, 11:03 PMgreat-computer-6335
09/05/2024, 11:05 PMgreat-computer-6335
09/05/2024, 11:05 PMancient-application-36103
09/05/2024, 11:06 PMancient-application-36103
09/05/2024, 11:06 PMgreat-computer-6335
09/05/2024, 11:06 PMgreat-computer-6335
09/05/2024, 11:07 PMancient-application-36103
09/05/2024, 11:07 PMfrom metaflow import FlowSpec, step, kubernetes, parameter
class ForeachFlow(FlowSpec):
num_titles = Parameter(num_titles)
@step
def start(self):
self.titles = range(num_titles)
self.next(self.a, foreach='titles')
@kubernetes(cpu=2, gpu=1)
@step
def a(self):
self.title = '%s processed' % self.input
self.next(self.join)
@step
def join(self, inputs):
self.results = [input.title for input in inputs]
self.next(self.end)
@step
def end(self):
print('\n'.join(self.results))
if __name__ == '__main__':
ForeachFlow()ancient-application-36103
09/05/2024, 11:07 PMancient-application-36103
09/05/2024, 11:08 PMgreat-computer-6335
09/05/2024, 11:09 PMancient-application-36103
09/05/2024, 11:09 PMancient-application-36103
09/05/2024, 11:10 PMancient-application-36103
09/05/2024, 11:10 PMgreat-computer-6335
09/05/2024, 11:10 PMgreat-computer-6335
09/05/2024, 11:11 PMancient-application-36103
09/05/2024, 11:11 PMgreat-computer-6335
09/05/2024, 11:12 PMgreat-computer-6335
09/05/2024, 11:13 PMancient-application-36103
09/05/2024, 11:13 PMancient-application-36103
09/05/2024, 11:13 PMgreat-computer-6335
09/05/2024, 11:13 PMgreat-computer-6335
09/05/2024, 11:14 PMgreat-computer-6335
09/05/2024, 11:14 PMancient-application-36103
09/05/2024, 11:15 PMgreat-computer-6335
09/05/2024, 11:17 PMgreat-computer-6335
09/05/2024, 11:17 PMancient-application-36103
09/05/2024, 11:18 PMgreat-computer-6335
09/05/2024, 11:19 PMgreat-computer-6335
09/05/2024, 11:21 PMgreat-computer-6335
09/05/2024, 11:21 PMancient-application-36103
09/05/2024, 11:22 PMgreat-computer-6335
09/05/2024, 11:22 PMgreat-computer-6335
09/05/2024, 11:24 PMancient-application-36103
09/05/2024, 11:25 PM