industrial-model 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.
@@ -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
+ ---
@@ -23,6 +23,6 @@ industrial_model/queries/models.py,sha256=iiHQ7-cfg0nukEv5PoCx9QPF-w1gVSnoNbXBOK
23
23
  industrial_model/queries/params.py,sha256=ehgCoR5n6E-tkEuoymZ2lkLcSzMaBAx_HnyJ7sWpqz0,964
24
24
  industrial_model/statements/__init__.py,sha256=mqPIvfQ-XZ_IILwha7RbkdIKH_MRAdAvfrw80pCKU1c,1753
25
25
  industrial_model/statements/expressions.py,sha256=bsUnkFDGVHpOQ1RUtEbSPE1nfVkF0zC3m5-9JFkSqu8,4751
26
- industrial_model-0.1.2.dist-info/METADATA,sha256=ZoXlx7woaGqKYSku3ooMzGzVu9MXcaMe-nTR0MiA4zg,763
27
- industrial_model-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- industrial_model-0.1.2.dist-info/RECORD,,
26
+ industrial_model-0.1.3.dist-info/METADATA,sha256=3DmP5yMReiv2zFlknqgEo6hCLMoIwQDNGX0e_wqN0KE,3935
27
+ industrial_model-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ industrial_model-0.1.3.dist-info/RECORD,,
@@ -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)