industrial-model 1.2.2__py3-none-any.whl → 1.2.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 1.2.2
3
+ Version: 1.2.4
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,22 +24,38 @@ 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 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
+ **Type-safe, Pythonic access to Cognite Data Fusion views.**
28
+
29
+ `industrial-model` is a Python ORM for Cognite Data Fusion (CDF). Define views as Pydantic models, build queries with a fluent API, and work with CDF in the same way you write the rest of your Python—with types, autocomplete, and clear errors.
30
+
31
+ ```python
32
+ from industrial_model import Engine, ViewInstance, ViewInstanceConfig, select
33
+ from pathlib import Path
34
+
35
+ class Asset(ViewInstance):
36
+ view_config = ViewInstanceConfig(
37
+ view_external_id="CogniteAsset", # Map to the view externalId. If the class name is the same as the view external id, you do not need to configure this property.
38
+ instance_spaces_prefix="instance_data-", # Define the scope of your instance spaces to improve performance.
39
+ )
40
+ name: str
41
+ description: str | None = None
42
+
43
+ engine = Engine.from_config_file(Path("cognite-sdk-config.yaml"))
44
+ results = engine.query(select(Asset).limit(10))
45
+ # results.data → list[Asset], fully typed
46
+ ```
28
47
 
29
48
  ---
30
49
 
31
50
  ## ✨ Features
32
51
 
33
- - **Declarative Models**: Define CDF views using Pydantic-style classes with type hints
34
- - **Type-Safe Queries**: Build complex queries using fluent and composable filters
35
- - **Flexible Querying**: Support for standard queries, paginated queries, and full page retrieval
36
- - **Advanced Filtering**: Rich set of filter operators including nested queries, edge filtering, and boolean logic
37
- - **Search Capabilities**: Full-text fuzzy search with configurable operators
38
- - **Aggregations**: Count, sum, average, min, max with grouping support
39
- - **Write Operations**: Upsert and delete instances with edge relationship support
40
- - **Automatic Aliasing**: Built-in support for field aliases and camelCase transformation
41
- - **Async Support**: All operations have async equivalents
42
- - **Validation Modes**: Configurable error handling for data validation
52
+ - **Declarative models** Pydantic-style classes with type hints; only the fields you need
53
+ - **Type-safe queries** Fluent, composable filters with full IDE support
54
+ - **Query, search, aggregate** Standard and paginated queries, full-text search, count/sum/avg/min/max
55
+ - **Rich filtering** Nested queries, edge filters, boolean logic, list/string operators
56
+ - **Read and write** Upsert and delete with edge relationship support
57
+ - **Async** All operations have async equivalents
58
+ - **Configurable validation** Choose how to handle validation errors per request
43
59
 
44
60
  ---
45
61
 
@@ -53,22 +69,24 @@ pip install industrial-model
53
69
 
54
70
  ## 📚 Table of Contents
55
71
 
