-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
9dc48a3
to
2529259
Compare
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": |
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.
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.
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.
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 |
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.
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
@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
5576732
to
2ff300d
Compare
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.
Is CRON_REGEX still used? I didnt try to validate it
It is used when creating CronSchedule and pydantic applies it |
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:I've used the
re.match
to capture invalid strings and also a unit test with a few different examples