Skip to content

Commit

Permalink
Remove "beta" warning for Units catalog [POFSP-195] (#1522)
Browse files Browse the repository at this point in the history
Co-authored-by: Håkon V. Treider <[email protected]>
  • Loading branch information
polomani and haakonvt authored Nov 27, 2023
1 parent 534dc3d commit f4c00fe
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ scripts/local_client.py
playground.py
scripts/tmp/
my_file.txt
.venv/
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.4.0] - 2023-11-27
### Changed
- Unit Catalog API is out of beta and will no longer issue warnings on usage. Access is unchanged: `client.units`.

## [7.3.3] - 2023-11-22
### Fixed
- Added action `Delete` in `ProjectsAcl`.
Expand Down
36 changes: 11 additions & 25 deletions cognite/client/_api/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
UnitSystem,
UnitSystemList,
)
from cognite.client.utils._experimental import FeaturePreviewWarning
from cognite.client.utils._identifier import IdentifierSequence

if TYPE_CHECKING:
Expand All @@ -26,9 +25,7 @@ def __init__(
cognite_client: CogniteClient,
) -> None:
super().__init__(config, api_version, cognite_client)
self._api_subversion = "beta"
self._warning = FeaturePreviewWarning(api_maturity="beta", sdk_maturity="beta", feature_name="Unit Catalogue")
self.systems = UnitSystemAPI(config, api_version, cognite_client, self._warning)
self.systems = UnitSystemAPI(config, api_version, cognite_client)

@overload
def retrieve(self, external_id: str, ignore_unknown_ids: bool = False) -> None | Unit:
Expand All @@ -41,7 +38,7 @@ def retrieve(self, external_id: MutableSequence[str], ignore_unknown_ids: bool =
def retrieve(
self, external_id: str | MutableSequence[str], ignore_unknown_ids: bool = False
) -> Unit | UnitList | None:
"""`Retrieve one or more unit <https://pr-50.units-api.preview.cogniteapp.com/#tag/Units/operation/retrieve_units_by_ids_api_v1_projects__project__units_byids_post>`_
"""`Retrieve one or more unit <https://developer.cognite.com/api#tag/Units/operation/byIdsUnits>`_
Args:
external_id (str | MutableSequence[str]): External ID or list of external IDs
Expand All @@ -51,20 +48,20 @@ def retrieve(
Unit | UnitList | None: If a single external ID is specified: the requested unit, or None if it does not exist. If several external IDs are specified: the requested units.
Examples:
Retrive unit 'temperature:deg_c'
Retrive unit 'temperature:deg_c'::
>>> from cognite.client import CogniteClient
>>> c = CogniteClient()
>>> res = c.units.retrieve('temperature:deg_c')
Retrive units 'temperature:deg_c' and 'pressure:bar'
Retrive units 'temperature:deg_c' and 'pressure:bar'::
>>> from cognite.client import CogniteClient
>>> c = CogniteClient()
>>> res = c.units.retrieve(['temperature:deg_c', 'pressure:bar'])
"""
self._warning.warn()
identifier = IdentifierSequence.load(external_ids=external_id)
return self._retrieve_multiple(
identifiers=identifier,
Expand All @@ -74,49 +71,38 @@ def retrieve(
)

def list(self) -> UnitList:
"""`List all supported units <https://pr-50.units-api.preview.cogniteapp.com/#tag/Units/operation/List_units_api_v1_projects__project__units_get>`_
"""`List all supported units <https://developer.cognite.com/api#tag/Units/operation/listUnits>`_
Returns:
UnitList: List of units
Examples:
List all supported unit in CDF:
List all supported unit in CDF::
>>> from cognite.client import CogniteClient
>>> c = CogniteClient()
>>> res = c.units.list()
"""
self._warning.warn()
return self._list(method="GET", list_cls=UnitList, resource_cls=Unit)


class UnitSystemAPI(APIClient):
_RESOURCE_PATH = "/units/systems"

def __init__(
self,
config: ClientConfig,
api_version: str | None,
cognite_client: CogniteClient,
warning: FeaturePreviewWarning,
) -> None:
super().__init__(config, api_version, cognite_client)
self._warning = warning
self._api_subversion = "beta"

def list(self) -> UnitSystemList:
"""`List all supported unit systems <https://pr-50.units-api.preview.cogniteapp.com/#tag/Units/operation/list_unit_systems_api_v1_projects__project__units_systems_get>`_
"""`List all supported unit systems <https://developer.cognite.com/api#tag/Unit-Systems/operation/listUnitSystems>`_
Returns:
UnitSystemList: List of unit systems
Examples:
List all supported unit systems in CDF:
List all supported unit systems in CDF::
>>> from cognite.client import CogniteClient
>>> c = CogniteClient()
>>> res = c.units.systems.list()
"""
self._warning.warn()
return self._list(method="GET", list_cls=UnitSystemList, resource_cls=UnitSystem)
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.3.3"
__version__ = "7.4.0"
__api_subversion__ = "V20220125"
8 changes: 0 additions & 8 deletions docs/source/unit_catalog.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
Unit Catalog
======================

.. warning::
Unit Catalog is a new feature:
* The API specification is in beta.
* The SDK implementation is in alpha.

Thus, breaking changes may occur without further notice, see :ref:`appendix-alpha-beta-features` for more information.


Units
------------
List Units
Expand Down
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.3.3"
version = "7.4.0"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down

0 comments on commit f4c00fe

Please sign in to comment.