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

add prefect.yaml and cli support for new schedule fields #13318

Merged
merged 14 commits into from
May 14, 2024

Conversation

zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented May 13, 2024

this PR:

  • adds a setting PREFECT_EXPERIMENTAL_ENABLE_SCHEDULE_CONCURRENCY to gate CLI prompts for new fields while the worker does not actually enforce these limits
  • adds prompts to prefect deploy to choose a value for max_active_runs and catchup for each schedule
  • adds support for configuring and saving these fields for schedule definitions in prefect.yaml

@zzstoatzz zzstoatzz marked this pull request as ready for review May 13, 2024 17:43
@zzstoatzz zzstoatzz requested review from zangell44 and a team as code owners May 13, 2024 17:43
@zzstoatzz zzstoatzz marked this pull request as draft May 13, 2024 17:44
Copy link

netlify bot commented May 13, 2024

Deploy Preview for prefect-docs-preview ready!

Name Link
🔨 Latest commit 13643f0
🔍 Latest deploy log https://app.netlify.com/sites/prefect-docs-preview/deploys/66437c36ef5b9600086361ee
😎 Deploy Preview https://deploy-preview-13318--prefect-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@zzstoatzz zzstoatzz marked this pull request as ready for review May 13, 2024 22:41
Copy link
Contributor

@bunchesofdonald bunchesofdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a few minor nits, but looks great overall!

command=(
f"deploy ./flows/hello.py:my_flow -n test-name --pool {work_pool.name}"
),
user_input=(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't block this PR on this, but a couple weeks ago I added a more semantic way of dealing with this in tests called prompts_and_responses, you can see an example over here: https://github.com/PrefectHQ/prefect/blob/main/tests/cli/test_deploy.py#L4130C13-L4140

default=None,
)
catchup = confirm(
"Catch up on missed runs?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include the fact that we're talking about 'late' runs here?

Suggested change
"Catch up on missed runs?",
"Catch up on late flow runs?",

@@ -238,6 +242,21 @@ def process_response(self, value: str) -> str:
raise InvalidResponse(self.validate_error_message)


def prompt_for_max_active_runs_and_catchup(console):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd split this into two prompts, one for max active and one for catchup.

@@ -376,7 +405,7 @@ def prompt_schedules(console) -> List[MinimalDeploymentSchedule]:
async def prompt_select_work_pool(
console: Console,
prompt: str = "Which work pool would you like to deploy this flow to?",
client: PrefectClient = None,
client: Optional[PrefectClient] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing to not block this PR on, but I added a client_injector that makes the typing on this kind of stuff better:

def client_injector(
func: Callable[Concatenate["PrefectClient", P], Awaitable[R]],
) -> Callable[P, Awaitable[R]]:
@wraps(func)
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
client, _ = get_or_create_client()
return await func(client, *args, **kwargs)
return wrapper

It's used the same way as inject_client except that it always expects the client will be the first argument and non-optional:

@sync_compatible
@client_injector
async def create_flow_run_input(
client: "PrefectClient",

version: str = None,
schedule: SCHEDULE_TYPES = None,
schedules: List[DeploymentScheduleCreate] = None,
version: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Copy link
Collaborator

@abrookins abrookins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed I would split up the prompts, but I have no blocking comments. Looks good!

@zzstoatzz zzstoatzz merged commit 20792ec into main May 14, 2024
54 of 59 checks passed
@zzstoatzz zzstoatzz deleted the new-schedule-fields-yaml-and-cli-support branch May 14, 2024 15:14
serinamarie pushed a commit to bsignoret/prefect that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants