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

Feat: accept cron schedule for analyzers #56

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

murilommen
Copy link
Collaborator

Previously we had left out the ability to define an Analyzer.schedule = CronSchedule. This PR adds that as a feature and also includes two guardrails for the cron string:

  • it must respect 5 slots (and not 6+)
  • it must be greater than or equal to 1hour
    I've used the re.match to capture invalid strings and also a unit test with a few different examples

@murilommen murilommen self-assigned this Mar 28, 2024
@murilommen murilommen force-pushed the dev/murilommen/feat-add-cron-schedule branch from 9dc48a3 to 2529259 Compare March 28, 2024 16:44
@murilommen murilommen temporarily deployed to whylabs-toolkit-ci March 28, 2024 16:46 — with GitHub Actions Inactive
@murilommen murilommen temporarily deployed to whylabs-toolkit-ci April 1, 2024 16:48 — with GitHub Actions Inactive
def _is_not_less_granular_than_1_hour(split_cron: SplitCron) -> bool:
"""Check if the cron expression is less granular than 1 hour."""
# Specific days checks
if split_cron.minute != "*" and split_cron.minute != "0":
Copy link
Collaborator

@christinedraper christinedraper Apr 1, 2024

Choose a reason for hiding this comment

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

I dont get why it needs to check that its not 0 (and ditto for the other fields). Seems like this check should fail if the minute is '*' or anything with a - or , in it. Anything else would be ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

true. it really doesn't make sense to check for the "top of the {time}"

if split_cron.day_of_week != "*" and split_cron.day_of_week != "1":
return True

# Check range
Copy link
Collaborator

Choose a reason for hiding this comment

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

all that happens from here on is that it iterates and then returns False... logic seems wrong. Also seems disconnected from "is granularity less than hour", seems like it is meant to be checking any range fields

@murilommen murilommen had a problem deploying to whylabs-toolkit-ci April 2, 2024 18:16 — with GitHub Actions Failure
@murilommen
Copy link
Collaborator Author

@christinedraper added a few changes that addresses these comments, see if they're enough to resolve the conversations 🙏🏽 and thanks for catching these

details:
- include every N {field} on base regex on CronSchedule
- get rid of "strictly 0 {field}" cases, which didn't make sense
- fix order of SplitCron implementation
- checks for "," and "-" cases only on the minute field
- added tests
@murilommen murilommen force-pushed the dev/murilommen/feat-add-cron-schedule branch from 5576732 to 2ff300d Compare April 2, 2024 18:17
@murilommen murilommen temporarily deployed to whylabs-toolkit-ci April 2, 2024 18:17 — with GitHub Actions Inactive
Copy link
Collaborator

@christinedraper christinedraper left a comment

Choose a reason for hiding this comment

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

Is CRON_REGEX still used? I didnt try to validate it

@murilommen murilommen merged commit 16a79c8 into mainline Apr 2, 2024
1 check passed
@murilommen murilommen deleted the dev/murilommen/feat-add-cron-schedule branch April 2, 2024 21:02
@murilommen
Copy link
Collaborator Author

Is CRON_REGEX still used? I didnt try to validate it

It is used when creating CronSchedule and pydantic applies it

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.

2 participants