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

fix: minimum time resolution #557

Merged
merged 2 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/phoenix/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,21 @@ def start_time(self) -> datetime:
"""Returns the datetime of the earliest inference in the dataset"""
timestamp_col_name: str = cast(str, self.schema.timestamp_column_name)
start_datetime: datetime = self.__dataframe[timestamp_col_name].min()
return start_datetime
return start_datetime.replace(second=0, microsecond=0)

@cached_property
def end_time(self) -> datetime:
"""
Returns the datetime of the latest inference in the dataset.
end_datetime equals max(timestamp) + 1 microsecond, so that it can be
used as part of a right-open interval.
end_datetime equals max(timestamp) + 1 minute, so that it can be
used as part of a right-open interval. Note that one minute is the
smallest interval that is currently allowed.
"""
timestamp_col_name: str = cast(str, self.schema.timestamp_column_name)
end_datetime: datetime = self.__dataframe[timestamp_col_name].max() + timedelta(
microseconds=1,
) # adding a microsecond, so it can be used as part of a right open interval
return end_datetime
minutes=1,
) # adding a minute, because it's the smallest interval allowed
return end_datetime.replace(second=0, microsecond=0)

@property
def dataframe(self) -> DataFrame:
Expand Down
10 changes: 8 additions & 2 deletions tests/datasets/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,14 @@ def test_dataset_bookends(self) -> None:
)
output_dataset = Dataset(dataframe=input_df, schema=input_schema)

assert output_dataset.start_time == raw_data_min_time
assert output_dataset.end_time == raw_data_max_time + timedelta(microseconds=1)
assert output_dataset.start_time == raw_data_min_time.replace(
second=0,
microsecond=0,
)
assert output_dataset.end_time == (raw_data_max_time + timedelta(minutes=1)).replace(
second=0,
microsecond=0,
)

@property
def num_records(self):
Expand Down