Skip to content

feat: Create deephaven.time time-type aliases#5269

Merged
devinrsmith merged 7 commits intodeephaven:mainfrom
devinrsmith:deephaven-time-aliases
Aug 28, 2024
Merged

feat: Create deephaven.time time-type aliases#5269
devinrsmith merged 7 commits intodeephaven:mainfrom
devinrsmith:deephaven-time-aliases

Conversation

@devinrsmith
Copy link
Copy Markdown
Member

@devinrsmith devinrsmith commented Mar 20, 2024

This adds TimeZoneLike, LocalDateLike, InstantLike, ZonedDateTimeLike, DurationLike, and PeriodLike as aliased union types for objects that can be coerced into said type. This makes it easier for public APIs to reference the proper time-types. S3Instructions, json.instant_val, TableReplayer, time_table, and the time.to_j_ APIs have been updated to reference the new types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

High level questions:

  1. Does PyCharm correctly type hint with this?
  2. Does VS Code correctly type hint with this?
  3. What do the Sphinx docs look like?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added simple pydocs to see what it looks like. I don't use PyCharm, so somebody else would need to check that.

sphinx-docs

sphinx-reference

vscode-hint

Comment thread py/server/deephaven/time.py Outdated
Comment on lines +31 to +37
TimeZoneAlias = Union[TimeZone, str, datetime.tzinfo, datetime.datetime, pandas.Timestamp]
LocalDateAlias = Union[LocalDate, str, datetime.date, datetime.datetime, numpy.datetime64, pandas.Timestamp]
LocalTimeAlias = Union[LocalTime, int, str, datetime.time, datetime.datetime, numpy.datetime64, pandas.Timestamp]
InstantAlias = Union[Instant, int, str, datetime.datetime, numpy.datetime64, pandas.Timestamp]
ZonedDateTimeAlias = Union[ZonedDateTime, str, datetime.datetime, numpy.datetime64, pandas.Timestamp]
DurationAlias = Union[Duration, int, str, datetime.timedelta, numpy.timedelta64, pandas.Timedelta]
PeriodAlias = Union[Period, str, datetime.timedelta, numpy.timedelta64, pandas.Timedelta]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. These need pydocs for sphinx.
  2. I'm concerned that "Alias" might be confusing to users. Maybe "Union" or something else.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To me, Alias is appropriate except for int, str. The same is for Type, Kind. I don't like Union that much either. I don't have a good suggestion and if I am forced to choose, I would pick one of 'Alias', 'Type', and 'Kind'.

@devinrsmith devinrsmith requested a review from chipkent August 19, 2024 15:33
@devinrsmith devinrsmith changed the title Create deephaven.time time-type aliases feat: Create deephaven.time time-type aliases Aug 19, 2024
Comment thread py/server/deephaven/table_factory.py Outdated
period = time.to_j_duration(period)

builder.period(period)
if period:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirming that an exception will be thrown if period is None. An early impl had a fixed value, which was not good. I think this fixed value was removed everywhere, but I'm not 100%.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call; there was an error thrown, but it wasn't as obvious in the java layer. I've explicitly accounted for this now and added a test case.

chipkent
chipkent previously approved these changes Aug 26, 2024
@devinrsmith devinrsmith merged commit ed3a523 into deephaven:main Aug 28, 2024
@devinrsmith devinrsmith deleted the deephaven-time-aliases branch August 28, 2024 21:01
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants