Skip to content

Commit

Permalink
[PYG-284] ↩ Revert 0.99.34 change (#354)
Browse files Browse the repository at this point in the history
* revert: time_series_type to type_

* refactro: regen + changelog

* tests: updated tests to match type_

* build; bump

* build: changelog bump

* tests: updated tests
  • Loading branch information
doctrino authored Nov 12, 2024
1 parent fc5d79c commit 3c25779
Show file tree
Hide file tree
Showing 39 changed files with 469 additions and 480 deletions.
8 changes: 1 addition & 7 deletions cognite/pygen/_core/models/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import warnings
from dataclasses import dataclass
from string import digits
from typing import TYPE_CHECKING, Literal, TypeVar, cast

from cognite.client.data_classes import data_modeling as dm
Expand Down Expand Up @@ -67,12 +66,7 @@ def from_property(

field_naming = config.naming.field
name = create_name(prop_id, field_naming.name)
if name in {"type", "version"}:
# Special handling for reserved words
prop_view_id = _get_prop_view_id(prop_id, view_id, view_by_id)
prefix = prop_view_id.external_id.removeprefix("Cognite").removeprefix("3D").lstrip(digits)
name = create_name(f"{prefix}_{name}", field_naming.name)
elif is_reserved_word(name, "field", view_id, prop_id):
if is_reserved_word(name, "field", view_id, prop_id):
name = f"{name}_"

doc_name = to_words(name, singularize=True)
Expand Down
2 changes: 1 addition & 1 deletion cognite/pygen/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.99.46"
__version__ = "0.99.47"
6 changes: 5 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## TBD
## [0.99.47] - 24-11-12
### Fixed
- Raised lower bound of dependency `inflect` to `6.2` when support for `pydantic` `v2` was added.
- Reverting change from `0.99.34`. For example, for `CogniteTimeSeries` the property `type` will
now be named `type_` and not `time_series_type`. This is to avoid conflicts if the view has a property
named `time_series_type`. This typically occurs when someone extends `CogniteTimeSeries` and introduces
custom `types`.

## [0.99.46] - 24-11-11
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart/cdf_streamlit.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ adding `cognite-pygen` to the installed packages under `settings`.
pyodide-http==0.2.1
cognite-sdk==7.64.12
pydantic==1.10.7
cognite-pygen==0.99.46
cognite-pygen==0.99.47
```

Note that we also set `pydantic` to a specific version. This is because `pygen` supports both `pydantic` `v1` and `v2`, but
Expand Down
4 changes: 2 additions & 2 deletions examples/cognite_core/_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from cognite_core._api.cognite_3_d_model import Cognite3DModelAPI
from cognite_core._api.cognite_3_d_model_query import Cognite3DModelQueryAPI
from cognite_core._api.cognite_3_d_object import Cognite3DObjectAPI
from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImagesAPI
from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImages360API
from cognite_core._api.cognite_3_d_object_query import Cognite3DObjectQueryAPI
from cognite_core._api.cognite_3_d_revision import Cognite3DRevisionAPI
from cognite_core._api.cognite_3_d_revision_query import Cognite3DRevisionQueryAPI
Expand Down Expand Up @@ -72,7 +72,7 @@
"Cognite3DModelAPI",
"Cognite3DModelQueryAPI",
"Cognite3DObjectAPI",
"Cognite3DObjectImagesAPI",
"Cognite3DObjectImages360API",
"Cognite3DObjectQueryAPI",
"Cognite3DRevisionAPI",
"Cognite3DRevisionQueryAPI",
Expand Down
4 changes: 2 additions & 2 deletions examples/cognite_core/_api/cognite_3_d_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
NodeAPI,
SequenceNotStr,
)
from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImagesAPI
from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImages360API
from cognite_core._api.cognite_3_d_object_query import Cognite3DObjectQueryAPI


Expand All @@ -59,7 +59,7 @@ class Cognite3DObjectAPI(NodeAPI[Cognite3DObject, Cognite3DObjectWrite, Cognite3
def __init__(self, client: CogniteClient):
super().__init__(client=client)

self.images_360_edge = Cognite3DObjectImagesAPI(client)
self.images_360_edge = Cognite3DObjectImages360API(client)

def __call__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from cognite_core.data_classes._core import DEFAULT_INSTANCE_SPACE


class Cognite3DObjectImagesAPI(EdgePropertyAPI):
class Cognite3DObjectImages360API(EdgePropertyAPI):
_view_id = dm.ViewId("cdf_cdm", "Cognite360ImageAnnotation", "v1")
_class_type = Cognite360ImageAnnotation
_class_write_type = Cognite360ImageAnnotationWrite
Expand Down
40 changes: 20 additions & 20 deletions examples/cognite_core/_api/cognite_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __call__(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -167,7 +167,7 @@ def __call__(
max_source_updated_time: The maximum value of the source updated time to filter on.
source_updated_user: The source updated user to filter on.
source_updated_user_prefix: The prefix of the source updated user to filter on.
asset_type: The asset type to filter on.
type_: The type to filter on.
external_id_prefix: The prefix of the external ID to filter on.
space: The space to filter on.
limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
Expand Down Expand Up @@ -204,7 +204,7 @@ def __call__(
max_source_updated_time,
source_updated_user,
source_updated_user_prefix,
asset_type,
type_,
external_id_prefix,
space,
(filter and dm.filters.And(filter, has_data)) or has_data,
Expand All @@ -221,7 +221,7 @@ def apply(
"""Add or update (upsert) Cognite assets.
Note: This method iterates through all nodes and timeseries linked to cognite_asset and creates them including the edges
between the nodes. For example, if any of `asset_class`, `object_3d`, `parent`, `path`, `root`, `source` or `asset_type` are set, then these
between the nodes. For example, if any of `asset_class`, `object_3d`, `parent`, `path`, `root`, `source` or `type_` are set, then these
nodes as well as any nodes linked to them, and all the edges linking these nodes will be created.
Args:
Expand Down Expand Up @@ -392,7 +392,7 @@ def search(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -437,7 +437,7 @@ def search(
max_source_updated_time: The maximum value of the source updated time to filter on.
source_updated_user: The source updated user to filter on.
source_updated_user_prefix: The prefix of the source updated user to filter on.
asset_type: The asset type to filter on.
type_: The type to filter on.
external_id_prefix: The prefix of the external ID to filter on.
space: The space to filter on.
limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
Expand Down Expand Up @@ -486,7 +486,7 @@ def search(
max_source_updated_time,
source_updated_user,
source_updated_user_prefix,
asset_type,
type_,
external_id_prefix,
space,
filter,
Expand Down Expand Up @@ -575,7 +575,7 @@ def aggregate(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -663,7 +663,7 @@ def aggregate(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -755,7 +755,7 @@ def aggregate(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -846,7 +846,7 @@ def aggregate(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -895,7 +895,7 @@ def aggregate(
max_source_updated_time: The maximum value of the source updated time to filter on.
source_updated_user: The source updated user to filter on.
source_updated_user_prefix: The prefix of the source updated user to filter on.
asset_type: The asset type to filter on.
type_: The type to filter on.
external_id_prefix: The prefix of the external ID to filter on.
space: The space to filter on.
limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
Expand Down Expand Up @@ -940,7 +940,7 @@ def aggregate(
max_source_updated_time,
source_updated_user,
source_updated_user_prefix,
asset_type,
type_,
external_id_prefix,
space,
filter,
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def histogram(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def histogram(
max_source_updated_time: The maximum value of the source updated time to filter on.
source_updated_user: The source updated user to filter on.
source_updated_user_prefix: The prefix of the source updated user to filter on.
asset_type: The asset type to filter on.
type_: The type to filter on.
external_id_prefix: The prefix of the external ID to filter on.
space: The space to filter on.
limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def histogram(
max_source_updated_time,
source_updated_user,
source_updated_user_prefix,
asset_type,
type_,
external_id_prefix,
space,
filter,
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def list(
max_source_updated_time: datetime.datetime | None = None,
source_updated_user: str | list[str] | None = None,
source_updated_user_prefix: str | None = None,
asset_type: (
type_: (
str
| tuple[str, str]
| dm.NodeId
Expand Down Expand Up @@ -1238,7 +1238,7 @@ def list(
max_source_updated_time: The maximum value of the source updated time to filter on.
source_updated_user: The source updated user to filter on.
source_updated_user_prefix: The prefix of the source updated user to filter on.
asset_type: The asset type to filter on.
type_: The type to filter on.
external_id_prefix: The prefix of the external ID to filter on.
space: The space to filter on.
limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items.
Expand All @@ -1248,7 +1248,7 @@ def list(
sort: (Advanced) If sort_by and direction are not sufficient, you can write your own sorting.
This will override the sort_by and direction. This allowos you to sort by multiple fields and
specify the direction for each field as well as how to handle null values.
retrieve_connections: Whether to retrieve `activities`, `asset_class`, `children`, `equipment`, `files`, `object_3d`, `parent`, `path`, `root`, `source`, `time_series` and `asset_type` for the Cognite assets. Defaults to 'skip'.
retrieve_connections: Whether to retrieve `activities`, `asset_class`, `children`, `equipment`, `files`, `object_3d`, `parent`, `path`, `root`, `source`, `time_series` and `type_` for the Cognite assets. Defaults to 'skip'.
'skip' will not retrieve any connections, 'identifier' will only retrieve the identifier of the connected items, and 'full' will retrieve the full connected items.
Returns:
Expand Down Expand Up @@ -1289,7 +1289,7 @@ def list(
max_source_updated_time,
source_updated_user,
source_updated_user_prefix,
asset_type,
type_,
external_id_prefix,
space,
filter,
Expand Down
10 changes: 5 additions & 5 deletions examples/cognite_core/_api/cognite_asset_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def query(
retrieve_parent: bool = False,
retrieve_root: bool = False,
retrieve_source: bool = False,
retrieve_asset_type: bool = False,
retrieve_type_: bool = False,
) -> T_DomainModelList:
"""Execute query and return the result.
Expand All @@ -68,7 +68,7 @@ def query(
retrieve_parent: Whether to retrieve the parent for each Cognite asset or not.
retrieve_root: Whether to retrieve the root for each Cognite asset or not.
retrieve_source: Whether to retrieve the source for each Cognite asset or not.
retrieve_asset_type: Whether to retrieve the asset type for each Cognite asset or not.
retrieve_type_: Whether to retrieve the type for each Cognite asset or not.
Returns:
The list of the source nodes of the query.
Expand All @@ -85,8 +85,8 @@ def query(
self._query_append_root(from_)
if retrieve_source:
self._query_append_source(from_)
if retrieve_asset_type:
self._query_append_asset_type(from_)
if retrieve_type_:
self._query_append_type_(from_)
return self._query()

def _query_append_asset_class(self, from_: str) -> None:
Expand Down Expand Up @@ -159,7 +159,7 @@ def _query_append_source(self, from_: str) -> None:
),
)

def _query_append_asset_type(self, from_: str) -> None:
def _query_append_type_(self, from_: str) -> None:
self._builder.append(
NodeQueryStep(
name=self._builder.create_name(from_),
Expand Down
Loading

0 comments on commit 3c25779

Please sign in to comment.