Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "beta" warning for Units catalog [POFSP-195] #1522

Merged
merged 11 commits into from
Nov 27, 2023
16 changes: 4 additions & 12 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>`_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these urls seem to work yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, but they will be there once we merge https://github.com/cognitedata/service-contracts/pull/2375

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now they work @haakonvt


Args:
external_id (str | MutableSequence[str]): External ID or list of external IDs
Expand All @@ -64,7 +61,6 @@ def retrieve(
>>> 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,7 +70,7 @@ 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/Units/listUnits>`_

Returns:
UnitList: List of units
Expand All @@ -86,7 +82,6 @@ def list(self) -> UnitList:
>>> c = CogniteClient()
>>> res = c.units.list()
"""
self._warning.warn()
return self._list(method="GET", list_cls=UnitList, resource_cls=Unit)


Expand All @@ -98,14 +93,12 @@ def __init__(
config: ClientConfig,
api_version: str | None,
cognite_client: CogniteClient,
warning: FeaturePreviewWarning,
) -> None:
super().__init__(config, api_version, cognite_client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this entire init method now.

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
Expand All @@ -118,5 +111,4 @@ def list(self) -> UnitSystemList:
>>> res = c.units.systems.list()

"""
self._warning.warn()
return self._list(method="GET", list_cls=UnitSystemList, resource_cls=UnitSystem)