Krystian
03/18/2025, 7:48 AMMarvin
03/18/2025, 7:48 AMpython
from prefect import flow
@flow
def my_flow():
print("Hello, Prefect!")
2. Deploy Your Flow: Use flow.deploy()
to specify how the flow should be deployed. This involves setting up deployment configurations, such as the work pool and Docker image details. Here's a basic example:
python
from prefect import flow
@flow
def my_flow():
print("Hello, Prefect!")
if __name__ == "__main__":
my_flow.deploy(name="my-flow-deployment", work_pool_name="default")
3. Run Your Script: Execute the script to deploy the flow. This will build a Docker image containing your flow code and create a deployment associated with the specified work pool.
4. Execution: You can then start a worker to execute scheduled runs, pulling the flow code from your Python file.
For more information, you can refer to the Prefect documentation on deploying via Python.
Additionally, Prefect's top-level API includes functions like flow.deploy
and flow.serve
that facilitate these operations. If you're interested in exploring more about the API, you can visit the Prefect API documentation.Krystian
03/18/2025, 9:01 AMMarvin
03/18/2025, 9:02 AM~/.prefect/prefect.db
.
- Data Tracked: The database stores data related to flow run and task run states, run history, logs, deployments, concurrency limits, storage blocks for flow and task results, variables, artifacts, and work pool status.
- PostgreSQL Option: For more robust, external database needs, Prefect supports PostgreSQL. Setting up PostgreSQL requires additional configuration, such as using Docker, and the pg_trgm
extension must be installed and enabled.
For more detailed information, you can refer to the Prefect self-host documentation.