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 'now' variable to Snowfakery #485

Merged
merged 7 commits into from
Feb 23, 2022
Merged

Add 'now' variable to Snowfakery #485

merged 7 commits into from
Feb 23, 2022

Conversation

prescod
Copy link
Contributor

@prescod prescod commented Sep 8, 2021

The now variable returns a datetime representing the current moment. It stores microsecond precision.

@prescod prescod requested a review from a team as a code owner September 8, 2021 20:38
boakley
boakley previously approved these changes Sep 13, 2021
Copy link

@boakley boakley left a comment

Choose a reason for hiding this comment

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

I left a couple of small comments, but I'm going to go ahead and approve because I don't think my questions are showstoppers.

b: ${{now}}
"""
generate(StringIO(yaml), {}, None)
assert datetime.fromisoformat(generated_rows.table_values("A", 0, "a"))
Copy link

Choose a reason for hiding this comment

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

This test seems a little imprecise -- it's verifying that now generates a date, but it doesn't verify that it sets the correct date. Would it be worth taking the time to mock out datetime.now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@boakley Fixed in 9329a0d

docs/index.md Outdated
#### `now`

The `now` variable returns a datetime
representing the current moment. Experimentally,
Copy link

Choose a reason for hiding this comment

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

Would it make sense to specifically mention that this returns the value of datetime.now()? I don't don't if the target audience is savvy enough to know what that means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think not, in general. I'll see what Peter says.

@prescod prescod added the doc review needed This PR should not be merged until "docs reviewed" label is added. label Feb 23, 2022
@prescod prescod requested a review from boakley February 23, 2022 07:56
@prescod
Copy link
Contributor Author

prescod commented Feb 23, 2022

I addressed David's suggestion that the date have a timezone in d657218. Since this PR was created, Snowfakery adopted a UTC-default policy.

@prescod prescod requested a review from pconrad-sfdo February 23, 2022 19:40
The `today` variable returns a date representing the current date. This date does not change chanage during the execution of a single recipe.
The `today` variable returns a date
representing the current date. This date
will not chanage during the execution of
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
will not chanage during the execution of
doesn't change during the execution of

current_datetime_without_microseconds: ${{int(now.timestamp())}}
```

This would generate field values similar to these:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This would generate field values similar to these:
The above example generates field values similar to these:

Copy link

@boakley boakley left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@prescod prescod merged commit 99dc642 into main Feb 23, 2022
@prescod prescod deleted the feature/now-function branch February 23, 2022 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc review needed This PR should not be merged until "docs reviewed" label is added. ready-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants