Search documentation

Type to search the documentation.

Docs/Examples/Run a remote Task

Python example

Run a remote Task

Declare a task, invoke it remotely, and print its result.

Before you run#

Use an installed, authenticated Yak CLI with access to the invite-only preview. Read Quickstart for the full setup and current behavior.

Source code#

Download hello_task.py

Canonical examplehello_task.py
hello_task.py
import asyncio
import yak

app = yak.App(name="hello-task", image="python:3.11")


@app.task()
def square(value: int) -> int:
    return value * value


@app.entrypoint()
async def main() -> None:
    result = await square.remote.aio(21)
    print(f"square(21) = {result}")


if __name__ == "__main__":
    asyncio.run(main())

Run the example#

Save the source as hello_task.py, then run:

Commandhello_task.py
hello_task.py ready
$ yak run hello_task.py