Skip to content

Instantly share code, notes, and snippets.

@dpoulopoulos
Created February 22, 2020 17:11
Show Gist options
  • Select an option

  • Save dpoulopoulos/0a98d063be71a2b7b6d3d8dc6938764e to your computer and use it in GitHub Desktop.

Select an option

Save dpoulopoulos/0a98d063be71a2b7b6d3d8dc6938764e to your computer and use it in GitHub Desktop.
Linear metaflow transition.
import numpy as np
from metaflow import FlowSpec, step
class CalculateMean(FlowSpec):
@step
def start(self):
"""
Initializes a random dataset.
"""
np.random.seed(0)
self.data = np.random.rand(100)
self.next(self.mean)
@step
def mean(self):
"""
Calculates the mean.
"""
self.avg = np.mean(self.data)
self.next(self.end)
@step
def end(self):
"""
Prints the results and terminates the run.
"""
print(f'Mean = {self.avg}')
if __name__ == '__main__':
CalculateMean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment