Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow entrypoint in a prefect.yaml to be a python module instead of a path #16998

Open
Ben-Epstein opened this issue Feb 5, 2025 · 1 comment
Labels
enhancement An improvement of an existing feature

Comments

@Ben-Epstein
Copy link

Describe the current behavior

Currently, entrypoint needs to be a path that is relative to the root of your github directory. At the same time, it needs to be relative to the CWD that you are running prefect deploy from, which leads to: you must always call prefect deploy from the root of your directory

This isn't always the best setup for repos (like multi-project repos), and it's also just a bit more confusing than it needs to be: relative-path routing is hard :D

Describe the proposed behavior

I'm proposing that entrypoint allow absolute module paths in python in addition to file paths, keyed internally in prefect by the presence of . in the value. If I have a repo like so

repo
|_ project
|_ _ Makefile
|_ _ pyproject.toml
|_ _ prefect.yaml
|_ _ flows
|_ _ _ my_flow.py

now, I can simply put
entrypoint: flows.my_flow.main instead of having to think about paths. This way, I can guarantee that what i want to be run is being run, and itll work from anywhere.

This can take inspiration from modal, which offers the same modal deploy src/project/app.py or modal deploy project.app both work, and for production i always use the latter.

Example Use

deployments:
- name: my-flow
  version:
  tags: []
  description: Run my flow at some cadence
  entrypoint: my_app.my_flow.main
  ....

Additional context

No response

@Ben-Epstein Ben-Epstein added the enhancement An improvement of an existing feature label Feb 5, 2025
@Ben-Epstein
Copy link
Author

Hm it seems like this might already be possible and just not documented? https://github.com/PrefectHQ/prefect/blob/main/src/prefect/flows.py#L2040C83-L2041C31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant