Skip to content

Commit

Permalink
Fix bug in sequences.data.retrieve_dataframe (#1924)
Browse files Browse the repository at this point in the history
Co-authored-by: Anders Albert <[email protected]>
  • Loading branch information
KristianVangsnes and doctrino authored Sep 12, 2024
1 parent 66879d4 commit 44f724b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.59.1] - 2024-09-12
## [7.59.2] - 2024-09-12
### Fixed
- A bug in `client.sequences.data.retrieve_dataframe(...)` where passing a column to `column_external_ids` caused a TypeError.

## [7.59.1] - 2024-09-12
### Fixed
- Creating a function using files dated before 1980 no longer raises ValueError,
by overriding the timestamps to 1980-01-01.
Expand Down
12 changes: 6 additions & 6 deletions cognite/client/_api/sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,14 +1295,14 @@ def retrieve_dataframe(
column_names_default = "columnExternalId"

if external_id is not None and id is None:
return self.retrieve(external_id=external_id, start=start, end=end, limit=limit).to_pandas(
# TODO(doctrino): Is this supported: `column_names=column_external_ids` ?
column_names=column_external_ids or column_names_default, # type: ignore [arg-type]
return self.retrieve(
external_id=external_id, start=start, end=end, limit=limit, columns=column_external_ids
).to_pandas(
column_names=column_names or column_names_default, # type: ignore [arg-type]
)
elif id is not None and external_id is None:
return self.retrieve(id=id, start=start, end=end, limit=limit).to_pandas(
# TODO(doctrino): Is this supported: `column_names=column_external_ids` ?
column_names=column_external_ids or column_names_default, # type: ignore [arg-type]
return self.retrieve(id=id, start=start, end=end, limit=limit, columns=column_external_ids).to_pandas(
column_names=column_names or column_names_default, # type: ignore [arg-type]
)
else:
raise ValueError("Either external_id or id must be specified")
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.59.1"
__version__ = "7.59.2"
__api_subversion__ = "20230101"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cognite-sdk"


version = "7.59.1"
version = "7.59.2"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
11 changes: 11 additions & 0 deletions tests/tests_unit/test_api/test_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,17 @@ def test_retrieve_dataframe_columns_mixed_with_zero(
)
pd.testing.assert_frame_equal(expected_df, data)

def test_retrieve_dataframe_columns_filter(
self, cognite_client, mock_seq_response, mock_get_sequence_data_two_col_with_zero
):
data_1 = cognite_client.sequences.data.retrieve_dataframe(
external_id="foo", start=0, end=100, column_external_ids=["ceid1"]
)
data_2 = cognite_client.sequences.data.retrieve(
external_id="foo", start=0, end=100, columns=["ceid1"]
).to_pandas()
assert data_1.equals(data_2)

def test_retrieve_dataframe_columns_many_extid(self, cognite_client, mock_get_sequence_data_many_columns):
data = cognite_client.sequences.data.retrieve(external_id="foo", start=1000000, end=1100000)
assert isinstance(data, SequenceRows)
Expand Down

0 comments on commit 44f724b

Please sign in to comment.