Created
February 22, 2020 17:11
-
-
Save dpoulopoulos/0a98d063be71a2b7b6d3d8dc6938764e to your computer and use it in GitHub Desktop.
Linear metaflow transition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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