Implement Your Workflows in Python

Note

We recommend using an OSX or a Linux machine, as we have not tested this on Windows. If you happen to test it, please let us know.

Prerequisites

Make sure you have Git, and Python >= 3.7 installed. Also ensure you have pip3 (mostly the case).

Start a new project / repository

Install Flyte’s Python SDK — Flytekit (recommended using a virtual environment), run pyflyte init {project_name}, where {project_name} is the directory that will be created containing the scaffolding for a flyte-ready project. Feel free to use any name as your project name, however for this guide we’re going to use myflyteapp in the invocation:

pip3 install flytekit --upgrade
pyflyte init myflyteapp
cd myflyteapp

The myflyteapp directory comes with a sample workflow, which can be found under flyte/workflows/example.py. The structure below shows the most important files and how a typical Flyte app should be laid out.

Run the Workflow Locally

The workflow can be run locally, simply by running it as a Python script; note the __main__ entry point at the bottom of flyte/workflows/example.py.

python flyte/workflows/example.py

Expected output:

Running my_wf() hello world

Recap

🎉 Congratulations! You just ran your first Flyte workflow locally, let’s take it to the cloud!