Environment Setup#
Prerequisites#
Repo Setup#
Clone the flytesnacks
repo and install its dependencies, which includes flytekit :
Tip
[Recommended] Create a new python virtual environment to make sure it doesn’t interfere with your
development environment, e.g. with python -m venv <path/to/env>
.
git clone https://github.com/flyteorg/flytesnacks
cd flytesnacks/cookbook
pip install -r core/requirements.txt
To make sure everything is working in your virtual environment, run hello_world.py
locally:
python core/flyte_basics/hello_world.py
Expected output:
Running my_wf() hello world
Create a Local Demo Flyte Cluster#
Use flytectl
to start a demo Flyte cluster:
flytectl demo start
Running Workflows#
Now you can run all of the example workflows locally using the default Docker image bundled with flytekit
:
pyflyte run core/flyte_basics/hello_world.py my_wf
Note
The first couple arguments of pyflyte run
is in the form of path/to/script.py <workflow_name>
, where
<workflow_name>
is the function decorated with @workflow
that you want to run.
To run the workflow on the demo Flyte cluster, all you need to do is supply the --remote
flag:
pyflyte run --remote core/flyte_basics/hello_world.py my_wf
You should see an output that looks like:
Go to https://<flyte_admin_url>/console/projects/flytesnacks/domains/development/executions/<execution_name> to see execution in the console.
You can visit this url to inspect the execution as it runs:

Finally, let’s run a workflow that takes some inputs, for example the basic_workflow.py
example:
pyflyte run --remote core/flyte_basics/basic_workflow.py my_wf --a 5 --b hello
Note
We’re passing in the workflow inputs as additional options to pyflyte run
, in the above example the
inputs are --a 5
and --b hello
. For snake-case argument names like arg_name
, you can provide the
option as --arg-name
.
Visualizing Workflows#
Workflows can be visualized as DAGs on the UI. However, you can visualize workflows on the browser and in the terminal by just using your terminal.
To view workflow on the browser:
flytectl get workflows --project flytesnacks --domain development flyte.workflows.example.my_wf --version <version> -o doturl
To view workflow as a strict digraph
on the command line:
flytectl get workflows --project flytesnacks --domain development flyte.workflows.example.my_wf --version <version> -o dot
Replace <version>
with version from console UI, it may look something like BLrGKJaYsW2ME1PaoirK1g==
Tip
Running most of the examples in the User Guide only requires the default Docker image that ships with Flyte.
Many examples in the Tutorials and Integrations section depend on additional libraries, sklearn
,
pytorch
, or tensorflow
, which will not work with the default docker image used by pyflyte run
.
These examples will explicitly show you which images to use for running these examples by passing in the docker
image you want to use with the --image
option in pyflyte run
.
🎉 Congrats! Now you can run all the examples in the User Guide 🎉
What’s Next?#
Try out the examples in Flyte Basics section.