Skip to content

Commit

Permalink
Add support for partitions param in FilesAPI.list() (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddonukis committed Apr 23, 2024
1 parent c5f3703 commit f4b0558
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.38.1] - 2024-04-23
### Added
- Added missing `partitions` parameter to `list()` and `__call__()` methods for `FilesAPI`.

## [7.38.0] - 2024-04-22
### Added
- Support for `workflows.executions.retry`
Expand Down
12 changes: 11 additions & 1 deletion cognite/client/_api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __call__(
directory_prefix: str | None = None,
uploaded: bool | None = None,
limit: int | None = None,
partitions: int | None = None,
) -> Iterator[FileMetadata] | Iterator[FileMetadataList]:
"""Iterate over files
Expand Down Expand Up @@ -95,6 +96,7 @@ def __call__(
directory_prefix (str | None): Filter by this (case-sensitive) prefix for the directory provided by the client.
uploaded (bool | None): Whether or not the actual file is uploaded. This field is returned only by the API, it has no effect in a post body.
limit (int | None): Maximum number of files to return. Defaults to return all items.
partitions (int | None): Retrieve resources in parallel using this number of workers (values up to 10 allowed), limit must be set to `None` (or `-1`).
Returns:
Iterator[FileMetadata] | Iterator[FileMetadataList]: yields FileMetadata one by one if chunk_size is not specified, else FileMetadataList objects.
Expand Down Expand Up @@ -129,6 +131,7 @@ def __call__(
chunk_size=chunk_size,
filter=filter,
limit=limit,
partitions=partitions,
)

def __iter__(self) -> Iterator[FileMetadata]:
Expand Down Expand Up @@ -1021,6 +1024,7 @@ def list(
directory_prefix: str | None = None,
uploaded: bool | None = None,
limit: int | None = DEFAULT_LIMIT_READ,
partitions: int | None = None,
) -> FileMetadataList:
"""`List files <https://developer.cognite.com/api#tag/Files/operation/advancedListFiles>`_
Expand All @@ -1046,6 +1050,7 @@ def list(
directory_prefix (str | None): Filter by this (case-sensitive) prefix for the directory provided by the client.
uploaded (bool | None): Whether or not the actual file is uploaded. This field is returned only by the API, it has no effect in a post body.
limit (int | None): Max number of files to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
partitions (int | None): Retrieve resources in parallel using this number of workers (values up to 10 allowed), limit must be set to `None` (or `-1`).
Returns:
FileMetadataList: The requested files.
Expand Down Expand Up @@ -1113,5 +1118,10 @@ def list(
).dump(camel_case=True)

return self._list(
list_cls=FileMetadataList, resource_cls=FileMetadata, method="POST", limit=limit, filter=filter
list_cls=FileMetadataList,
resource_cls=FileMetadata,
method="POST",
limit=limit,
filter=filter,
partitions=partitions,
)
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.38.0"
__version__ = "7.38.1"
__api_subversion__ = "20230101"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.38.0"
version = "7.38.1"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
6 changes: 5 additions & 1 deletion tests/tests_unit/test_api/test_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class TestListAndIterSignatures:
(
files.FilesAPI,
files.FileMetadataFilter,
["data_set_external_ids", "asset_subtree_external_ids"],
[
"data_set_external_ids",
"asset_subtree_external_ids",
"partitions",
],
),
(
sequences.SequencesAPI,
Expand Down

0 comments on commit f4b0558

Please sign in to comment.