industrial-model 0.1.24__tar.gz → 0.1.26__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.24 → industrial_model-0.1.26}/PKG-INFO +1 -1
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/queries/models.py +5 -5
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/queries/params.py +16 -4
- {industrial_model-0.1.24 → industrial_model-0.1.26}/pyproject.toml +5 -1
- industrial_model-0.1.24/.python-version +0 -1
- industrial_model-0.1.24/scripts/build.sh +0 -4
- industrial_model-0.1.24/scripts/format.sh +0 -2
- industrial_model-0.1.24/scripts/lint.sh +0 -3
- industrial_model-0.1.24/scripts/publish.sh +0 -2
- industrial_model-0.1.24/tests/__init__.py +0 -0
- industrial_model-0.1.24/tests/cognite-sdk-config.yaml +0 -15
- industrial_model-0.1.24/tests/hubs.py +0 -37
- industrial_model-0.1.24/tests/models.py +0 -92
- industrial_model-0.1.24/tests/test_schema.py +0 -350
- industrial_model-0.1.24/tests/tests_adapter.py +0 -42
- industrial_model-0.1.24/tests/tests_aggregate.py +0 -19
- industrial_model-0.1.24/tests/tests_search.py +0 -28
- industrial_model-0.1.24/tests/tests_upsert_mapper.py +0 -37
- industrial_model-0.1.24/uv.lock +0 -618
- {industrial_model-0.1.24 → industrial_model-0.1.26}/.gitignore +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/README.md +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/aggregation_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/filter_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/models.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/optimizer.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/query_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/query_result_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/search_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/sort_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/upsert_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/utils.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/cognite_adapters/view_mapper.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/config.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/constants.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/engines/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/engines/async_engine.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/engines/engine.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/models/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/models/base.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/models/entities.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/models/schemas.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/py.typed +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/queries/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/statements/__init__.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/statements/expressions.py +0 -0
- {industrial_model-0.1.24 → industrial_model-0.1.26}/industrial_model/utils.py +0 -0
|
@@ -18,7 +18,7 @@ class BaseQuery(RootModel):
|
|
|
18
18
|
|
|
19
19
|
for key, item in self.__class__.model_fields.items():
|
|
20
20
|
values = getattr(self, key)
|
|
21
|
-
if
|
|
21
|
+
if values is None:
|
|
22
22
|
continue
|
|
23
23
|
for metadata_item in item.metadata:
|
|
24
24
|
if isinstance(metadata_item, SortParam):
|
|
@@ -43,7 +43,7 @@ class BasePaginatedQuery(BaseQuery):
|
|
|
43
43
|
|
|
44
44
|
class BaseSearchQuery(RootModel):
|
|
45
45
|
query: str | None = None
|
|
46
|
-
query_properties: list[
|
|
46
|
+
query_properties: list[Any] | None = None
|
|
47
47
|
limit: int = 1000
|
|
48
48
|
|
|
49
49
|
def to_statement(
|
|
@@ -53,7 +53,7 @@ class BaseSearchQuery(RootModel):
|
|
|
53
53
|
|
|
54
54
|
for key, item in self.__class__.model_fields.items():
|
|
55
55
|
values = getattr(self, key)
|
|
56
|
-
if
|
|
56
|
+
if values is None:
|
|
57
57
|
continue
|
|
58
58
|
for metadata_item in item.metadata:
|
|
59
59
|
if isinstance(metadata_item, SortParam):
|
|
@@ -69,7 +69,7 @@ class BaseSearchQuery(RootModel):
|
|
|
69
69
|
|
|
70
70
|
class BaseAggregationQuery(RootModel):
|
|
71
71
|
aggregate: AggregateTypes | None = None
|
|
72
|
-
group_by_properties: list[
|
|
72
|
+
group_by_properties: list[Any] | None = None
|
|
73
73
|
aggregation_property: str | None = None
|
|
74
74
|
limit: int | None = None
|
|
75
75
|
|
|
@@ -80,7 +80,7 @@ class BaseAggregationQuery(RootModel):
|
|
|
80
80
|
|
|
81
81
|
for key, item in self.__class__.model_fields.items():
|
|
82
82
|
values = getattr(self, key)
|
|
83
|
-
if
|
|
83
|
+
if values is None:
|
|
84
84
|
continue
|
|
85
85
|
for metadata_item in item.metadata:
|
|
86
86
|
if isinstance(metadata_item, QueryParam | NestedQueryParam):
|
|
@@ -5,7 +5,7 @@ from industrial_model.constants import (
|
|
|
5
5
|
LEAF_EXPRESSION_OPERATORS,
|
|
6
6
|
SORT_DIRECTION,
|
|
7
7
|
)
|
|
8
|
-
from industrial_model.statements import LeafExpression
|
|
8
|
+
from industrial_model.statements import BoolExpression, Expression, LeafExpression
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@dataclass
|
|
@@ -13,9 +13,21 @@ class QueryParam:
|
|
|
13
13
|
property: str
|
|
14
14
|
operator: LEAF_EXPRESSION_OPERATORS
|
|
15
15
|
|
|
16
|
-
def to_expression(self, value: Any) ->
|
|
16
|
+
def to_expression(self, value: Any) -> Expression:
|
|
17
17
|
if self.operator == "nested":
|
|
18
|
-
raise ValueError(
|
|
18
|
+
raise ValueError(
|
|
19
|
+
"Nested operator not allowed in QueryParam - use NestedQueryParam"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
if self.operator == "exists" and isinstance(value, bool) and not value:
|
|
23
|
+
return BoolExpression(
|
|
24
|
+
operator="not",
|
|
25
|
+
filters=[
|
|
26
|
+
LeafExpression(
|
|
27
|
+
property=self.property, operator=self.operator, value=True
|
|
28
|
+
)
|
|
29
|
+
],
|
|
30
|
+
)
|
|
19
31
|
|
|
20
32
|
return LeafExpression(
|
|
21
33
|
property=self.property,
|
|
@@ -29,7 +41,7 @@ class NestedQueryParam:
|
|
|
29
41
|
property: str
|
|
30
42
|
value: QueryParam
|
|
31
43
|
|
|
32
|
-
def to_expression(self, value: Any) ->
|
|
44
|
+
def to_expression(self, value: Any) -> Expression:
|
|
33
45
|
return LeafExpression(
|
|
34
46
|
property=self.property,
|
|
35
47
|
operator="nested",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "industrial-model"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.26"
|
|
4
4
|
description = "Industrial Model ORM"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -22,6 +22,10 @@ classifiers = [
|
|
|
22
22
|
requires = ["hatchling >= 1.27"]
|
|
23
23
|
build-backend = "hatchling.build"
|
|
24
24
|
|
|
25
|
+
[tool.hatch.build]
|
|
26
|
+
packages = ["industrial_model"]
|
|
27
|
+
|
|
28
|
+
|
|
25
29
|
[tool.uv]
|
|
26
30
|
dev-dependencies = [
|
|
27
31
|
"dotenv>=0.9.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.11
|
|
File without changes
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
cognite:
|
|
2
|
-
project: "${CDF_PROJECT}"
|
|
3
|
-
client_name: "${CDF_CLIENT_NAME}"
|
|
4
|
-
base_url: "https://${CDF_CLUSTER}.cognitedata.com"
|
|
5
|
-
credentials:
|
|
6
|
-
client_credentials:
|
|
7
|
-
token_url: "${CDF_TOKEN_URL}"
|
|
8
|
-
client_id: "${CDF_CLIENT_ID}"
|
|
9
|
-
client_secret: "${CDF_CLIENT_SECRET}"
|
|
10
|
-
scopes: ["https://${CDF_CLUSTER}.cognitedata.com/.default"]
|
|
11
|
-
|
|
12
|
-
data_model:
|
|
13
|
-
external_id: "${CDF_DATA_MODEL_EXTERNAL_ID}"
|
|
14
|
-
space: "${CDF_DATA_MODEL_SPACE}"
|
|
15
|
-
version: "${CDF_DATA_MODEL_VERSION}"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from string import Template
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
import yaml
|
|
7
|
-
from cognite.client import CogniteClient
|
|
8
|
-
from dotenv import load_dotenv
|
|
9
|
-
|
|
10
|
-
from industrial_model import DataModelId, Engine
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def generate_config(
|
|
14
|
-
config_file_path: str | None = None,
|
|
15
|
-
) -> dict[str, dict[str, Any]]:
|
|
16
|
-
load_dotenv(override=True)
|
|
17
|
-
file_path = Path(
|
|
18
|
-
config_file_path or f"{os.path.dirname(__file__)}/cognite-sdk-config.yaml"
|
|
19
|
-
)
|
|
20
|
-
env_sub_template = Template(file_path.read_text())
|
|
21
|
-
file_env_parsed = env_sub_template.substitute(dict(os.environ))
|
|
22
|
-
|
|
23
|
-
value = yaml.safe_load(file_env_parsed)
|
|
24
|
-
|
|
25
|
-
assert isinstance(value, dict)
|
|
26
|
-
return value
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def generate_engine(config_file_path: str | None = None) -> Engine:
|
|
30
|
-
cognite_config = generate_config(config_file_path)
|
|
31
|
-
client = CogniteClient.load(cognite_config["cognite"])
|
|
32
|
-
|
|
33
|
-
client.config.timeout = 60
|
|
34
|
-
print(client.config)
|
|
35
|
-
|
|
36
|
-
dm_id = DataModelId.model_validate(cognite_config["data_model"])
|
|
37
|
-
return Engine(client, dm_id)
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
from typing import Annotated
|
|
3
|
-
|
|
4
|
-
from pydantic import Field
|
|
5
|
-
|
|
6
|
-
from industrial_model import (
|
|
7
|
-
InstanceId,
|
|
8
|
-
ViewInstance,
|
|
9
|
-
ViewInstanceConfig,
|
|
10
|
-
WritableViewInstance,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class DescribableEntity(ViewInstance):
|
|
15
|
-
name: str | None = None
|
|
16
|
-
description: str | None = None
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class ReportingSite(DescribableEntity):
|
|
20
|
-
time_zone: DescribableEntity | None = None
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class EventDetail(ViewInstance):
|
|
24
|
-
ref_metric_code: DescribableEntity | None = None
|
|
25
|
-
ref_event_code: DescribableEntity | None = None
|
|
26
|
-
ref_sub_category_l1: DescribableEntity | None = None
|
|
27
|
-
ref_sub_category_l2: DescribableEntity | None = None
|
|
28
|
-
ref_sub_category_l3: DescribableEntity | None = None
|
|
29
|
-
ref_sub_category_l4: DescribableEntity | None = None
|
|
30
|
-
ref_sub_category_l5: DescribableEntity | None = None
|
|
31
|
-
ref_equipment: DescribableEntity | None = None
|
|
32
|
-
ref_discipline: DescribableEntity | None = None
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class Event(ViewInstance):
|
|
36
|
-
view_config = ViewInstanceConfig(
|
|
37
|
-
view_external_id="OEEEvent",
|
|
38
|
-
instance_spaces_prefix="OEE-",
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
start_date_time: datetime.datetime | None = None
|
|
42
|
-
ref_site: ReportingSite | None = None
|
|
43
|
-
ref_unit: DescribableEntity | None = None
|
|
44
|
-
ref_reporting_line: DescribableEntity | None = None
|
|
45
|
-
ref_reporting_location: DescribableEntity | None = None
|
|
46
|
-
ref_product: DescribableEntity | None = None
|
|
47
|
-
ref_material: DescribableEntity | None = None
|
|
48
|
-
ref_process_type: DescribableEntity | None = None
|
|
49
|
-
ref_oee_event_detail: Annotated[
|
|
50
|
-
list[EventDetail],
|
|
51
|
-
Field(default_factory=list, alias="refOEEEventDetail"),
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
class SearchEvent(ViewInstance):
|
|
56
|
-
view_config = ViewInstanceConfig(view_external_id="OEEEvent")
|
|
57
|
-
|
|
58
|
-
start_date_time: datetime.datetime
|
|
59
|
-
event_definition: str
|
|
60
|
-
ref_site: InstanceId
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class Msdp(ViewInstance):
|
|
64
|
-
view_config = ViewInstanceConfig(
|
|
65
|
-
view_external_id="OEEMSDP",
|
|
66
|
-
instance_spaces_prefix="OEE-",
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
effective_date: datetime.date
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
class WritableEvent(WritableViewInstance):
|
|
73
|
-
view_config = ViewInstanceConfig(
|
|
74
|
-
view_external_id="OEEEvent",
|
|
75
|
-
instance_spaces_prefix="OEE-",
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
start_date_time: datetime.datetime | None = None
|
|
79
|
-
ref_site: ReportingSite | None = None
|
|
80
|
-
ref_reporting_line: DescribableEntity | None = None
|
|
81
|
-
ref_oee_event_detail: Annotated[
|
|
82
|
-
list[EventDetail],
|
|
83
|
-
Field(default_factory=list, alias="refOEEEventDetail"),
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
def edge_id_factory(
|
|
87
|
-
self, target_node: InstanceId, edge_type: InstanceId
|
|
88
|
-
) -> InstanceId:
|
|
89
|
-
return InstanceId(
|
|
90
|
-
external_id=f"{self.external_id}-{target_node.external_id}-{edge_type.external_id}",
|
|
91
|
-
space=self.space,
|
|
92
|
-
)
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
from pydantic import BaseModel
|
|
2
|
-
|
|
3
|
-
from industrial_model.models import get_schema_properties
|
|
4
|
-
from tests.models import (
|
|
5
|
-
DescribableEntity,
|
|
6
|
-
Event,
|
|
7
|
-
EventDetail,
|
|
8
|
-
Msdp,
|
|
9
|
-
ReportingSite,
|
|
10
|
-
WritableEvent,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
SEP = "|"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class _Car(BaseModel):
|
|
17
|
-
model: str
|
|
18
|
-
year: int
|
|
19
|
-
owner: "SuperNestedModel"
|
|
20
|
-
previous_owners: list["SuperNestedModel"] | None
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class SuperNestedModel(DescribableEntity):
|
|
24
|
-
parent: "SuperNestedModel"
|
|
25
|
-
children: list["SuperNestedModel"]
|
|
26
|
-
cars: list[_Car] | None
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def test_get_schema_properties() -> None:
|
|
30
|
-
for entity, expected_schema in _get_test_schema().items():
|
|
31
|
-
schema = get_schema_properties(entity, SEP)
|
|
32
|
-
assert schema == expected_schema, f"Expected {expected_schema}, got {schema}"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def _get_test_schema() -> dict[type[BaseModel], list[str]]:
|
|
36
|
-
return {
|
|
37
|
-
Msdp: ["effectiveDate", "externalId", "space"],
|
|
38
|
-
DescribableEntity: ["description", "externalId", "name", "space"],
|
|
39
|
-
ReportingSite: [
|
|
40
|
-
"description",
|
|
41
|
-
"externalId",
|
|
42
|
-
"name",
|
|
43
|
-
"space",
|
|
44
|
-
"timeZone",
|
|
45
|
-
"timeZone|description",
|
|
46
|
-
"timeZone|externalId",
|
|
47
|
-
"timeZone|name",
|
|
48
|
-
"timeZone|space",
|
|
49
|
-
],
|
|
50
|
-
EventDetail: [
|
|
51
|
-
"externalId",
|
|
52
|
-
"refDiscipline",
|
|
53
|
-
"refDiscipline|description",
|
|
54
|
-
"refDiscipline|externalId",
|
|
55
|
-
"refDiscipline|name",
|
|
56
|
-
"refDiscipline|space",
|
|
57
|
-
"refEquipment",
|
|
58
|
-
"refEquipment|description",
|
|
59
|
-
"refEquipment|externalId",
|
|
60
|
-
"refEquipment|name",
|
|
61
|
-
"refEquipment|space",
|
|
62
|
-
"refEventCode",
|
|
63
|
-
"refEventCode|description",
|
|
64
|
-
"refEventCode|externalId",
|
|
65
|
-
"refEventCode|name",
|
|
66
|
-
"refEventCode|space",
|
|
67
|
-
"refMetricCode",
|
|
68
|
-
"refMetricCode|description",
|
|
69
|
-
"refMetricCode|externalId",
|
|
70
|
-
"refMetricCode|name",
|
|
71
|
-
"refMetricCode|space",
|
|
72
|
-
"refSubCategoryL1",
|
|
73
|
-
"refSubCategoryL1|description",
|
|
74
|
-
"refSubCategoryL1|externalId",
|
|
75
|
-
"refSubCategoryL1|name",
|
|
76
|
-
"refSubCategoryL1|space",
|
|
77
|
-
"refSubCategoryL2",
|
|
78
|
-
"refSubCategoryL2|description",
|
|
79
|
-
"refSubCategoryL2|externalId",
|
|
80
|
-
"refSubCategoryL2|name",
|
|
81
|
-
"refSubCategoryL2|space",
|
|
82
|
-
"refSubCategoryL3",
|
|
83
|
-
"refSubCategoryL3|description",
|
|
84
|
-
"refSubCategoryL3|externalId",
|
|
85
|
-
"refSubCategoryL3|name",
|
|
86
|
-
"refSubCategoryL3|space",
|
|
87
|
-
"refSubCategoryL4",
|
|
88
|
-
"refSubCategoryL4|description",
|
|
89
|
-
"refSubCategoryL4|externalId",
|
|
90
|
-
"refSubCategoryL4|name",
|
|
91
|
-
"refSubCategoryL4|space",
|
|
92
|
-
"refSubCategoryL5",
|
|
93
|
-
"refSubCategoryL5|description",
|
|
94
|
-
"refSubCategoryL5|externalId",
|
|
95
|
-
"refSubCategoryL5|name",
|
|
96
|
-
"refSubCategoryL5|space",
|
|
97
|
-
"space",
|
|
98
|
-
],
|
|
99
|
-
Event: [
|
|
100
|
-
"externalId",
|
|
101
|
-
"refMaterial",
|
|
102
|
-
"refMaterial|description",
|
|
103
|
-
"refMaterial|externalId",
|
|
104
|
-
"refMaterial|name",
|
|
105
|
-
"refMaterial|space",
|
|
106
|
-
"refOEEEventDetail",
|
|
107
|
-
"refOEEEventDetail|externalId",
|
|
108
|
-
"refOEEEventDetail|refDiscipline",
|
|
109
|
-
"refOEEEventDetail|refDiscipline|description",
|
|
110
|
-
"refOEEEventDetail|refDiscipline|externalId",
|
|
111
|
-
"refOEEEventDetail|refDiscipline|name",
|
|
112
|
-
"refOEEEventDetail|refDiscipline|space",
|
|
113
|
-
"refOEEEventDetail|refEquipment",
|
|
114
|
-
"refOEEEventDetail|refEquipment|description",
|
|
115
|
-
"refOEEEventDetail|refEquipment|externalId",
|
|
116
|
-
"refOEEEventDetail|refEquipment|name",
|
|
117
|
-
"refOEEEventDetail|refEquipment|space",
|
|
118
|
-
"refOEEEventDetail|refEventCode",
|
|
119
|
-
"refOEEEventDetail|refEventCode|description",
|
|
120
|
-
"refOEEEventDetail|refEventCode|externalId",
|
|
121
|
-
"refOEEEventDetail|refEventCode|name",
|
|
122
|
-
"refOEEEventDetail|refEventCode|space",
|
|
123
|
-
"refOEEEventDetail|refMetricCode",
|
|
124
|
-
"refOEEEventDetail|refMetricCode|description",
|
|
125
|
-
"refOEEEventDetail|refMetricCode|externalId",
|
|
126
|
-
"refOEEEventDetail|refMetricCode|name",
|
|
127
|
-
"refOEEEventDetail|refMetricCode|space",
|
|
128
|
-
"refOEEEventDetail|refSubCategoryL1",
|
|
129
|
-
"refOEEEventDetail|refSubCategoryL1|description",
|
|
130
|
-
"refOEEEventDetail|refSubCategoryL1|externalId",
|
|
131
|
-
"refOEEEventDetail|refSubCategoryL1|name",
|
|
132
|
-
"refOEEEventDetail|refSubCategoryL1|space",
|
|
133
|
-
"refOEEEventDetail|refSubCategoryL2",
|
|
134
|
-
"refOEEEventDetail|refSubCategoryL2|description",
|
|
135
|
-
"refOEEEventDetail|refSubCategoryL2|externalId",
|
|
136
|
-
"refOEEEventDetail|refSubCategoryL2|name",
|
|
137
|
-
"refOEEEventDetail|refSubCategoryL2|space",
|
|
138
|
-
"refOEEEventDetail|refSubCategoryL3",
|
|
139
|
-
"refOEEEventDetail|refSubCategoryL3|description",
|
|
140
|
-
"refOEEEventDetail|refSubCategoryL3|externalId",
|
|
141
|
-
"refOEEEventDetail|refSubCategoryL3|name",
|
|
142
|
-
"refOEEEventDetail|refSubCategoryL3|space",
|
|
143
|
-
"refOEEEventDetail|refSubCategoryL4",
|
|
144
|
-
"refOEEEventDetail|refSubCategoryL4|description",
|
|
145
|
-
"refOEEEventDetail|refSubCategoryL4|externalId",
|
|
146
|
-
"refOEEEventDetail|refSubCategoryL4|name",
|
|
147
|
-
"refOEEEventDetail|refSubCategoryL4|space",
|
|
148
|
-
"refOEEEventDetail|refSubCategoryL5",
|
|
149
|
-
"refOEEEventDetail|refSubCategoryL5|description",
|
|
150
|
-
"refOEEEventDetail|refSubCategoryL5|externalId",
|
|
151
|
-
"refOEEEventDetail|refSubCategoryL5|name",
|
|
152
|
-
"refOEEEventDetail|refSubCategoryL5|space",
|
|
153
|
-
"refOEEEventDetail|space",
|
|
154
|
-
"refProcessType",
|
|
155
|
-
"refProcessType|description",
|
|
156
|
-
"refProcessType|externalId",
|
|
157
|
-
"refProcessType|name",
|
|
158
|
-
"refProcessType|space",
|
|
159
|
-
"refProduct",
|
|
160
|
-
"refProduct|description",
|
|
161
|
-
"refProduct|externalId",
|
|
162
|
-
"refProduct|name",
|
|
163
|
-
"refProduct|space",
|
|
164
|
-
"refReportingLine",
|
|
165
|
-
"refReportingLine|description",
|
|
166
|
-
"refReportingLine|externalId",
|
|
167
|
-
"refReportingLine|name",
|
|
168
|
-
"refReportingLine|space",
|
|
169
|
-
"refReportingLocation",
|
|
170
|
-
"refReportingLocation|description",
|
|
171
|
-
"refReportingLocation|externalId",
|
|
172
|
-
"refReportingLocation|name",
|
|
173
|
-
"refReportingLocation|space",
|
|
174
|
-
"refSite",
|
|
175
|
-
"refSite|description",
|
|
176
|
-
"refSite|externalId",
|
|
177
|
-
"refSite|name",
|
|
178
|
-
"refSite|space",
|
|
179
|
-
"refSite|timeZone",
|
|
180
|
-
"refSite|timeZone|description",
|
|
181
|
-
"refSite|timeZone|externalId",
|
|
182
|
-
"refSite|timeZone|name",
|
|
183
|
-
"refSite|timeZone|space",
|
|
184
|
-
"refUnit",
|
|
185
|
-
"refUnit|description",
|
|
186
|
-
"refUnit|externalId",
|
|
187
|
-
"refUnit|name",
|
|
188
|
-
"refUnit|space",
|
|
189
|
-
"space",
|
|
190
|
-
"startDateTime",
|
|
191
|
-
],
|
|
192
|
-
WritableEvent: [
|
|
193
|
-
"externalId",
|
|
194
|
-
"refOEEEventDetail",
|
|
195
|
-
"refOEEEventDetail|externalId",
|
|
196
|
-
"refOEEEventDetail|refDiscipline",
|
|
197
|
-
"refOEEEventDetail|refDiscipline|description",
|
|
198
|
-
"refOEEEventDetail|refDiscipline|externalId",
|
|
199
|
-
"refOEEEventDetail|refDiscipline|name",
|
|
200
|
-
"refOEEEventDetail|refDiscipline|space",
|
|
201
|
-
"refOEEEventDetail|refEquipment",
|
|
202
|
-
"refOEEEventDetail|refEquipment|description",
|
|
203
|
-
"refOEEEventDetail|refEquipment|externalId",
|
|
204
|
-
"refOEEEventDetail|refEquipment|name",
|
|
205
|
-
"refOEEEventDetail|refEquipment|space",
|
|
206
|
-
"refOEEEventDetail|refEventCode",
|
|
207
|
-
"refOEEEventDetail|refEventCode|description",
|
|
208
|
-
"refOEEEventDetail|refEventCode|externalId",
|
|
209
|
-
"refOEEEventDetail|refEventCode|name",
|
|
210
|
-
"refOEEEventDetail|refEventCode|space",
|
|
211
|
-
"refOEEEventDetail|refMetricCode",
|
|
212
|
-
"refOEEEventDetail|refMetricCode|description",
|
|
213
|
-
"refOEEEventDetail|refMetricCode|externalId",
|
|
214
|
-
"refOEEEventDetail|refMetricCode|name",
|
|
215
|
-
"refOEEEventDetail|refMetricCode|space",
|
|
216
|
-
"refOEEEventDetail|refSubCategoryL1",
|
|
217
|
-
"refOEEEventDetail|refSubCategoryL1|description",
|
|
218
|
-
"refOEEEventDetail|refSubCategoryL1|externalId",
|
|
219
|
-
"refOEEEventDetail|refSubCategoryL1|name",
|
|
220
|
-
"refOEEEventDetail|refSubCategoryL1|space",
|
|
221
|
-
"refOEEEventDetail|refSubCategoryL2",
|
|
222
|
-
"refOEEEventDetail|refSubCategoryL2|description",
|
|
223
|
-
"refOEEEventDetail|refSubCategoryL2|externalId",
|
|
224
|
-
"refOEEEventDetail|refSubCategoryL2|name",
|
|
225
|
-
"refOEEEventDetail|refSubCategoryL2|space",
|
|
226
|
-
"refOEEEventDetail|refSubCategoryL3",
|
|
227
|
-
"refOEEEventDetail|refSubCategoryL3|description",
|
|
228
|
-
"refOEEEventDetail|refSubCategoryL3|externalId",
|
|
229
|
-
"refOEEEventDetail|refSubCategoryL3|name",
|
|
230
|
-
"refOEEEventDetail|refSubCategoryL3|space",
|
|
231
|
-
"refOEEEventDetail|refSubCategoryL4",
|
|
232
|
-
"refOEEEventDetail|refSubCategoryL4|description",
|
|
233
|
-
"refOEEEventDetail|refSubCategoryL4|externalId",
|
|
234
|
-
"refOEEEventDetail|refSubCategoryL4|name",
|
|
235
|
-
"refOEEEventDetail|refSubCategoryL4|space",
|
|
236
|
-
"refOEEEventDetail|refSubCategoryL5",
|
|
237
|
-
"refOEEEventDetail|refSubCategoryL5|description",
|
|
238
|
-
"refOEEEventDetail|refSubCategoryL5|externalId",
|
|
239
|
-
"refOEEEventDetail|refSubCategoryL5|name",
|
|
240
|
-
"refOEEEventDetail|refSubCategoryL5|space",
|
|
241
|
-
"refOEEEventDetail|space",
|
|
242
|
-
"refReportingLine",
|
|
243
|
-
"refReportingLine|description",
|
|
244
|
-
"refReportingLine|externalId",
|
|
245
|
-
"refReportingLine|name",
|
|
246
|
-
"refReportingLine|space",
|
|
247
|
-
"refSite",
|
|
248
|
-
"refSite|description",
|
|
249
|
-
"refSite|externalId",
|
|
250
|
-
"refSite|name",
|
|
251
|
-
"refSite|space",
|
|
252
|
-
"refSite|timeZone",
|
|
253
|
-
"refSite|timeZone|description",
|
|
254
|
-
"refSite|timeZone|externalId",
|
|
255
|
-
"refSite|timeZone|name",
|
|
256
|
-
"refSite|timeZone|space",
|
|
257
|
-
"space",
|
|
258
|
-
"startDateTime",
|
|
259
|
-
],
|
|
260
|
-
SuperNestedModel: [
|
|
261
|
-
"cars",
|
|
262
|
-
"cars|model",
|
|
263
|
-
"cars|owner",
|
|
264
|
-
"cars|owner|cars",
|
|
265
|
-
"cars|owner|cars|model",
|
|
266
|
-
"cars|owner|cars|owner",
|
|
267
|
-
"cars|owner|cars|previous_owners",
|
|
268
|
-
"cars|owner|cars|year",
|
|
269
|
-
"cars|owner|children",
|
|
270
|
-
"cars|owner|description",
|
|
271
|
-
"cars|owner|externalId",
|
|
272
|
-
"cars|owner|name",
|
|
273
|
-
"cars|owner|parent",
|
|
274
|
-
"cars|owner|parent|cars",
|
|
275
|
-
"cars|owner|parent|cars|model",
|
|
276
|
-
"cars|owner|parent|cars|owner",
|
|
277
|
-
"cars|owner|parent|cars|previous_owners",
|
|
278
|
-
"cars|owner|parent|cars|year",
|
|
279
|
-
"cars|owner|parent|children",
|
|
280
|
-
"cars|owner|parent|description",
|
|
281
|
-
"cars|owner|parent|externalId",
|
|
282
|
-
"cars|owner|parent|name",
|
|
283
|
-
"cars|owner|parent|parent",
|
|
284
|
-
"cars|owner|parent|parent|cars",
|
|
285
|
-
"cars|owner|parent|parent|cars|model",
|
|
286
|
-
"cars|owner|parent|parent|cars|owner",
|
|
287
|
-
"cars|owner|parent|parent|cars|previous_owners",
|
|
288
|
-
"cars|owner|parent|parent|cars|year",
|
|
289
|
-
"cars|owner|parent|parent|children",
|
|
290
|
-
"cars|owner|parent|parent|description",
|
|
291
|
-
"cars|owner|parent|parent|externalId",
|
|
292
|
-
"cars|owner|parent|parent|name",
|
|
293
|
-
"cars|owner|parent|parent|parent",
|
|
294
|
-
"cars|owner|parent|parent|space",
|
|
295
|
-
"cars|owner|parent|space",
|
|
296
|
-
"cars|owner|space",
|
|
297
|
-
"cars|previous_owners",
|
|
298
|
-
"cars|year",
|
|
299
|
-
"children",
|
|
300
|
-
"children|cars",
|
|
301
|
-
"children|cars|model",
|
|
302
|
-
"children|cars|owner",
|
|
303
|
-
"children|cars|previous_owners",
|
|
304
|
-
"children|cars|year",
|
|
305
|
-
"children|children",
|
|
306
|
-
"children|description",
|
|
307
|
-
"children|externalId",
|
|
308
|
-
"children|name",
|
|
309
|
-
"children|parent",
|
|
310
|
-
"children|parent|cars",
|
|
311
|
-
"children|parent|cars|model",
|
|
312
|
-
"children|parent|cars|owner",
|
|
313
|
-
"children|parent|cars|previous_owners",
|
|
314
|
-
"children|parent|cars|year",
|
|
315
|
-
"children|parent|children",
|
|
316
|
-
"children|parent|description",
|
|
317
|
-
"children|parent|externalId",
|
|
318
|
-
"children|parent|name",
|
|
319
|
-
"children|parent|parent",
|
|
320
|
-
"children|parent|space",
|
|
321
|
-
"children|space",
|
|
322
|
-
"description",
|
|
323
|
-
"externalId",
|
|
324
|
-
"name",
|
|
325
|
-
"parent",
|
|
326
|
-
"parent|cars",
|
|
327
|
-
"parent|cars|model",
|
|
328
|
-
"parent|cars|owner",
|
|
329
|
-
"parent|cars|previous_owners",
|
|
330
|
-
"parent|cars|year",
|
|
331
|
-
"parent|children",
|
|
332
|
-
"parent|description",
|
|
333
|
-
"parent|externalId",
|
|
334
|
-
"parent|name",
|
|
335
|
-
"parent|parent",
|
|
336
|
-
"parent|parent|cars",
|
|
337
|
-
"parent|parent|cars|model",
|
|
338
|
-
"parent|parent|cars|owner",
|
|
339
|
-
"parent|parent|cars|previous_owners",
|
|
340
|
-
"parent|parent|cars|year",
|
|
341
|
-
"parent|parent|children",
|
|
342
|
-
"parent|parent|description",
|
|
343
|
-
"parent|parent|externalId",
|
|
344
|
-
"parent|parent|name",
|
|
345
|
-
"parent|parent|parent",
|
|
346
|
-
"parent|parent|space",
|
|
347
|
-
"parent|space",
|
|
348
|
-
"space",
|
|
349
|
-
],
|
|
350
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
from industrial_model import col, select
|
|
5
|
-
|
|
6
|
-
from .hubs import generate_engine
|
|
7
|
-
from .models import DescribableEntity, Event, Msdp
|
|
8
|
-
|
|
9
|
-
if __name__ == "__main__":
|
|
10
|
-
adapter = generate_engine()
|
|
11
|
-
|
|
12
|
-
filter = (
|
|
13
|
-
col(Event.start_date_time).gt_(datetime.datetime(2025, 3, 1))
|
|
14
|
-
& col(Event.ref_site).nested_(DescribableEntity.external_id == "STS-CLK")
|
|
15
|
-
& (col(Event.start_date_time) < datetime.datetime(2025, 6, 1))
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
statement = select(Event).limit(100).where(filter).asc(Event.start_date_time)
|
|
19
|
-
|
|
20
|
-
result = [
|
|
21
|
-
item.model_dump(mode="json") for item in adapter.query_all_pages(statement)
|
|
22
|
-
]
|
|
23
|
-
print(len(result))
|
|
24
|
-
json.dump(result, open("events.json", "w"), indent=2)
|
|
25
|
-
|
|
26
|
-
result_paginated = adapter.query(statement)
|
|
27
|
-
print(len(result_paginated.data))
|
|
28
|
-
json.dump(
|
|
29
|
-
result_paginated.model_dump(mode="json"),
|
|
30
|
-
open("events_paginated.json", "w"),
|
|
31
|
-
indent=2,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
statement_msdp = (
|
|
35
|
-
select(Msdp).limit(2500).where(Msdp.effective_date >= datetime.date(2022, 5, 1))
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
result_msdp = [
|
|
39
|
-
item.model_dump(mode="json") for item in adapter.query_all_pages(statement_msdp)
|
|
40
|
-
]
|
|
41
|
-
print(len(result_msdp))
|
|
42
|
-
json.dump(result_msdp, open("msdp.json", "w"), indent=2)
|