56
- 1. [Getting Started](#-getting-started)
57
- 2. [Model Definition](#-model-definition)
58
- 3. [Engine Setup](#-engine-setup)
59
- 4. [Querying Data](#-querying-data)
60
- 5. [Filtering](#-filtering)
61
- 6. [Search](#-search)
62
- 7. [Aggregations](#-aggregations)
63
- 8. [Write Operations](#-write-operations)
64
- 9. [Advanced Features](#-advanced-features)
65
- 10. [Async Operations](#-async-operations)
72
+ | Section | What you'll find |
73
+ |--------|-------------------|
74
+ | [Getting Started](#-getting-started) | Prerequisites and example schema |
75
+ | [Model Definition](#-model-definition) | Views as Pydantic models, aliases, config |
76
+ | [Engine Setup](#-engine-setup) | Config file or manual `Engine` / `AsyncEngine` |
77
+ | [Querying Data](#-querying-data) | `select()`, pagination, sorting, validation |
78
+ | [Filtering](#-filtering) | Comparison, list, string, nested, and edge filters |
79
+ | [Search](#-search) | Full-text search with filters |
80
+ | [Aggregations](#-aggregations) | Count, sum, avg, min, max, with grouping |
81
+ | [Write Operations](#-write-operations) | Upsert and delete |
82
+ | [Advanced Features](#-advanced-features) | ID generation, `InstanceId`, result helpers |
83
+ | [Async Operations](#-async-operations) | `AsyncEngine` and async API |
66
84
 
67
85
  ---
68
86
 
69
87
  ## 🚀 Getting Started
70
88
 
71
- This guide uses the `CogniteAsset` view from the `CogniteCore` data model (version `v1`) as an example.
89
+ The quick example above shows the core flow: **model → engine → query**. The rest of this guide uses the `CogniteAsset` view from the `CogniteCore` data model (version `v1`).
72
90
 
73
91
  ### Sample GraphQL Schema
74
92
 
@@ -87,6 +105,8 @@ type CogniteAsset {
87
105
 
88
106
  ## 🏗️ Model Definition
89
107
 
108
+ Models map CDF views to Python classes. Inherit from `ViewInstance` (or `WritableViewInstance` for writes) and declare only the properties you need.
109
+
90
110
  ### Basic Model
91
111
 
92
112
  Define your model by inheriting from `ViewInstance` and adding only the properties you need:
@@ -186,6 +206,8 @@ class CogniteAssetByName(AggregatedViewInstance):
186
206
 
187
207
  ## ⚙️ Engine Setup
188
208
 
209
+ The engine connects to CDF and knows which data model and version to use. You can load it from a config file or build it from an existing `CogniteClient`.
210
+
189
211
  ### Option A: From Configuration File
190
212
 
191
213
  Create a `cognite-sdk-config.yaml` file:
@@ -251,6 +273,8 @@ async_engine = AsyncEngine.from_config_file(Path("cognite-sdk-config.yaml"))
251
273
 
252
274
  ## 🔎 Querying Data
253
275
 
276
+ Use `select()` to build statements, then run them with `engine.query()` or `engine.query_all_pages()`. Results are typed and paginated.
277
+
254
278
  ### Basic Query
255
279
 
256
280
  ```python
@@ -322,6 +346,8 @@ results = engine.query(statement, validation_mode="ignoreOnError")
322
346
 
323
347
  ## 🔍 Filtering
324
348
 
349
+ Add `.where(...)` to narrow results. Use `col()` for operators like `in_()`, `prefix()`, and `nested_()`; use `==`, `!=`, `&`, and `|` where they apply.
350
+
325
351
  ### Comparison Operators
326
352
 
327
353
  ```python
@@ -535,6 +561,8 @@ statement = select(CogniteAsset).where(
535
561
 
536
562
  ## 🔍 Search
537
563
 
564
+ Full-text search over view instances. Combine `search()` with `.where()` filters and `.query_by()` to search specific properties.
565
+
538
566
  ### Search with Filters
539
567
 
540
568
  ```python
@@ -604,6 +632,8 @@ results = engine.search(search_statement)
604
632
 
605
633
  ## 📊 Aggregations
606
634
 
635
+ Use `AggregatedViewInstance` and `aggregate()` for count, sum, avg, min, and max—optionally with `.group_by()` and `.where()`.
636
+
607
637
  ### Count Aggregation
608
638
 
609
639
  ```python
@@ -722,6 +752,8 @@ results = engine.aggregate(statement)
722
752
 
723
753
  ## ✏️ Write Operations
724
754
 
755
+ Use `WritableViewInstance` and implement `edge_id_factory` for models with relationships. Then `engine.upsert()` and `engine.delete()` work on lists of instances.
756
+
725
757
  ### Upsert Instances
726
758
 
727
759
  ```python
@@ -804,6 +836,7 @@ engine.delete(instances_to_delete)
804
836
 
805
837
  ## 🚀 Advanced Features
806
838
 
839
+ Utilities for ID generation, `InstanceId` handling, and working with `PaginatedResult`.
807
840
 
808
841
  ### Generate Model IDs
809
842
 
@@ -884,7 +917,7 @@ if result.has_next_page:
884
917
 
885
918
  ## ⚡ Async Operations
886
919
 
887
- All engine methods have async equivalents:
920
+ Use `AsyncEngine` for async code. Every sync method has an `_async` counterpart (e.g. `query_async`, `upsert_async`).
888
921
 
889
922
  ### AsyncEngine Setup
890
923
 
@@ -955,7 +988,7 @@ asyncio.run(main())
955
988
 
956
989
  ## 📝 Complete Example
957
990
 
958
- Here's a complete example demonstrating multiple features:
991
+ Putting it together: query with filters, search, aggregate, upsert, and delete in one script.
959
992
 
960
993
  ```python
961
994
  from industrial_model import (
@@ -1058,7 +1091,7 @@ engine.delete(obsolete)
1058
1091
 
1059
1092
  ## 🎯 Best Practices
1060
1093
 
1061
- 1. **Model Definition**: Only include fields you actually need in your models
1094
+ 1. **Models** Declare only the fields you use; smaller models stay clearer and faster
1062
1095
  2. **View Configuration**: Use `instance_spaces` or `instance_spaces_prefix` to optimize queries
1063
1096
  3. **Pagination**: Use `query_all_pages()` for small datasets, `query()` with cursors for large datasets
1064
1097
  4. **Validation**: Use `ignoreOnError` mode when dealing with potentially inconsistent data
@@ -30,7 +30,7 @@ industrial_model/queries/params.py,sha256=50qY5BO5onLsXorhcv-7qCKhJaMO94UzhKLCmZ
30
30
  industrial_model/queries/utils.py,sha256=uP6PLh9IVHDK6J8x444zHWPmyV4PkxdLO-PMc6qWItc,1505
31
31
  industrial_model/statements/__init__.py,sha256=xazAVHvN8HKsWcXR2Hp1aGxd59stg13JXO6tgpJnsC4,5660
32
32
  industrial_model/statements/expressions.py,sha256=4ZZOcZroI5-4xRw4PXIRlufi0ARndE5zSbbxLDpR2Ec,4816
33
- industrial_model-1.2.2.dist-info/METADATA,sha256=X_mVQqlQjoqff94wACeDJ11KPCgJ3gJk6Jxx5EtXDEY,26780
34
- industrial_model-1.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- industrial_model-1.2.2.dist-info/licenses/LICENSE,sha256=BCHCZ1Qo7m4YvAEIQqtVBI3NebFJdZ8_7m_cxInIlN0,4934
36
- industrial_model-1.2.2.dist-info/RECORD,,
33
+ industrial_model-1.2.4.dist-info/METADATA,sha256=By6k1IXT8Y09TlXsuGk4xwv5CAiJ9S0CeWgjRHDYyOs,29043
34
+ industrial_model-1.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
35
+ industrial_model-1.2.4.dist-info/licenses/LICENSE,sha256=BCHCZ1Qo7m4YvAEIQqtVBI3NebFJdZ8_7m_cxInIlN0,4934
36
+ industrial_model-1.2.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any