From 0494725a7238dffc9f7e6d47de99552d788aa548 Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Mon, 10 Apr 2023 09:49:11 -0700 Subject: [PATCH 1/2] fix bug --- src/phoenix/datasets/dataset.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/phoenix/datasets/dataset.py b/src/phoenix/datasets/dataset.py index 87d4d41744..58a2fc308d 100644 --- a/src/phoenix/datasets/dataset.py +++ b/src/phoenix/datasets/dataset.py @@ -108,13 +108,13 @@ def start_time(self) -> datetime: 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 + end_datetime equals max(timestamp) + 1 minute, so that it can be used as part of a right-open interval. """ 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 + minutes=1, + ) # adding a minute, so it can be used as part of a right open interval return end_datetime @property From 9570f702ac2588c0c830f44a9a3f1a95817c7f9f Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Mon, 10 Apr 2023 10:21:08 -0700 Subject: [PATCH 2/2] round to minute --- src/phoenix/datasets/dataset.py | 9 +++++---- tests/datasets/test_dataset.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/phoenix/datasets/dataset.py b/src/phoenix/datasets/dataset.py index 58a2fc308d..bd9bb43141 100644 --- a/src/phoenix/datasets/dataset.py +++ b/src/phoenix/datasets/dataset.py @@ -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 minute, so that it can be - used as part of a right-open interval. + 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( minutes=1, - ) # adding a minute, so it can be used as part of a right open interval - return end_datetime + ) # adding a minute, because it's the smallest interval allowed + return end_datetime.replace(second=0, microsecond=0) @property def dataframe(self) -> DataFrame: diff --git a/tests/datasets/test_dataset.py b/tests/datasets/test_dataset.py index 79b0dd898d..764ac7e600 100644 --- a/tests/datasets/test_dataset.py +++ b/tests/datasets/test_dataset.py @@ -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):