This release is a pre-release and may not be stable for production use.
Flyte v2 SDK
The next-generation SDK for Flyte.
Quick start
- Run
uv venv, andsource .venv/bin/activateto create a new virtual environment. - Install the latest version of the SDK by running the following:
uv pip install --no-cache --prerelease=allow --upgrade flyte
- Create the config and point it to your cluster by running the following:
flyte create config --endpoint <your-endpoint-url> --project <your-project> --domain <your-domain>
This will create a config.yaml file in the current directory which will be referenced ahead of any other config.yamls found in your system.
- Now you can run code with the CLI:
flyte run <path-to-your-script> <task-name>
Hello World Example
# hello_world.py
import flyte
env = flyte.TaskEnvironment(name="hello_world")
@env.task
async def say_hello(data: str) -> str:
return f"Hello {data}"
@env.task
async def say_hello_nested(data: str) -> str:
return await say_hello.override(resources=flyte.Resources(gpu="A100 80G:4")).execute(data)
if __name__ == "__main__":
import asyncio
# to run pure python - the SDK is not invoked at all
asyncio.run(say_hello_nested("test"))
# To run locally, but run through type system etc
flyte.init()
flyte.run(say_hello_nested, "World")
# To run remote
flyte.init(endpoint="dns:///localhost:8090", insecure=True)
flyte.run(say_hello_nested, "World")
# It is possible to switch local and remote, but keeping init to have and endpoint, but , changing context during run
flyte.with_runcontext(mode="local").run(...) # this will run locally only
# To run remote with a config
flyte.init_from_config("config.yaml")
CLI
All commands can be run from any root directory.
For examples, it is not needed to have __init__.py in the directory.
If you run from a directory, the code will automatically package and upload all modules that are imported.
You can change the behavior by using --copy-style flag.
flyte run hello_world.py say_hello --data "World"
To follow the logs for the a0 action, you can use the --follow flag:
flyte run --follow hello_world.py say_hello --data "World"
Note that --follow has to be used with the run command.
Change copy style:
flyte run --copy-style all hello_world.py say_hello_nested --data "World"
Building Images
import flyte
env = flyte.TaskEnvironment(
name="hello_world",
image=flyte.Image.auto().with_apt_packages(...).with_pip_packages(...),
)
Deploying
flyte deploy hello_world.py say_hello_nested
Get information
Get all runs:
flyte get run
Get a specific run:
flyte get run "run-name"
Get all actions for a run:
flyte get actions "run-name"
Get a specific action for a run:
flyte get action "run-name" "action-name"
Get action logs:
flyte get logs "run-name" ["action-name"]
This defaults to root action if no action name is provided
Running workflows programmatically in Python
You can run any workflow programmatically within the script module using main:
if __name__ == "__main__":
import flyte
flyte.init()
flyte.run(say_hello_nested, "World")
Running scripts with dependencies specified in metadata headers
You can also run a uv script with dependencies specified in metadata headers
and build the task image automatically based on those dependencies:
# container_images.py
# /// script
# dependencies = [
# "polars",
# "flyte>=0.2.0b12"
# ]
# ///
import polars as pl
import flyte
env = flyte.TaskEnvironment(
name="polars_image",
image=flyte.Image.from_uv_script(
__file__,
name="flyte",
registry="ghcr.io/<you-username>"
arch=("linux/amd64", "linux/arm64"),
).with_apt_packages("ca-certificates"),
)
@env.task
async def create_dataframe() -> pl.DataFrame:
return pl.DataFrame(
{"name": ["Alice", "Bob", "Charlie"], "age": [25, 32, 37], "city": ["New York", "Paris", "Berlin"]}
)
@env.task
async def print_dataframe(dataframe: pl.DataFrame):
print(dataframe)
@env.task
async def workflow():
df = await create_dataframe()
await print_dataframe(df)
if __name__ == "__main__":
flyte.init_from_config("config.yaml")
run = flyte.run(workflow)
print(run.name)
print(run.url)
run.wait(run)
When you execute
uv run hello_world.py
uv will automatically update the local virtual environment with the dependencies specified in the metadata headers.
Then, Flyte will build the task image using those dependencies and push it to the registry you specify.
Flyte will then deploy the tasks to the cluster where the system will pull the image and run the tasks using it.
Metadata
Release files for flyte 0.2.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flyte-0.2.0a0-py3-none-any.whl | Python 3 | none | any | Details for flyte-0.2.0a0-py3-none-any.whl |
Release files / flyte-0.2.0a0-py3-none-any.whl
| Download URL | flyte-0.2.0a0-py3-none-any.whl |
|---|---|
| Size | 356.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b8c0baded42caff1bd0aa278913f7766b46bfe4865008e23a48fd6702755cd9
|
|
BLAKE2b-256 checksum How to use checksums |
c14e6a467655046672ab22abc7cb81d209556bff5394d8608e892addb3994683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Security for flyte 0.2.0a0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.