-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds example of deploying from a GitHub repo
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
# Deploy a flow from a git repository | ||
This example shows how to deploy a flow from a git repository. | ||
It assumes you have a work pool named `process`. You can implicitly create the | ||
work pool by starting a worker: | ||
```bash | ||
prefect worker start --pool process --type process | ||
``` | ||
""" | ||
|
||
from prefect import flow | ||
from prefect.runner.storage import GitRepository | ||
from prefect.blocks.system import Secret | ||
from prefect.client.schemas.schedules import CronSchedule | ||
|
||
|
||
def deploy(): | ||
# flow.from_source will actually clone the repository to load the flow | ||
flow.from_source( | ||
# Here we are using GitHub but it works for GitLab, Bitbucket, etc. | ||
source=GitRepository( | ||
url="https://github.com/PrefectHQ/examples.git", | ||
credentials={ | ||
# We are assuming you have a Secret block named `github-access-token` | ||
# that contains your GitHub personal access token | ||
"access_token": Secret.load("github-access-token"), | ||
}, | ||
), | ||
entrypoint="flows/hello-world.py:hello", | ||
).deploy( | ||
name="source-github", | ||
schedules=[ | ||
# Run the flow every hour on the hour | ||
CronSchedule(cron="0 * * * *"), | ||
], | ||
work_pool_name="process", | ||
# Define a different default parameter for this deployment | ||
parameters={ | ||
"name": "Arthur", | ||
}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
deploy() |