Skip to content

Commit

Permalink
fix: Updated all Data Modeling limits to match API spec (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored May 21, 2024
1 parent b9ce405 commit 3750f59
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.43.4] - 2024-05-20
### Fixed
- The data modeling APIs (Views, Containers, Data Models and Spaces) limits for create, retrieve, delete,
and list were not matching the API spec, causing the SDK to wrongly split large calls into too few requests.
This means that the SDK will no longer raise a `CogniteAPIError` if you, for example, try to delete
more than 100 containers in a single method call.

## [7.43.3] - 2024-05-15
### Fixed
- Identity providers that return `expires_in` as a string no longer causes `TypeError` when authenticating.
Expand Down
13 changes: 11 additions & 2 deletions cognite/client/_api/data_modeling/containers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Iterator, Literal, Sequence, cast, overload
from typing import TYPE_CHECKING, Iterator, Literal, Sequence, cast, overload

from cognite.client._api_client import APIClient
from cognite.client._constants import DATA_MODELING_DEFAULT_LIMIT_READ
Expand All @@ -19,10 +19,19 @@
)
from cognite.client.utils._concurrency import ConcurrencySettings

if TYPE_CHECKING:
from cognite.client import CogniteClient
from cognite.client.config import ClientConfig


class ContainersAPI(APIClient):
_RESOURCE_PATH = "/models/containers"
_LIST_LIMIT = 100

def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self._DELETE_LIMIT = 100
self._RETRIEVE_LIMIT = 100
self._CREATE_LIMIT = 100

@overload
def __call__(
Expand Down
13 changes: 11 additions & 2 deletions cognite/client/_api/data_modeling/data_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Iterator, Literal, Sequence, cast, overload
from typing import TYPE_CHECKING, Iterator, Literal, Sequence, cast, overload

from cognite.client._api_client import APIClient
from cognite.client._constants import DATA_MODELING_DEFAULT_LIMIT_READ
Expand All @@ -14,10 +14,19 @@
from cognite.client.data_classes.data_modeling.views import View
from cognite.client.utils._concurrency import ConcurrencySettings

if TYPE_CHECKING:
from cognite.client import CogniteClient
from cognite.client.config import ClientConfig


class DataModelsAPI(APIClient):
_RESOURCE_PATH = "/models/datamodels"
_LIST_LIMIT = 100

def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self._DELETE_LIMIT = 100
self._RETRIEVE_LIMIT = 100
self._CREATE_LIMIT = 100

@overload
def __call__(
Expand Down
13 changes: 11 additions & 2 deletions cognite/client/_api/data_modeling/spaces.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Iterator, Sequence, cast, overload
from typing import TYPE_CHECKING, Iterator, Sequence, cast, overload

from cognite.client._api_client import APIClient
from cognite.client._constants import DEFAULT_LIMIT_READ
Expand All @@ -9,10 +9,19 @@
from cognite.client.utils._concurrency import ConcurrencySettings
from cognite.client.utils.useful_types import SequenceNotStr

if TYPE_CHECKING:
from cognite.client import CogniteClient
from cognite.client.config import ClientConfig


class SpacesAPI(APIClient):
_RESOURCE_PATH = "/models/spaces"
_LIST_LIMIT = 100

def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self._DELETE_LIMIT = 100
self._RETRIEVE_LIMIT = 100
self._CREATE_LIMIT = 100

@overload
def __call__(
Expand Down
13 changes: 11 additions & 2 deletions cognite/client/_api/data_modeling/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections import defaultdict
from typing import Iterator, Sequence, cast, overload
from typing import TYPE_CHECKING, Iterator, Sequence, cast, overload

from cognite.client._api_client import APIClient
from cognite.client._constants import DATA_MODELING_DEFAULT_LIMIT_READ
Expand All @@ -13,10 +13,19 @@
from cognite.client.data_classes.data_modeling.views import View, ViewApply, ViewFilter, ViewList
from cognite.client.utils._concurrency import ConcurrencySettings

if TYPE_CHECKING:
from cognite.client import CogniteClient
from cognite.client.config import ClientConfig


class ViewsAPI(APIClient):
_RESOURCE_PATH = "/models/views"
_LIST_LIMIT = 100

def __init__(self, config: ClientConfig, api_version: str | None, cognite_client: CogniteClient) -> None:
super().__init__(config, api_version, cognite_client)
self._DELETE_LIMIT = 100
self._RETRIEVE_LIMIT = 100
self._CREATE_LIMIT = 100

@overload
def __call__(
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.43.3"
__version__ = "7.43.4"
__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.43.3"
version = "7.43.4"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down

0 comments on commit 3750f59

Please sign in to comment.