FFFF GitHub - flyteorg/flyte-sdk: Type-safe, distributed orchestration of agents, ML pipelines, and real-time inference — in pure Python with async/await. · GitHub
[go: up one dir, main page]

Skip to content

flyteorg/flyte-sdk

Repository files navigation

Flyte 2 SDK

Reliably orchestrate ML pipelines, models, and agents at scale — in pure Python.

Version Python License Try in Browser Docs SDK Reference CLI Reference

Install

pip install flyte

Example

import asyncio
import flyte

env = flyte.TaskEnvironment(
    name="hello_world",
    image=flyte.Image.from_debian_base(python_version=(3, 12)),
)

@env.task
def calculate(x: int) -> int:
    return x * 2 + 5

@env.task
async def main(numbers: list[int]) -> float:
    results = await asyncio.gather(*[
        calculate.aio(num) for num in numbers
    ])
    return sum(results) / len(results)

if __name__ == "__main__":
    flyte.init()
    run = flyte.run(main, numbers=list(range(10)))
    print(f"Result: {run.result}")
PythonFlyte CLI
python hello.py
flyte run hello.py main --numbers '[1,2,3]'

Serve a Model

# serving.py
from fastapi import FastAPI
import flyte
from flyte.app.extras import FastAPIAppEnvironment

app = FastAPI()
env = FastAPIAppEnvironment(
    name="my-model",
    app=app,
    image=flyte.Image.from_debian_base(python_version=(3, 12)).with_pip_packages(
        "fastapi", "uvicorn"
    ),
)

@app.get("/predict")
async def predict(x: float) -> dict:
    return {"result": x * 2 + 5}

if __name__ == "__main__":
    flyte.init_from_config()
    flyte.serve(env)
PythonFlyte CLI
python serving.py
flyte serve serving.py env

Local Development Experience

Install the TUI for a rich local development experience:

pip install flyte[tui]

Watch the local development experience

Learn More

License

Apache 2.0 — see LICENSE.

About

Type-safe, distributed orchestration of agents, ML pipelines, and real-time inference — in pure Python with async/await.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

0