Creating a Flyte project¶
About Flyte projects¶
A Flyte project is a directory containing task and workflow code, internal Python source code, configuration files, and other artifacts needed to package up your code so that it can be registered to a Flyte cluster.
Prerequisites¶
Follow the steps in “Installing development tools”
(Optional, but recommended) Install git
Steps¶
1. Activate your Python virtual environment¶
If you are using conda or another Python virtual environment manager, first, activate the virtual environment you will use to manage dependencies for your Flyte project:
conda activate flyte-example
2. Initialize your Flyte project¶
Next, initialize your Flyte project. The flytekit-python-template GitHub repository contains Flyte project templates with sample code that you can run as is or modify to suit your needs.
In this example, we will initialize the basic-template-imagespec project template.
pyflyte init my_project
Note
If you need to use a Dockerfile for your project, you can initialize the Dockerfile template:
pyflyte init --template basic-template-dockerfile my_project
3. Install additional requirements¶
After initializing your Flyte project, you will need to install requirements listed in requirements.txt
:
cd my_project
pip install -r requirements.txt
4. (Optional) Version your Flyte project with git¶
We highly recommend putting your Flyte project code under version control. To do so, initialize a git repository in the Flyte project directory:
git init
Note
If you are using a Dockerfile instead of ImageSpec, you will need to initialize a git repository and create at least one commit, since the commit hash is used to tag the image when it is built.
5. Run your workflow in a local Python environment¶
To check that your Flyte project was set up correctly, run the workflow in a local Python environment:
cd workflows
pyflyte run example.py wf
Next steps¶
To learn about the parts of a Flyte project, including tasks and workflows, see “Flyte project components”.
To run the workflow in your Flyte project in a local Flyte cluster, see the “Running a workflow in a local cluster” section of “Running a workflow locally”.