industrial-model 0.1.41__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {industrial_model-0.1.41 → industrial_model-1.0.1}/PKG-INFO +2 -3
  2. {industrial_model-0.1.41 → industrial_model-1.0.1}/README.md +1 -2
  3. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/sort_mapper.py +12 -2
  4. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/engines/_internal.py +6 -6
  5. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/models/entities.py +3 -3
  6. {industrial_model-0.1.41 → industrial_model-1.0.1}/pyproject.toml +1 -1
  7. {industrial_model-0.1.41 → industrial_model-1.0.1}/.gitignore +0 -0
  8. {industrial_model-0.1.41 → industrial_model-1.0.1}/LICENSE +0 -0
  9. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/__init__.py +0 -0
  10. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/__init__.py +0 -0
  11. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/aggregation_mapper.py +0 -0
  12. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
  13. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/models.py +0 -0
  14. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/optimizer.py +0 -0
  15. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/query_mapper.py +0 -0
  16. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
  17. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/search_mapper.py +0 -0
  18. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/upsert_mapper.py +0 -0
  19. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/utils.py +0 -0
  20. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/cognite_adapters/view_mapper.py +0 -0
  21. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/config.py +0 -0
  22. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/constants.py +0 -0
  23. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/engines/__init__.py +0 -0
  24. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/engines/async_engine.py +0 -0
  25. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/engines/engine.py +0 -0
  26. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/models/__init__.py +0 -0
  27. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/models/base.py +0 -0
  28. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/models/schemas.py +0 -0
  29. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/models/utils.py +0 -0
  30. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/py.typed +0 -0
  31. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/queries/__init__.py +0 -0
  32. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/queries/models.py +0 -0
  33. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/queries/params.py +0 -0
  34. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/queries/utils.py +0 -0
  35. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/statements/__init__.py +0 -0
  36. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/statements/expressions.py +0 -0
  37. {industrial_model-0.1.41 → industrial_model-1.0.1}/industrial_model/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 0.1.41
3
+ Version: 1.0.1
4
4
  Summary: Industrial Model ORM
5
5
  Project-URL: Homepage, https://github.com/lucasrosaalves/industrial-model
6
6
  Project-URL: Source, https://github.com/lucasrosaalves/industrial-model
@@ -24,7 +24,7 @@ Description-Content-Type: text/markdown
24
24
 
25
25
  # 📦 industrial-model
26
26
 
27
- `industrial-model` is a Python ORM-style abstraction for querying views and data models in Cognite Data Fusion (CDF). It provides a declarative and type-safe way to model CDF views using `pydantic`, build queries, and interact with the CDF API in a Pythonic fashion.
27
+ `industrial-model` is a Python ORM-style abstraction for querying views in Cognite Data Fusion (CDF). It provides a declarative and type-safe way to model CDF views using `pydantic`, build queries, and interact with the CDF API in a Pythonic fashion.
28
28
 
29
29
  ---
30
30
 
@@ -54,7 +54,6 @@ We use the simplified version of the `CogniteAsset`view in the `CogniteCore` dat
54
54
 
55
55
  ```graphql
56
56
  type CogniteAsset {
57
- object3D: Cognite3DObject
58
57
  name: String
59
58
  description: String
60
59
  tags: [String]
@@ -1,6 +1,6 @@
1
1
  # 📦 industrial-model
2
2
 
3
- `industrial-model` is a Python ORM-style abstraction for querying views and data models in Cognite Data Fusion (CDF). It provides a declarative and type-safe way to model CDF views using `pydantic`, build queries, and interact with the CDF API in a Pythonic fashion.
3
+ `industrial-model` is a Python ORM-style abstraction for querying views in Cognite Data Fusion (CDF). It provides a declarative and type-safe way to model CDF views using `pydantic`, build queries, and interact with the CDF API in a Pythonic fashion.
4
4
 
5
5
  ---
6
6
 
@@ -30,7 +30,6 @@ We use the simplified version of the `CogniteAsset`view in the `CogniteCore` dat
30
30
 
31
31
  ```graphql
32
32
  type CogniteAsset {
33
- object3D: Cognite3DObject
34
33
  name: String
35
34
  description: String
36
35
  tags: [String]
@@ -1,4 +1,4 @@
1
- from cognite.client.data_classes.data_modeling import InstanceSort, View
1
+ from cognite.client.data_classes.data_modeling import InstanceSort, MappedProperty, View
2
2
 
3
3
  from industrial_model.cognite_adapters.utils import get_property_ref
4
4
  from industrial_model.constants import SORT_DIRECTION
@@ -15,7 +15,17 @@ class SortMapper:
15
15
  InstanceSort(
16
16
  property=get_property_ref(column.property, root_view),
17
17
  direction=direction,
18
- nulls_first=direction == "descending",
18
+ nulls_first=self._is_nulls_first(column, root_view, direction),
19
19
  )
20
20
  for column, direction in sort_clauses
21
21
  ]
22
+
23
+ def _is_nulls_first(
24
+ self, column: Column, root_view: View, direction: SORT_DIRECTION
25
+ ) -> bool:
26
+ view_property = root_view.properties.get(column.property)
27
+
28
+ if isinstance(view_property, MappedProperty) and view_property.source:
29
+ return direction == "ascending"
30
+
31
+ return direction == "descending"
@@ -20,13 +20,13 @@ def generate_engine_params(
20
20
  file_env_parsed = env_sub_template.substitute(dict(os.environ))
21
21
 
22
22
  engine_config = yaml.safe_load(file_env_parsed)
23
- assert isinstance(
24
- engine_config, dict
25
- ), "Configuration file must contain a dictionary"
23
+ assert isinstance(engine_config, dict), (
24
+ "Configuration file must contain a dictionary"
25
+ )
26
26
  assert "cognite" in engine_config, "Configuration must contain 'cognite' section"
27
- assert (
28
- "data_model" in engine_config
29
- ), "Configuration must contain 'data_model' section"
27
+ assert "data_model" in engine_config, (
28
+ "Configuration must contain 'data_model' section"
29
+ )
30
30
 
31
31
  client = CogniteClient.load(engine_config["cognite"])
32
32
  dm_id = DataModelId.model_validate(engine_config["data_model"])
@@ -73,9 +73,9 @@ class ViewInstance(InstanceId):
73
73
  return cls.view_config.get("view_external_id") or cls.__name__
74
74
 
75
75
  def get_edge_metadata(self, property: Column | str | Any) -> list[EdgeContainer]:
76
- assert isinstance(
77
- property, Column | str
78
- ), f"Expected property to be Column, or str, got {type(property).__name__}"
76
+ assert isinstance(property, Column | str), (
77
+ f"Expected property to be Column, or str, got {type(property).__name__}"
78
+ )
79
79
  identifier = property.property if isinstance(property, Column) else property
80
80
 
81
81
  edge_map_key = self.get_field_alias(identifier) or self.get_field_name(
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "industrial-model"
3
- version = "0.1.41"
3
+ version = "1.0.1"
4
4
  description = "Industrial Model ORM"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"