industrial-model 0.1.34__py3-none-any.whl → 0.1.35__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.
@@ -55,3 +55,14 @@ class RootModel(BaseModel):
55
55
  return key
56
56
 
57
57
  return None
58
+
59
+ def get_field_alias(self, field_name_or_alias: str) -> str | None:
60
+ entry = self.__class__.model_fields.get(field_name_or_alias)
61
+ if entry:
62
+ return entry.alias
63
+
64
+ for _, field_info in self.__class__.model_fields.items():
65
+ if field_info.alias == field_name_or_alias:
66
+ return field_info.alias
67
+
68
+ return None
@@ -1,5 +1,5 @@
1
1
  from abc import abstractmethod
2
- from datetime import date, datetime
2
+ from datetime import UTC, date, datetime
3
3
  from typing import (
4
4
  Any,
5
5
  ClassVar,
@@ -9,7 +9,7 @@ from typing import (
9
9
  TypeVar,
10
10
  )
11
11
 
12
- from pydantic import PrivateAttr
12
+ from pydantic import PrivateAttr, computed_field
13
13
 
14
14
  from industrial_model.statements import Column
15
15
 
@@ -39,6 +39,18 @@ class EdgeContainer(InstanceId):
39
39
  type: InstanceId
40
40
  start_node: InstanceId
41
41
  end_node: InstanceId
42
+ last_updated_time: int
43
+ created_time: int
44
+
45
+ @computed_field # type: ignore[prop-decorator]
46
+ @property
47
+ def created_time_as_datetime(self) -> datetime:
48
+ return datetime.fromtimestamp(self.created_time / 1000, tz=UTC)
49
+
50
+ @computed_field # type: ignore[prop-decorator]
51
+ @property
52
+ def last_updated_time_as_datetime(self) -> datetime:
53
+ return datetime.fromtimestamp(self.last_updated_time / 1000, tz=UTC)
42
54
 
43
55
 
44
56
  TInstanceId = TypeVar("TInstanceId", bound=InstanceId)
@@ -60,6 +72,19 @@ class ViewInstance(InstanceId):
60
72
  def get_view_external_id(cls) -> str:
61
73
  return cls.view_config.get("view_external_id") or cls.__name__
62
74
 
75
+ def get_edge_metadata(self, property: Column | str | Any) -> list[EdgeContainer]:
76
+ assert isinstance(property, Column | str), (
77
+ f"Expected property to be Column, or str, got {type(property).__name__}"
78
+ )
79
+ identifier = property.property if isinstance(property, Column) else property
80
+
81
+ edge_map_key = self.get_field_alias(identifier) or self.get_field_name(
82
+ identifier
83
+ )
84
+ if not edge_map_key:
85
+ return []
86
+ return self._edges.get(edge_map_key, [])
87
+
63
88
  def generate_model_id(
64
89
  self,
65
90
  fields: list[str] | list[Column] | list[Any],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: industrial-model
3
- Version: 0.1.34
3
+ Version: 0.1.35
4
4
  Summary: Industrial Model ORM
5
5
  Author-email: Lucas Alves <lucasrosaalves@gmail.com>
6
6
  Classifier: Programming Language :: Python
@@ -19,8 +19,8 @@ industrial_model/engines/__init__.py,sha256=7aGHrUm2MxIq39vR8h0xu3i1zNOuT9H9U-q4
19
19
  industrial_model/engines/async_engine.py,sha256=-sQv2vn93bBmTZOxY_C1r40YP7IMl1ND2gCN2GE9BqY,2188
20
20
  industrial_model/engines/engine.py,sha256=Pwg8A3PFVdRExiLGyhcs8hhiGyKgKi6piOmiLgvCL50,3810
21
21
  industrial_model/models/__init__.py,sha256=AzJ0CyPK5PvUCX45FFtybl13tkukUvk2UAF_90s_LQ8,742
22
- industrial_model/models/base.py,sha256=iGhDjXqA5ULEQIFHtkMi7WYJl0nQq1wi8_zqOr-Ep78,1649
23
- industrial_model/models/entities.py,sha256=XugtGFCJrHnxR4UX7FWFumB2tNZGB7mNjM4skznnmdQ,4704
22
+ industrial_model/models/base.py,sha256=qi44m0KW9KuXKTSJqSLea1poErBeAqm6Hv08VdRYHkU,2023
23
+ industrial_model/models/entities.py,sha256=-Jf7bNCijbS3_wZohlog3bRsAkXvkUeAQW9DamJqGFo,5700
24
24
  industrial_model/models/schemas.py,sha256=EoLK9GYdS-0DQ98myTP3wOU9YpWIJOfDSLOYZUy3xEY,4559
25
25
  industrial_model/queries/__init__.py,sha256=lA83zOxMRgBgkseWJgK9kCr1vD8D8iSWs9NGGRnoYKk,355
26
26
  industrial_model/queries/models.py,sha256=VK69c4L0b0miPrKvOQBB8A01SPxZXYThrquv6gw5OGY,2544
@@ -28,6 +28,6 @@ industrial_model/queries/params.py,sha256=50qY5BO5onLsXorhcv-7qCKhJaMO94UzhKLCmZ
28
28
  industrial_model/queries/utils.py,sha256=uP6PLh9IVHDK6J8x444zHWPmyV4PkxdLO-PMc6qWItc,1505
29
29
  industrial_model/statements/__init__.py,sha256=3Et9PM7AMbIS7Fh9051Q0u3qUpX6588d1yuNrvdd4wI,5429
30
30
  industrial_model/statements/expressions.py,sha256=4ZZOcZroI5-4xRw4PXIRlufi0ARndE5zSbbxLDpR2Ec,4816
31
- industrial_model-0.1.34.dist-info/METADATA,sha256=9rtluwI-0-GwC1dqVlIUaCSPL8jdx6DNEVSIXhJ0qVU,6858
32
- industrial_model-0.1.34.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
33
- industrial_model-0.1.34.dist-info/RECORD,,
31
+ industrial_model-0.1.35.dist-info/METADATA,sha256=sKHvIearHLTa1i63nxbkpD2U7guTDl3FVSNPZIKDx2Q,6858
32
+ industrial_model-0.1.35.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
33
+ industrial_model-0.1.35.dist-info/RECORD,,