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

Create single-shot Prefect Agent #106

Closed
jacksund opened this issue Mar 10, 2022 · 2 comments
Closed

Create single-shot Prefect Agent #106

jacksund opened this issue Mar 10, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jacksund
Copy link
Owner

jacksund commented Mar 10, 2022

Similar to how a Fireworks worker will grab a single workflow, submit it, and then shutdown once the workflow completes, we'd also like to replicate this with a LocalAgent in prefect.

Currently, I think the best way to do this is by overwriting LocalAgent's _get_ready_flow_runs method and changing the following line:

# original line
flow_run_ids = set(result.data.get_runs_in_queue.flow_run_ids) 

# new code that reduces this query to a single flow run
flow_run_ids = set(result.data.get_runs_in_queue.flow_run_ids)
flow_run_ids = set([flow_run_ids.pop()]) if flow_run_ids else flow_run_ids  # new line

We'd then run LocalAgent with max_polls=1. This Agent will also automatically shut down without running anything if no flow runs are available.

@jacksund jacksund added the enhancement New feature or request label Mar 11, 2022
@jacksund
Copy link
Owner Author

jacksund commented Mar 11, 2022

Rather than hacking this method, I'm also proposing more useful changes to Prefect's api here

Ideally, I'd be able to use an agent like so:

from prefect.agent.local import LocalAgent

LocalAgent(max_polls=1, max_runs_per_poll=1) 

When starting this agent, it would submit 1 flow run and then shutdown upon that flow's completion.

@jacksund
Copy link
Owner Author

jacksund commented Aug 9, 2022

added in #190

@jacksund jacksund closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant