industrial-model 1.2.2__py3-none-any.whl → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 1.2.2
3
+ Version: 1.2.3
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,37 @@ 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
+ instance_spaces_prefix="instace_data-", # Define the scope of your instance spaces to improve performance.
38
+ )
39
+ name: str
40
+ description: str | None = None
41
+
42
+ engine = Engine.from_config_file(Path("cognite-sdk-config.yaml"))
43
+ results = engine.query(select(Asset).limit(10))
44
+ # results.data → list[Asset], fully typed
45
+ ```
28
46
 
29
47
  ---
30
48
 
31
49
  ## ✨ Features
32
50
 
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
51
+ - **Declarative models** Pydantic-style classes with type hints; only the fields you need
52
+ - **Type-safe queries** Fluent, composable filters with full IDE support
53
+ - **Query, search, aggregate** Standard and paginated queries, full-text search, count/sum/avg/min/max
54
+ - **Rich filtering** Nested queries, edge filters, boolean logic, list/string operators
55
+ - **Read and write** Upsert and delete with edge relationship support
56
+ - **Async** All operations have async equivalents
57
+ - **Configurable validation** Choose how to handle validation errors per request
43
58
 
44
59
  ---
45
60
 
@@ -53,22 +68,24 @@ pip install industrial-model
53
68
 
54
69
  ## 📚 Table of Contents
55
70
 
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)
71
+ | Section | What you'll find |
72
+ |--------|-------------------|
73
+ | [Getting Started](#-getting-started) | Prerequisites and example schema |
74
+ | [Model Definition](#-model-definition) | Views as Pydantic models, aliases, config |
75
+ | [Engine Setup](#-engine-setup) | Config file or manual `Engine` / `AsyncEngine` |
76
+ | [Querying Data](#-querying-data) | `select()`, pagination, sorting, validation |
77
+ | [Filtering](#-filtering) | Comparison, list, string, nested, and edge filters |
78
+ | [Search](#-search) | Full-text search with filters |
79
+ | [Aggregations](#-aggregations) | Count, sum, avg, min, max, with grouping |
80
+ | [Write Operations](#-write-operations) | Upsert and delete |
81
+ | [Advanced Features](#-advanced-features) | ID generation, `InstanceId`, result helpers |
82
+ | [Async Operations](#-async-operations) | `AsyncEngine` and async API |
66
83
 
67
84
  ---
68
85
 
69
86
  ## 🚀 Getting Started
70
87
 
71
- This guide uses the `CogniteAsset` view from the `CogniteCore` data model (version `v1`) as an example.
88
+ 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
89
 
73
90
  ### Sample GraphQL Schema
74
91
 
@@ -87,6 +104,8 @@ type CogniteAsset {
87
104
 
88
105
  ## 🏗️ Model Definition
89
106
 
107
+ Models map CDF views to Python classes. Inherit from `ViewInstance` (or `WritableViewInstance` for writes) and declare only the properties you need.
108
+
90
109
  ### Basic Model
91
110
 
92
111
  Define your model by inheriting from `ViewInstance` and adding only the properties you need:
@@ -186,6 +205,8 @@ class CogniteAssetByName(AggregatedViewInstance):
186
205
 
187
206
  ## ⚙️ Engine Setup
188
207
 
208
+ 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`.
209
+
189
210
  ### Option A: From Configuration File
190
211
 
191
212
  Create a `cognite-sdk-config.yaml` file:
@@ -251,6 +272,8 @@ async_engine = AsyncEngine.from_config_file(Path("cognite-sdk-config.yaml"))
251
272
 
252
273
  ## 🔎 Querying Data
253
274
 
275
+ Use `select()` to build statements, then run them with `engine.query()` or `engine.query_all_pages()`. Results are typed and paginated.
276
+
254
277
  ### Basic Query
255
278
 
256
279
  ```python
@@ -322,6 +345,8 @@ results = engine.query(statement, validation_mode="ignoreOnError")
322
345
 
323
346
  ## 🔍 Filtering
324
347
 
348
+ Add `.where(...)` to narrow results. Use `col()` for operators like `in_()`, `prefix()`, and `nested_()`; use `==`, `!=`, `&`, and `|` where they apply.
349
+
325
350
  ### Comparison Operators
326
351
 
327
352
  ```python
@@ -535,6 +560,8 @@ statement = select(CogniteAsset).where(
535
560
 
536
561
  ## 🔍 Search
537
562
 
563
+ Full-text search over view instances. Combine `search()` with `.where()` filters and `.query_by()` to search specific properties.
564
+
538
565
  ### Search with Filters
539
566
 
540
567
  ```python
@@ -604,6 +631,8 @@ results = engine.search(search_statement)
604
631
 
605
632
  ## 📊 Aggregations
606
633
 
634
+ Use `AggregatedViewInstance` and `aggregate()` for count, sum, avg, min, and max—optionally with `.group_by()` and `.where()`.
635
+
607
636
  ### Count Aggregation
608
637
 
609
638
  ```python
@@ -722,6 +751,8 @@ results = engine.aggregate(statement)
722
751
 
723
752
  ## ✏️ Write Operations
724
753
 
754
+ Use `WritableViewInstance` and implement `edge_id_factory` for models with relationships. Then `engine.upsert()` and `engine.delete()` work on lists of instances.
755
+
725
756
  ### Upsert Instances
726
757
 
727
758
  ```python
@@ -804,6 +835,7 @@ engine.delete(instances_to_delete)
804
835
 
805
836
  ## 🚀 Advanced Features
806
837
 
838
+ Utilities for ID generation, `InstanceId` handling, and working with `PaginatedResult`.
807
839
 
808
840
  ### Generate Model IDs
809
841
 
@@ -884,7 +916,7 @@ if result.has_next_page:
884
916
 
885
917
  ## ⚡ Async Operations
886
918
 
887
- All engine methods have async equivalents:
919
+ Use `AsyncEngine` for async code. Every sync method has an `_async` counterpart (e.g. `query_async`, `upsert_async`).
888
920
 
889
921
  ### AsyncEngine Setup
890
922
 
@@ -955,7 +987,7 @@ asyncio.run(main())
955
987
 
956
988
  ## 📝 Complete Example
957
989
 
958
- Here's a complete example demonstrating multiple features:
990
+ Putting it together: query with filters, search, aggregate, upsert, and delete in one script.
959
991
 
960
992
  ```python
961
993
  from industrial_model import (
@@ -1058,7 +1090,7 @@ engine.delete(obsolete)
1058
1090
 
1059
1091
  ## 🎯 Best Practices
1060
1092
 
1061
- 1. **Model Definition**: Only include fields you actually need in your models
1093
+ 1. **Models** Declare only the fields you use; smaller models stay clearer and faster
1062
1094
  2. **View Configuration**: Use `instance_spaces` or `instance_spaces_prefix` to optimize queries
1063
1095
  3. **Pagination**: Use `query_all_pages()` for small datasets, `query()` with cursors for large datasets
1064
1096
  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.3.dist-info/METADATA,sha256=sVnK17Ksz5sXFP-e9o9IAMFN87fYmIAaZyBWOyb0_qM,28872
34
+ industrial_model-1.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
35
+ industrial_model-1.2.3.dist-info/licenses/LICENSE,sha256=BCHCZ1Qo7m4YvAEIQqtVBI3NebFJdZ8_7m_cxInIlN0,4934
36
+ industrial_model-1.2.3.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