industrial-model 0.1.2__tar.gz → 0.1.4__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 (41) hide show
  1. industrial_model-0.1.4/PKG-INFO +186 -0
  2. industrial_model-0.1.4/README.md +166 -0
  3. {industrial_model-0.1.2 → industrial_model-0.1.4}/pyproject.toml +1 -1
  4. industrial_model-0.1.2/PKG-INFO +0 -23
  5. industrial_model-0.1.2/README.md +0 -3
  6. industrial_model-0.1.2/assets/logo.jpeg +0 -0
  7. {industrial_model-0.1.2 → industrial_model-0.1.4}/.gitignore +0 -0
  8. {industrial_model-0.1.2 → industrial_model-0.1.4}/.python-version +0 -0
  9. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/__init__.py +0 -0
  10. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/__init__.py +0 -0
  11. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
  12. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/optimizer.py +0 -0
  13. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/query_mapper.py +0 -0
  14. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
  15. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/schemas.py +0 -0
  16. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
  17. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/utils.py +0 -0
  18. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/cognite_adapters/view_mapper.py +0 -0
  19. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/config.py +0 -0
  20. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/constants.py +0 -0
  21. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/engines/__init__.py +0 -0
  22. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/engines/async_engine.py +0 -0
  23. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/engines/engine.py +0 -0
  24. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/models/__init__.py +0 -0
  25. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/models/base.py +0 -0
  26. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/models/entities.py +0 -0
  27. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/py.typed +0 -0
  28. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/queries/__init__.py +0 -0
  29. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/queries/models.py +0 -0
  30. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/queries/params.py +0 -0
  31. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/statements/__init__.py +0 -0
  32. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/statements/expressions.py +0 -0
  33. {industrial_model-0.1.2 → industrial_model-0.1.4}/industrial_model/utils.py +0 -0
  34. {industrial_model-0.1.2 → industrial_model-0.1.4}/scripts/build.sh +0 -0
  35. {industrial_model-0.1.2 → industrial_model-0.1.4}/scripts/format.sh +0 -0
  36. {industrial_model-0.1.2 → industrial_model-0.1.4}/scripts/lint.sh +0 -0
  37. {industrial_model-0.1.2 → industrial_model-0.1.4}/tests/__init__.py +0 -0
  38. {industrial_model-0.1.2 → industrial_model-0.1.4}/tests/cognite-sdk-config.yaml +0 -0
  39. {industrial_model-0.1.2 → industrial_model-0.1.4}/tests/hubs.py +0 -0
  40. {industrial_model-0.1.2 → industrial_model-0.1.4}/tests/tests_adapter.py +0 -0
  41. {industrial_model-0.1.2 → industrial_model-0.1.4}/uv.lock +0 -0
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: industrial-model
3
+ Version: 0.1.4
4
+ Summary: Industrial Model ORM
5
+ Author-email: Lucas Alves <lucasrosaalves@gmail.com>
6
+ Classifier: Programming Language :: Python
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Topic :: Database
13
+ Classifier: Topic :: Database :: Database Engines/Servers
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: anyio>=4.9.0
17
+ Requires-Dist: cognite-sdk>=7.75.0
18
+ Requires-Dist: pydantic>=2.11.4
19
+ Description-Content-Type: text/markdown
20
+
21
+ # 📦 industrial-model
22
+
23
+ `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.
24
+
25
+ ---
26
+
27
+ ## ✨ Features
28
+
29
+ - Define CDF views using Pydantic-style classes.
30
+ - Build complex queries using fluent and composable filters.
31
+ - Easily fetch data using standard or paginated query execution.
32
+ - Automatic alias and field transformation support.
33
+ - Extensible and test-friendly design.
34
+
35
+ ---
36
+
37
+ ## 📦 Installation
38
+
39
+ ```bash
40
+ pip install industrial-model
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 🛠️ Usage Example
46
+
47
+ ```python
48
+ import datetime
49
+ from cognite.client import CogniteClient
50
+ from pydantic import Field
51
+
52
+ from industrial_model import (
53
+ AsyncEngine,
54
+ DataModelId,
55
+ Engine,
56
+ ViewInstance,
57
+ select,
58
+ col,
59
+ and_,
60
+ or_,
61
+ )
62
+
63
+ # Define entities (view instances)
64
+
65
+
66
+ class Car(ViewInstance):
67
+ name: str
68
+
69
+
70
+ class Region(ViewInstance):
71
+ name: str
72
+
73
+
74
+ class Country(ViewInstance):
75
+ name: str
76
+ region: Region = Field(
77
+ alias="regionRef"
78
+ ) # Maps property to field if names differ
79
+
80
+
81
+ class Person(ViewInstance):
82
+ name: str
83
+ birthday: datetime.date
84
+ lives_in: Country
85
+ cars: list[Car]
86
+
87
+
88
+ # By default, the ORM maps the class name to the view in the data model.
89
+ # You can override this behavior using the `view_config` field.
90
+
91
+ # For improved query performance, you can configure `instance_spaces` or `instance_spaces_prefix`
92
+ # in the `view_config`. These options include space filters in the generated queries,
93
+ # which can significantly reduce response times when working with large datasets.
94
+
95
+ class AnotherPerson(ViewInstance):
96
+ view_config = ViewInstanceConfig(
97
+ view_external_id="Person", # Maps this class to the 'Person' view
98
+ instance_spaces_prefix="Industr-", # Filters queries to spaces with this prefix
99
+ instance_spaces=["Industrial-Data"] # Alternatively, explicitly filter by these spaces
100
+ )
101
+
102
+ name: str
103
+ birthday: datetime.date
104
+ lives_in: Country
105
+ cars: list[Car]
106
+
107
+
108
+ # Initialize Cognite client and data model engine
109
+
110
+ cognite_client = CogniteClient()
111
+
112
+ data_model_id = DataModelId(
113
+ external_id="IndustrialData",
114
+ space="IndustralSpaceType",
115
+ version="v1"
116
+ )
117
+
118
+ engine = Engine(cognite_client, data_model_id)
119
+ async_engine = AsyncEngine(cognite_client, data_model_id) # Optional async engine
120
+
121
+
122
+ # -----------------------------------
123
+ # Example Queries
124
+ # -----------------------------------
125
+
126
+ # 1. Basic query: Find person named "Lucas"
127
+ statement = select(Person).where(Person.name == "Lucas").limit(1)
128
+ result = engine.query(statement)
129
+
130
+
131
+ # 2. Combined filter with AND/OR
132
+ statement = select(Person).where(
133
+ (Person.name == "Lucas") & (Person.birthday > datetime.date(2023, 1, 2)) |
134
+ (Person.name == "Another")
135
+ )
136
+ result = engine.query(statement)
137
+
138
+
139
+ # 3. Same logic using `col()` expressions
140
+ statement = select(Person).where(
141
+ (col("name").equals_("Lucas")) &
142
+ (col(Person.birthday).gt_("2023-01-02")) |
143
+ (Person.name == "Another")
144
+ )
145
+ result = engine.query(statement)
146
+
147
+
148
+ # 4. Nested filtering using relationships
149
+ statement = select(Person).where(
150
+ or_(
151
+ col(Person.lives_in).nested_(Country.name == "usa"),
152
+ and_(
153
+ col(Person.lives_in).nested_(col(Country.name).equals_("bra")),
154
+ col(Person.birthday).equals_("2023-01-01")
155
+ )
156
+ )
157
+ )
158
+ result = engine.query(statement)
159
+
160
+
161
+ # 5. Paginated query with sorting and cursor
162
+ statement = (
163
+ select(Person)
164
+ .where(
165
+ (Person.name == "Lucas") &
166
+ (Person.birthday > datetime.date(2023, 1, 2)) |
167
+ (Person.name == "Another")
168
+ )
169
+ .limit(10)
170
+ .cursor("NEXT CURSOR")
171
+ .asc(Person.name)
172
+ )
173
+ result = engine.query(statement)
174
+
175
+
176
+ # 6. Fetch all pages of a query
177
+ statement = select(Person).where(
178
+ (Person.name == "Lucas") &
179
+ (Person.birthday > datetime.date(2023, 1, 2)) |
180
+ (Person.name == "Another")
181
+ )
182
+ all_results = engine.query_all_pages(statement)
183
+
184
+ ```
185
+
186
+ ---
@@ -0,0 +1,166 @@
1
+ # 📦 industrial-model
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.
4
+
5
+ ---
6
+
7
+ ## ✨ Features
8
+
9
+ - Define CDF views using Pydantic-style classes.
10
+ - Build complex queries using fluent and composable filters.
11
+ - Easily fetch data using standard or paginated query execution.
12
+ - Automatic alias and field transformation support.
13
+ - Extensible and test-friendly design.
14
+
15
+ ---
16
+
17
+ ## 📦 Installation
18
+
19
+ ```bash
20
+ pip install industrial-model
21
+ ```
22
+
23
+ ---
24
+
25
+ ## 🛠️ Usage Example
26
+
27
+ ```python
28
+ import datetime
29
+ from cognite.client import CogniteClient
30
+ from pydantic import Field
31
+
32
+ from industrial_model import (
33
+ AsyncEngine,
34
+ DataModelId,
35
+ Engine,
36
+ ViewInstance,
37
+ select,
38
+ col,
39
+ and_,
40
+ or_,
41
+ )
42
+
43
+ # Define entities (view instances)
44
+
45
+
46
+ class Car(ViewInstance):
47
+ name: str
48
+
49
+
50
+ class Region(ViewInstance):
51
+ name: str
52
+
53
+
54
+ class Country(ViewInstance):
55
+ name: str
56
+ region: Region = Field(
57
+ alias="regionRef"
58
+ ) # Maps property to field if names differ
59
+
60
+
61
+ class Person(ViewInstance):
62
+ name: str
63
+ birthday: datetime.date
64
+ lives_in: Country
65
+ cars: list[Car]
66
+
67
+
68
+ # By default, the ORM maps the class name to the view in the data model.
69
+ # You can override this behavior using the `view_config` field.
70
+
71
+ # For improved query performance, you can configure `instance_spaces` or `instance_spaces_prefix`
72
+ # in the `view_config`. These options include space filters in the generated queries,
73
+ # which can significantly reduce response times when working with large datasets.
74
+
75
+ class AnotherPerson(ViewInstance):
76
+ view_config = ViewInstanceConfig(
77
+ view_external_id="Person", # Maps this class to the 'Person' view
78
+ instance_spaces_prefix="Industr-", # Filters queries to spaces with this prefix
79
+ instance_spaces=["Industrial-Data"] # Alternatively, explicitly filter by these spaces
80
+ )
81
+
82
+ name: str
83
+ birthday: datetime.date
84
+ lives_in: Country
85
+ cars: list[Car]
86
+
87
+
88
+ # Initialize Cognite client and data model engine
89
+
90
+ cognite_client = CogniteClient()
91
+
92
+ data_model_id = DataModelId(
93
+ external_id="IndustrialData",
94
+ space="IndustralSpaceType",
95
+ version="v1"
96
+ )
97
+
98
+ engine = Engine(cognite_client, data_model_id)
99
+ async_engine = AsyncEngine(cognite_client, data_model_id) # Optional async engine
100
+
101
+
102
+ # -----------------------------------
103
+ # Example Queries
104
+ # -----------------------------------
105
+
106
+ # 1. Basic query: Find person named "Lucas"
107
+ statement = select(Person).where(Person.name == "Lucas").limit(1)
108
+ result = engine.query(statement)
109
+
110
+
111
+ # 2. Combined filter with AND/OR
112
+ statement = select(Person).where(
113
+ (Person.name == "Lucas") & (Person.birthday > datetime.date(2023, 1, 2)) |
114
+ (Person.name == "Another")
115
+ )
116
+ result = engine.query(statement)
117
+
118
+
119
+ # 3. Same logic using `col()` expressions
120
+ statement = select(Person).where(
121
+ (col("name").equals_("Lucas")) &
122
+ (col(Person.birthday).gt_("2023-01-02")) |
123
+ (Person.name == "Another")
124
+ )
125
+ result = engine.query(statement)
126
+
127
+
128
+ # 4. Nested filtering using relationships
129
+ statement = select(Person).where(
130
+ or_(
131
+ col(Person.lives_in).nested_(Country.name == "usa"),
132
+ and_(
133
+ col(Person.lives_in).nested_(col(Country.name).equals_("bra")),
134
+ col(Person.birthday).equals_("2023-01-01")
135
+ )
136
+ )
137
+ )
138
+ result = engine.query(statement)
139
+
140
+
141
+ # 5. Paginated query with sorting and cursor
142
+ statement = (
143
+ select(Person)
144
+ .where(
145
+ (Person.name == "Lucas") &
146
+ (Person.birthday > datetime.date(2023, 1, 2)) |
147
+ (Person.name == "Another")
148
+ )
149
+ .limit(10)
150
+ .cursor("NEXT CURSOR")
151
+ .asc(Person.name)
152
+ )
153
+ result = engine.query(statement)
154
+
155
+
156
+ # 6. Fetch all pages of a query
157
+ statement = select(Person).where(
158
+ (Person.name == "Lucas") &
159
+ (Person.birthday > datetime.date(2023, 1, 2)) |
160
+ (Person.name == "Another")
161
+ )
162
+ all_results = engine.query_all_pages(statement)
163
+
164
+ ```
165
+
166
+ ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "industrial-model"
3
- version = "0.1.2"
3
+ version = "0.1.4"
4
4
  description = "Industrial Model ORM"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,23 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: industrial-model
3
- Version: 0.1.2
4
- Summary: Industrial Model ORM
5
- Author-email: Lucas Alves <lucasrosaalves@gmail.com>
6
- Classifier: Programming Language :: Python
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: Programming Language :: Python :: 3 :: Only
9
- Classifier: Programming Language :: Python :: 3.11
10
- Classifier: Programming Language :: Python :: 3.12
11
- Classifier: Programming Language :: Python :: 3.13
12
- Classifier: Topic :: Database
13
- Classifier: Topic :: Database :: Database Engines/Servers
14
- Classifier: Typing :: Typed
15
- Requires-Python: >=3.11
16
- Requires-Dist: anyio>=4.9.0
17
- Requires-Dist: cognite-sdk>=7.75.0
18
- Requires-Dist: pydantic>=2.11.4
19
- Description-Content-Type: text/markdown
20
-
21
- # capybara
22
-
23
- ![My Image](./assets/logo.jpeg)
@@ -1,3 +0,0 @@
1
- # capybara
2
-
3
- ![My Image](./assets/logo.jpeg)
Binary file