Created
December 8, 2022 16:17
-
-
Save zanieb/61facb93fa4e0cfe7e6fc45997b1f4ae to your computer and use it in GitHub Desktop.
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
| from prefect import Flow, task, Parameter | |
| @task | |
| def foo(): | |
| print("foo") | |
| @task | |
| def bar(): | |
| print("bar") | |
| @task | |
| def plusone(x): | |
| return x + 1 | |
| def foobar(): | |
| foo() | |
| bar() | |
| def do_some_math(start_at): | |
| # Parameters can be passed to tasks | |
| result = plusone(start_at) | |
| # Logic cannot be performed unless in a task e.g. | |
| # if result > 2: ... not allowed | |
| return result | |
| with Flow("example") as flow: | |
| start_at = Parameter("start_at", default=0) | |
| foobar() | |
| math_result = do_some_math(start_at) | |
| # Tasks can be called directly in the flow still | |
| plusone(math_result) | |
| flow.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment