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
Cleanup deployment-start-time feature branch, add tests #7928
Cleanup deployment-start-time feature branch, add tests #7928
Conversation
requirements.txt
Outdated
@@ -9,7 +9,7 @@ cloudpickle >= 2.0 | |||
coolname >= 1.0.4 | |||
croniter >= 1.0.12 | |||
cryptography >= 36.0.1 | |||
dateparser >= 1.0 | |||
dateparser >= 1.1.2 |
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.
Why do we need the higher version?
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.
These tests were failing: https://github.com/PrefectHQ/prefect/actions/runs/3752658214/jobs/6375066682#step:12:236
I determined the cause to be: scrapinghub/dateparser#1045 and the solution was implemented here: scrapinghub/dateparser#1046.
elif start_in is None and start_at is None: | ||
scheduled_start_time = now | ||
human_dt_diff = " (now)" | ||
else: | ||
if start_in: | ||
start_time_raw = "in " + start_in | ||
else: | ||
start_time_raw = "at " + start_at |
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.
Since the above exits if both are set you can just do
if start_in: ...
elif start_at: ...
else: ...
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.
Do you mean else:
being where start_in
is None and start_as
in None? Because there is some logic beneath that specific to start_in
/start_at
for assigning start_time_parsed
, scheduled_start_time
, and human_dt_diff
.
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.
Yeah I think you can do else
instead of elif start_in is None and start_at is None:
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'm curious too what this would look like without having a helper function for the raw parsing logic.
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 think the helper function is a bit harder to read than the initial implementation, especially since it does more than one thing (parses the date time and generates a formatted diff). I don't have strong feelings here though.
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.
(unresolving for visibility; does not mean it needs to be addressed)
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.
A couple minor ux nits (not strong feelings) but otherwise lgtm!
Co-authored-by: Michael Adkins <michael@prefect.io>
Co-authored-by: Michael Adkins <michael@prefect.io>
Continuation of #7772
Notes
dateparser.parse
has a defaultPREFER_DATES_FROM
setting ofcurrent_period
. This means that when parsing a date, it will go backwards in time if that's closer than a future time, e.g. if it is currently 5pm, thendateparser.parse("1pm")
will retrieve a date from earlier today (in the past) because this 1pm is closer than tomorrow at 1pm.By changing the
PREFER_DATES_FROM
setting tofuture
like in this PR, when parsing a date, it will always go forward in time regardless of closeness, e.g. if it is currently 5pm, thendateparser.parse("1pm")
will retrieve the next future instance of 1pm, meaning tomorrow at 1pm even though today at 1pm is closer in proximity.We reasoned that most of the time, users want to run deployments at a future date, so we should consistently parse for a future date, rather than inconsistently provide a past date or future date based on proximity.
If needed someday, we could add a setting to enable other behavior.
Example
Checklist
<link to issue>
"fix
,feature
,enhancement