industrial-model 0.1.2__tar.gz → 0.1.3__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.
- industrial_model-0.1.3/PKG-INFO +166 -0
- industrial_model-0.1.3/README.md +146 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/pyproject.toml +1 -1
- industrial_model-0.1.2/PKG-INFO +0 -23
- industrial_model-0.1.2/README.md +0 -3
- industrial_model-0.1.2/assets/logo.jpeg +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/.gitignore +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/.python-version +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/optimizer.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/query_mapper.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/schemas.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/utils.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/view_mapper.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/config.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/constants.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/engines/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/engines/async_engine.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/engines/engine.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/models/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/models/base.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/models/entities.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/py.typed +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/queries/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/queries/models.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/queries/params.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/statements/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/statements/expressions.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/utils.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/scripts/build.sh +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/scripts/format.sh +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/scripts/lint.sh +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/tests/__init__.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/tests/cognite-sdk-config.yaml +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/tests/hubs.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/tests/tests_adapter.py +0 -0
- {industrial_model-0.1.2 → industrial_model-0.1.3}/uv.lock +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: industrial-model
|
|
3
|
+
Version: 0.1.3
|
|
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
|
+
livesIn: 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.livesIn).nested_(Country.name == "usa"),
|
|
132
|
+
and_(
|
|
133
|
+
col(Person.livesIn).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
|
+
---
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
livesIn: Country
|
|
65
|
+
cars: list[Car]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Initialize Cognite client and data model engine
|
|
69
|
+
|
|
70
|
+
cognite_client = CogniteClient()
|
|
71
|
+
|
|
72
|
+
data_model_id = DataModelId(
|
|
73
|
+
external_id="IndustrialData",
|
|
74
|
+
space="IndustralSpaceType",
|
|
75
|
+
version="v1"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
engine = Engine(cognite_client, data_model_id)
|
|
79
|
+
async_engine = AsyncEngine(cognite_client, data_model_id) # Optional async engine
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# -----------------------------------
|
|
83
|
+
# Example Queries
|
|
84
|
+
# -----------------------------------
|
|
85
|
+
|
|
86
|
+
# 1. Basic query: Find person named "Lucas"
|
|
87
|
+
statement = select(Person).where(Person.name == "Lucas").limit(1)
|
|
88
|
+
result = engine.query(statement)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# 2. Combined filter with AND/OR
|
|
92
|
+
statement = select(Person).where(
|
|
93
|
+
(Person.name == "Lucas") & (Person.birthday > datetime.date(2023, 1, 2)) |
|
|
94
|
+
(Person.name == "Another")
|
|
95
|
+
)
|
|
96
|
+
result = engine.query(statement)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# 3. Same logic using `col()` expressions
|
|
100
|
+
statement = select(Person).where(
|
|
101
|
+
(col("name").equals_("Lucas")) &
|
|
102
|
+
(col(Person.birthday).gt_("2023-01-02")) |
|
|
103
|
+
(Person.name == "Another")
|
|
104
|
+
)
|
|
105
|
+
result = engine.query(statement)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# 4. Nested filtering using relationships
|
|
109
|
+
statement = select(Person).where(
|
|
110
|
+
or_(
|
|
111
|
+
col(Person.livesIn).nested_(Country.name == "usa"),
|
|
112
|
+
and_(
|
|
113
|
+
col(Person.livesIn).nested_(col(Country.name).equals_("bra")),
|
|
114
|
+
col(Person.birthday).equals_("2023-01-01")
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
result = engine.query(statement)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# 5. Paginated query with sorting and cursor
|
|
122
|
+
statement = (
|
|
123
|
+
select(Person)
|
|
124
|
+
.where(
|
|
125
|
+
(Person.name == "Lucas") &
|
|
126
|
+
(Person.birthday > datetime.date(2023, 1, 2)) |
|
|
127
|
+
(Person.name == "Another")
|
|
128
|
+
)
|
|
129
|
+
.limit(10)
|
|
130
|
+
.cursor("NEXT CURSOR")
|
|
131
|
+
.asc(Person.name)
|
|
132
|
+
)
|
|
133
|
+
result = engine.query(statement)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# 6. Fetch all pages of a query
|
|
137
|
+
statement = select(Person).where(
|
|
138
|
+
(Person.name == "Lucas") &
|
|
139
|
+
(Person.birthday > datetime.date(2023, 1, 2)) |
|
|
140
|
+
(Person.name == "Another")
|
|
141
|
+
)
|
|
142
|
+
all_results = engine.query_all_pages(statement)
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
industrial_model-0.1.2/PKG-INFO
DELETED
|
@@ -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
|
-

|
industrial_model-0.1.2/README.md
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/__init__.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/filter_mapper.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/optimizer.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/query_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/schemas.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/sort_mapper.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/utils.py
RENAMED
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/cognite_adapters/view_mapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{industrial_model-0.1.2 → industrial_model-0.1.3}/industrial_model/statements/expressions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|