This repository was archived by the owner on Aug 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
deploy example and fix typing #382
Open
zzstoatzz
wants to merge
9
commits into
main
Choose a base branch
from
example-deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or 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
examples/deploy.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'something' here should probably be 'write_poems'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, an example that deploys it by pulling an image, would solve all of my problems.
Collaborator
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch @alkiviadis-savvopoulos!
fixed that and also added a docker example
better example updates fix kwargs
3a5b81d to
6aa3b39
Compare
6aa3b39 to
ce25892
Compare
zzstoatzz
commented
Jan 13, 2025
Comment on lines
+53
to
+98
| if __name__ == "__main__": | ||
| EVERY_12_HOURS_CRON = "0 */12 * * *" | ||
| if len(sys.argv) > 1 and sys.argv[1] == "serve": | ||
| analyze_hn_articles.serve( | ||
| parameters={"n": 5}, | ||
| cron=EVERY_12_HOURS_CRON, | ||
| ) | ||
| elif len(sys.argv) > 1 and sys.argv[1] == "local_deploy": | ||
| analyze_hn_articles.from_source( | ||
| source=str((p := Path(__file__)).parent.resolve()), | ||
| entrypoint=f"{p.name}:analyze_hn_articles", | ||
| ).deploy( | ||
| name="local-deployment", | ||
| work_pool_name="local", | ||
| cron=EVERY_12_HOURS_CRON, | ||
| ) | ||
| elif len(sys.argv) > 1 and sys.argv[1] == "docker_deploy": | ||
| repo = GitRepository( | ||
| url="https://github.com/PrefectHQ/controlflow.git", | ||
| branch="main", | ||
| credentials=None, # replace with `dict(username="", access_token="")` for private repos | ||
| ) | ||
| analyze_hn_articles.from_source( | ||
| source=repo, | ||
| entrypoint="examples/read_hn.py:analyze_articles", | ||
| ).deploy( | ||
| name="docker-deployment", | ||
| # image=DockerImage( # uncomment and replace with your own image if desired | ||
| # name="zzstoatzz/cf-read-hn", | ||
| # tag="latest", | ||
| # dockerfile=str(Path(__file__).parent.resolve() / "read-hn.Dockerfile"), | ||
| # ), | ||
| work_pool_name="docker-work", # uv pip install -U prefect-docker prefect worker start --pool docker-work --type docker | ||
| cron=EVERY_12_HOURS_CRON, | ||
| parameters={"n": 5}, | ||
| job_variables={ | ||
| "env": {"OPENAI_API_KEY": os.getenv("OPENAI_API_KEY")}, | ||
| "image": "zzstoatzz/cf-read-hn:latest", # publicly available image on dockerhub | ||
| }, | ||
| build=False, | ||
| push=False, | ||
| ) | ||
| else: | ||
| print(f"just running the code\n\n\n\n\n\n") | ||
| briefs = analyze_hn_articles(5) # type: ignore | ||
| TypeAdapter(list[HNArticleSummary]).validate_python(briefs) |
Collaborator
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cf flows and tasks are in fact valid prefect flows and tasks, and so this example shows how to deploy / map flows / tasks
also fixes up some typing so methods like
serveanddeployare known to the IDE