Paige Fuller
03/26/2024, 4:56 PMNate
03/26/2024, 5:01 PMfrom_source
if you already have the flow object handyPaige Fuller
03/26/2024, 5:03 PMPaige Fuller
03/26/2024, 5:06 PMname: Deploy to Prefect Server
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install prefect
- name: Deploy to Prefect Server
run: |
# Set up Prefect environment variables
export PREFECT__SERVER__API="${{ secrets.PREFECT_API_URL }}"
python paige-test.py
Nate
03/26/2024, 5:08 PMNate
03/26/2024, 5:11 PMPaige Fuller
03/26/2024, 5:12 PMPaige Fuller
03/26/2024, 5:13 PMNate
03/26/2024, 5:22 PMfrom_source
) - I would stick with from_source
and just point it at github like your original example, this will:
⦠allow you to write some GHA like you did above (just set PREFECT_API_URL
there and you should be good!)
⦠from_source
will make it so that the eventual Deployment
you register with the server has the information about where the flow code lives when the worker picks up a flow run from that deployment
if you're trying this
@flow
async def my_flow(name: str = "world"):
print(f"Hello {name}!")
if __name__ == "__main__":
flow.from_source(
...
).deploy(...)
like above and its not working for you, what's the error look like that you're getting?Nate
03/26/2024, 5:23 PMprefect --no-prompt deploy --all
in CI like in this repo I'm linking, but lots of folks use .deploy()
like it sounds like you all prefer šPaige Fuller
03/26/2024, 5:25 PMNate
03/26/2024, 5:29 PMPointing to the github repo from source works fine when its at the same repo in which its running?yes it does! because all you're doing at the moment you call
.deploy()
is telling your prefect server that "hey, this Deployment I'm giving you lives at
⢠source=<https://github.com/company/my-repo.git>
⢠entrpoint=path/to/my/flow/relative/to/repo/root.py:my_flow_function
so when its time to run, that's where you should go pull
it from!" (behind the scenes, we translate that from_source
bit into a pull
step for your worker that instructs it on how to retrieve your flow code at runtime)Nate
03/26/2024, 5:30 PMentrypoint="/builtin_worklflows/paige-test.py:my_flow"
also just noticing that your
entrypoint
looks a little goofy, just because of that leading forward slash
entrypoint should be relative to repo rootPaige Fuller
03/26/2024, 5:31 PMNate
03/26/2024, 5:31 PMPaige Fuller
03/26/2024, 6:11 PM