Last active
October 9, 2024 23:30
-
-
Save perrygeo/05b438430ab776786bdc85185360c327 to your computer and use it in GitHub Desktop.
Flyte example
This file contains 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 flytekit import ContainerTask, kwtypes, task, workflow | |
@task | |
def say_hello(name: str, area: float) -> str: | |
return f"Hey {name}! You have an ellipse of area {area}" | |
calculate_ellipse_area_python = ContainerTask( | |
command=[ | |
"python", | |
"calculate-ellipse-area.py", | |
"{{.inputs.a}}", | |
"{{.inputs.b}}", | |
"/var/outputs", | |
], | |
image="ghcr.io/flyteorg/rawcontainers-python:v2", | |
input_data_dir="/var/inputs", | |
inputs=kwtypes(a=float, b=float), | |
name="ellipse-area-metadata-python", | |
output_data_dir="/var/outputs", | |
outputs=kwtypes(area=float, metadata=str), | |
) | |
@workflow | |
def wf(name: str = "world", a: float = 1.0, b: float = 1.0) -> str: | |
""" | |
A test Flyte workflow demonstrating passing data between nodes. | |
""" | |
area, metadata = calculate_ellipse_area_python(a, b) | |
return say_hello(name, area) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<1 second locally, 2 minutes in the sandbox.
vs.