gw_data 0.3.0__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.
- gw_data/__init__.py +4 -0
- gw_data/config.py +19 -0
- gw_data/db/__init__.py +0 -0
- gw_data/db/models/__init__.py +37 -0
- gw_data/db/models/_base.py +5 -0
- gw_data/db/models/connectivity_edge.py +80 -0
- gw_data/db/models/customer.py +18 -0
- gw_data/db/models/g_node.py +83 -0
- gw_data/db/models/installation.py +52 -0
- gw_data/db/models/installer.py +17 -0
- gw_data/db/models/message.py +51 -0
- gw_data/db/models/position_point.py +46 -0
- gw_data/db/models/reading.py +55 -0
- gw_data/db/models/reading_channel.py +62 -0
- gw_data/db/models/user.py +35 -0
- gw_data/db/models/user_installation_role.py +38 -0
- gw_data/db/scripts/0_db_create.psql +4 -0
- gw_data/db/scripts/1_db_user_setup.psql +16 -0
- gw_data/db/scripts/2_db_schema_setup.sql +11 -0
- gw_data/db/scripts/3_db_alembic_upgrade.sh +2 -0
- gw_data/db/scripts/4_db_seed.py +129 -0
- gw_data/db/scripts/_XX_drop_all.sql +13 -0
- gw_data/db/scripts/seed_data/homes.csv +6 -0
- gw_data/db/session.py +0 -0
- gw_data/sema/__init__.py +15 -0
- gw_data/sema/base.py +184 -0
- gw_data/sema/codec.py +168 -0
- gw_data/sema/definitions/enums/base.g.node.class/000.yaml +55 -0
- gw_data/sema/definitions/enums/g.node.status/000.yaml +35 -0
- gw_data/sema/definitions/formats/left.right.dot.yaml +27 -0
- gw_data/sema/definitions/formats/uuid4.str.yaml +29 -0
- gw_data/sema/definitions/registry.yaml +77 -0
- gw_data/sema/definitions/types/g.node.gt/004.yaml +169 -0
- gw_data/sema/definitions/types/position.point.gt/000.yaml +86 -0
- gw_data/sema/enums/__init__.py +7 -0
- gw_data/sema/enums/base_g_node_class.py +29 -0
- gw_data/sema/enums/g_node_status.py +28 -0
- gw_data/sema/enums/gw_str_enum.py +97 -0
- gw_data/sema/enums/old_versions/__init__.py +0 -0
- gw_data/sema/indexes/dependency_closure.yaml +19 -0
- gw_data/sema/indexes/local_names.yaml +6 -0
- gw_data/sema/indexes/lookup.yaml +35 -0
- gw_data/sema/indexes/reverse_dependencies.yaml +21 -0
- gw_data/sema/indexes/seed_expanded.yaml +29 -0
- gw_data/sema/indexes/versions.yaml +31 -0
- gw_data/sema/property_format.py +56 -0
- gw_data/sema/tests/test_property_format.py +47 -0
- gw_data/sema/types/__init__.py +7 -0
- gw_data/sema/types/g_node_gt.py +106 -0
- gw_data/sema/types/old_versions/__init__.py +0 -0
- gw_data/sema/types/position_point_gt.py +31 -0
- gw_data-0.3.0.dist-info/METADATA +189 -0
- gw_data-0.3.0.dist-info/RECORD +55 -0
- gw_data-0.3.0.dist-info/WHEEL +4 -0
- gw_data-0.3.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
metadata:
|
|
2
|
+
registry_version: "1.0"
|
|
3
|
+
last_updated: "2026-05-14T14:50:00Z"
|
|
4
|
+
maintainer: "gridworks-energy"
|
|
5
|
+
|
|
6
|
+
snapshot:
|
|
7
|
+
built_at: "2026-05-18T22:35:28Z"
|
|
8
|
+
|
|
9
|
+
formats:
|
|
10
|
+
left.right.dot:
|
|
11
|
+
owner: gridworks-energy
|
|
12
|
+
schema_url: "https://schemas.electricity.works/formats/left.right.dot"
|
|
13
|
+
created: "2024-09-02T15:00:00Z"
|
|
14
|
+
description: "Dot-separated hierarchical identifier composed of lowercase alphanumeric segments"
|
|
15
|
+
|
|
16
|
+
uuid4.str:
|
|
17
|
+
owner: gridworks-energy
|
|
18
|
+
schema_url: "https://schemas.electricity.works/formats/uuid4.str"
|
|
19
|
+
created: "2024-09-02T15:00:00Z"
|
|
20
|
+
description: "Canonical lowercase UUIDv4 string (RFC 4122) in 8-4-4-4-12 format"
|
|
21
|
+
|
|
22
|
+
enums:
|
|
23
|
+
base.g.node.class:
|
|
24
|
+
latest_version: "000"
|
|
25
|
+
owner: gridworks-energy
|
|
26
|
+
enum_type: "versioned"
|
|
27
|
+
description: "Universal physical ontology classification for Grid Nodes"
|
|
28
|
+
|
|
29
|
+
versions:
|
|
30
|
+
"000":
|
|
31
|
+
schema_url: "https://schemas.electricity.works/enums/base.g.node.class/000"
|
|
32
|
+
created: "2026-02-22T16:43:00Z"
|
|
33
|
+
|
|
34
|
+
g.node.status:
|
|
35
|
+
latest_version: "000"
|
|
36
|
+
owner: gridworks-energy
|
|
37
|
+
enum_type: "versioned"
|
|
38
|
+
description: "Lifecycle status of a Grid Node within the registry"
|
|
39
|
+
|
|
40
|
+
versions:
|
|
41
|
+
"000":
|
|
42
|
+
schema_url: "https://schemas.electricity.works/enums/g.node.status/000"
|
|
43
|
+
created: "2026-02-22T16:43:00Z"
|
|
44
|
+
|
|
45
|
+
types:
|
|
46
|
+
g.node.gt:
|
|
47
|
+
latest_version: "004"
|
|
48
|
+
owner: gridworks-energy
|
|
49
|
+
versioning_strategy: "literal"
|
|
50
|
+
description: "Fundamental identity object representing physical and logical grid nodes"
|
|
51
|
+
|
|
52
|
+
versions:
|
|
53
|
+
"004":
|
|
54
|
+
schema_url: "https://schemas.electricity.works/types/g.node.gt/004"
|
|
55
|
+
created: "2026-02-24T14:00:00Z"
|
|
56
|
+
summary: "Baseline runtime version (no prior version tracked)."
|
|
57
|
+
direct_dependencies:
|
|
58
|
+
structural:
|
|
59
|
+
- "base.g.node.class:000"
|
|
60
|
+
- "g.node.status:000"
|
|
61
|
+
- "left.right.dot"
|
|
62
|
+
- "uuid4.str"
|
|
63
|
+
|
|
64
|
+
position.point.gt:
|
|
65
|
+
latest_version: "000"
|
|
66
|
+
owner: gridworks-energy
|
|
67
|
+
versioning_strategy: "literal"
|
|
68
|
+
description: "Geographic position expressed in integer microdegrees (WGS84)"
|
|
69
|
+
|
|
70
|
+
versions:
|
|
71
|
+
"000":
|
|
72
|
+
schema_url: "https://schemas.electricity.works/types/position.point.gt/000"
|
|
73
|
+
created: "2026-02-24T15:00:00Z"
|
|
74
|
+
summary: "Initial Sema version"
|
|
75
|
+
direct_dependencies:
|
|
76
|
+
structural:
|
|
77
|
+
- "uuid4.str"
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
2
|
+
$id: "https://schemas.electricity.works/types/g.node.gt/004"
|
|
3
|
+
|
|
4
|
+
title: "g.node.gt"
|
|
5
|
+
type: object
|
|
6
|
+
description: >
|
|
7
|
+
A GNode (“Grid Node”) is the fundamental identity object in the GridWorks
|
|
8
|
+
ecosystem. Every physical location, metered unit, device, service, or actor
|
|
9
|
+
interacting with the transactive system is represented as a GNode.
|
|
10
|
+
|
|
11
|
+
properties:
|
|
12
|
+
|
|
13
|
+
GNodeId:
|
|
14
|
+
$ref: "https://schemas.electricity.works/formats/uuid4.str"
|
|
15
|
+
description: >
|
|
16
|
+
Globally unique identifier for this GNode. Immutable for the lifetime
|
|
17
|
+
of the GNode.
|
|
18
|
+
|
|
19
|
+
Alias:
|
|
20
|
+
$ref: "https://schemas.electricity.works/formats/left.right.dot"
|
|
21
|
+
description: >
|
|
22
|
+
Human-readable hierarchical identifier. Forms the basis of the
|
|
23
|
+
GNodeTree topology. Alias may change over time as the physical
|
|
24
|
+
or conceptual topology is refined.
|
|
25
|
+
|
|
26
|
+
BaseClass:
|
|
27
|
+
$ref: "https://schemas.electricity.works/enums/base.g.node.class/000"
|
|
28
|
+
description: >
|
|
29
|
+
Universal structural ontology classification for the GNode.
|
|
30
|
+
Defines the physical or logical topology role used for
|
|
31
|
+
interoperability, copper-tree construction, and market
|
|
32
|
+
coordination across organizations.
|
|
33
|
+
|
|
34
|
+
GNodeClass:
|
|
35
|
+
type: string
|
|
36
|
+
description: >
|
|
37
|
+
Functional or role-based classification for the GNode. Interpreted
|
|
38
|
+
according to the namespace of the registering organization. This field is a
|
|
39
|
+
free-form string, not a universal enum.
|
|
40
|
+
|
|
41
|
+
Status:
|
|
42
|
+
$ref: "https://schemas.electricity.works/enums/g.node.status/000"
|
|
43
|
+
description: >
|
|
44
|
+
Lifecycle status of the GNode within the registry.
|
|
45
|
+
|
|
46
|
+
PrevAlias:
|
|
47
|
+
$ref: "https://schemas.electricity.works/formats/left.right.dot"
|
|
48
|
+
description: >
|
|
49
|
+
Previous Alias value during alias transitions. Required only when
|
|
50
|
+
Alias changes. Must be null if Alias has not changed.
|
|
51
|
+
|
|
52
|
+
PositionPointId:
|
|
53
|
+
$ref: "https://schemas.electricity.works/formats/uuid4.str"
|
|
54
|
+
description: >
|
|
55
|
+
Reference to a PositionPoint GT type giving physical location
|
|
56
|
+
(WGS84 microdegrees). Required for physical GNodes; null for
|
|
57
|
+
logical/service nodes.
|
|
58
|
+
|
|
59
|
+
DisplayName:
|
|
60
|
+
type: "string"
|
|
61
|
+
description: >
|
|
62
|
+
Optional human-friendly label for UI or documentation.
|
|
63
|
+
|
|
64
|
+
TypeName:
|
|
65
|
+
const: "g.node.gt"
|
|
66
|
+
|
|
67
|
+
Version:
|
|
68
|
+
const: "004"
|
|
69
|
+
|
|
70
|
+
required:
|
|
71
|
+
- GNodeId
|
|
72
|
+
- Alias
|
|
73
|
+
- BaseClass
|
|
74
|
+
- GNodeClass
|
|
75
|
+
- Status
|
|
76
|
+
- TypeName
|
|
77
|
+
- Version
|
|
78
|
+
|
|
79
|
+
additionalProperties: false
|
|
80
|
+
|
|
81
|
+
examples:
|
|
82
|
+
- |
|
|
83
|
+
{
|
|
84
|
+
"GNodeId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
85
|
+
"Alias": "d1.isone.me.versant.keene.beech",
|
|
86
|
+
"BaseClass": "LeafTransactiveNode",
|
|
87
|
+
"GNodeClass": "LeafTransactiveNode",
|
|
88
|
+
"Status": "Active",
|
|
89
|
+
"PositionPointId": "198ca6af-5a4b-43a2-a8a9-7546deabc731",
|
|
90
|
+
"DisplayName": "Beech Street Meter",
|
|
91
|
+
"TypeName": "g.node.gt",
|
|
92
|
+
"Version": "004"
|
|
93
|
+
}
|
|
94
|
+
- |
|
|
95
|
+
{
|
|
96
|
+
"GNodeId": "dcb05390-5bca-40ef-b63d-7908ccb33d9b",
|
|
97
|
+
"Alias": "d1.isone.me.ws",
|
|
98
|
+
"BaseClass": "Logical",
|
|
99
|
+
"GNodeClass": "WeatherForecastService",
|
|
100
|
+
"Status": "Active",
|
|
101
|
+
"DisplayName": "New England Weather Forecast Service",
|
|
102
|
+
"TypeName": "g.node.gt",
|
|
103
|
+
"Version": "004"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
x-gridworks:
|
|
107
|
+
owner: "gridworks-energy"
|
|
108
|
+
|
|
109
|
+
axioms:
|
|
110
|
+
|
|
111
|
+
- number: 1
|
|
112
|
+
name: "ClassConsistency"
|
|
113
|
+
statement: >
|
|
114
|
+
a. If BaseClass is not Logical, GNodeClass SHALL equal the string value of BaseClass.
|
|
115
|
+
b. If BaseClass is Logical, GNodeClass SHALL NOT equal any value of base.g.node.class other than Logical.
|
|
116
|
+
|
|
117
|
+
- number: 2
|
|
118
|
+
name: "PhysicalGNodeLocations"
|
|
119
|
+
statement: >
|
|
120
|
+
If BaseClass != Logical, PositionPointId SHALL NOT be null.
|
|
121
|
+
|
|
122
|
+
- number: 3
|
|
123
|
+
name: "AliasTransitionConsistency"
|
|
124
|
+
statement: >
|
|
125
|
+
If PrevAlias is not null, it SHALL differ from Alias.
|
|
126
|
+
|
|
127
|
+
- number: 4
|
|
128
|
+
name: "GNodeClassNamespacing"
|
|
129
|
+
statement: >
|
|
130
|
+
GNodeClass SHALL be a non-empty string containing no whitespace
|
|
131
|
+
|
|
132
|
+
- number: 5
|
|
133
|
+
name: "AliasSuffixSemantics"
|
|
134
|
+
statement: >
|
|
135
|
+
a. Alias SHALL end with ".ta" if and only if GNodeClass is "TerminalAsset".
|
|
136
|
+
b. Alias SHALL end with ".scada" if and only if GNodeClass is "Scada".
|
|
137
|
+
|
|
138
|
+
extended_description: >
|
|
139
|
+
Grid Nodes (GNodes) provide the stable identity layer for distributed
|
|
140
|
+
coordination in the GridWorks ecosystem. Each GNode participates in a
|
|
141
|
+
hierarchical alias structure that encodes topology, routing semantics,
|
|
142
|
+
and coordination scope.
|
|
143
|
+
|
|
144
|
+
GNodes may represent physical grid structure (e.g., metered boundaries,
|
|
145
|
+
connectivity nodes, constraint points) or logical and service roles
|
|
146
|
+
(e.g., SCADA agents, forecasting services, market participants).
|
|
147
|
+
BaseClass defines the universal structural ontology required for
|
|
148
|
+
interoperability. GNodeClass expresses organization-specific
|
|
149
|
+
functional roles and does not alter structural semantics.
|
|
150
|
+
|
|
151
|
+
`g.node.gt` is an immutable serialized snapshot of declared node state.
|
|
152
|
+
Any change to a GNode (alias updates, status changes, relocations,
|
|
153
|
+
or classification changes) SHALL be represented by publishing a new
|
|
154
|
+
`g.node.gt` message rather than mutating a previously published instance.
|
|
155
|
+
This preserves durable identity (GNodeId) while allowing controlled
|
|
156
|
+
evolution of descriptive attributes.
|
|
157
|
+
|
|
158
|
+
GNode is designed as the atomic unit of coordination in a recursively
|
|
159
|
+
composable grid architecture. Systems of arbitrary scale are formed by
|
|
160
|
+
composing GNodes into hierarchical or heterarchical structures. This
|
|
161
|
+
allows optimal power flow (OPF), market clearing, and constraint
|
|
162
|
+
coordination mechanisms to operate centrally, regionally, or in
|
|
163
|
+
distributed configurations without altering the underlying identity model.
|
|
164
|
+
|
|
165
|
+
Conceptually, GNode aligns with node abstractions in IEC 61970/61968
|
|
166
|
+
CIM (e.g., ConnectivityNode and TopologicalNode), while unifying
|
|
167
|
+
physical and logical coordination entities within a single identity
|
|
168
|
+
abstraction suitable for graph-based modeling and transactive
|
|
169
|
+
coordination.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
2
|
+
$id: "https://schemas.electricity.works/types/position.point.gt/000"
|
|
3
|
+
|
|
4
|
+
title: "position.point.gt"
|
|
5
|
+
type: object
|
|
6
|
+
description: >
|
|
7
|
+
A geographic position for a physical Grid Node. Coordinates are stored in
|
|
8
|
+
integer microdegrees (degrees × 1,000,000). This type is conceptually aligned
|
|
9
|
+
with the IEC 61970/61968 CIM `PositionPoint` class, but simplified for
|
|
10
|
+
GridWorks use cases, which require only a single latitude/longitude point.
|
|
11
|
+
|
|
12
|
+
properties:
|
|
13
|
+
|
|
14
|
+
Id:
|
|
15
|
+
$ref: "https://schemas.electricity.works/formats/uuid4.str"
|
|
16
|
+
description: >
|
|
17
|
+
Globally unique identifier for this PositionPoint. Serves as the
|
|
18
|
+
primary key in the Grid Node Registry.
|
|
19
|
+
|
|
20
|
+
LatitudeMicroDeg:
|
|
21
|
+
type: integer
|
|
22
|
+
description: >
|
|
23
|
+
Latitude in microdegrees. Must fall between -90,000,000 and
|
|
24
|
+
90,000,000 inclusive (corresponding to -90.0° to +90.0° in WGS84).
|
|
25
|
+
|
|
26
|
+
LongitudeMicroDeg:
|
|
27
|
+
type: integer
|
|
28
|
+
description: >
|
|
29
|
+
Longitude in microdegrees. Must fall between -180,000,000 and
|
|
30
|
+
180,000,000 inclusive (corresponding to -180.0° to +180.0° in WGS84).
|
|
31
|
+
|
|
32
|
+
TypeName:
|
|
33
|
+
const: "position.point.gt"
|
|
34
|
+
|
|
35
|
+
Version:
|
|
36
|
+
const: "000"
|
|
37
|
+
|
|
38
|
+
required:
|
|
39
|
+
- Id
|
|
40
|
+
- LatitudeMicroDeg
|
|
41
|
+
- LongitudeMicroDeg
|
|
42
|
+
- TypeName
|
|
43
|
+
- Version
|
|
44
|
+
|
|
45
|
+
additionalProperties: false
|
|
46
|
+
|
|
47
|
+
examples:
|
|
48
|
+
- |
|
|
49
|
+
{
|
|
50
|
+
"Id": "198ca6af-5a4b-43a2-a8a9-7546deabc731",
|
|
51
|
+
"LatitudeMicroDeg": 45657842,
|
|
52
|
+
"LongitudeMicroDeg": -68708913,
|
|
53
|
+
"TypeName": "position.point.gt",
|
|
54
|
+
"Version": "000"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
x-gridworks:
|
|
58
|
+
owner: "gridworks-energy"
|
|
59
|
+
|
|
60
|
+
axioms:
|
|
61
|
+
- number: 1
|
|
62
|
+
name: "ValidEarthCoordinates"
|
|
63
|
+
statement: >
|
|
64
|
+
LatitudeMicroDeg SHALL be between -90,000,000 and 90,000,000 inclusive.
|
|
65
|
+
LongitudeMicroDeg SHALL be between -180,000,000 and 180,000,000 inclusive.
|
|
66
|
+
|
|
67
|
+
extended_description: >
|
|
68
|
+
PositionPoint represents the physical location of a GNode that has
|
|
69
|
+
spatial meaning within the electric grid, such as TerminalAssets,
|
|
70
|
+
LeafTransactiveNodes, MarketMaker constraint points, and ConnectivityNodes.
|
|
71
|
+
Coordinates are expressed in WGS84 (EPSG:4326), the standard global
|
|
72
|
+
geodetic reference system used by GPS and commonly adopted in utility
|
|
73
|
+
GIS, mapping, and DERMS integrations.
|
|
74
|
+
|
|
75
|
+
This type corresponds to a simplified form of the IEC 61970/61968 CIM
|
|
76
|
+
`PositionPoint` class. The CIM model supports elevation, coordinate-system
|
|
77
|
+
definitions, and collections of points for geometric shapes. GridWorks
|
|
78
|
+
intentionally restricts this type to a single latitude/longitude pair
|
|
79
|
+
to provide a deterministic and minimal spatial anchor for coordination.
|
|
80
|
+
|
|
81
|
+
Position accuracy is not prescribed by this type. The microdegree
|
|
82
|
+
representation provides sufficient precision to distinguish
|
|
83
|
+
distribution-level assets (e.g., residential footprints, poles,
|
|
84
|
+
transformers, substations). The actual positional accuracy of a
|
|
85
|
+
PositionPoint depends entirely on the source of the underlying
|
|
86
|
+
geographic data.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from enum import auto
|
|
2
|
+
|
|
3
|
+
from gw_data.sema.enums.gw_str_enum import SemaEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseGNodeClass(SemaEnum):
|
|
7
|
+
"""Sema: https://schemas.electricity.works/enums/base.g.node.class/000"""
|
|
8
|
+
|
|
9
|
+
TerminalAsset = auto()
|
|
10
|
+
LeafTransactiveNode = auto()
|
|
11
|
+
ConnectivityNode = auto()
|
|
12
|
+
MarketMaker = auto()
|
|
13
|
+
Logical = auto()
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def default(cls) -> "BaseGNodeClass":
|
|
17
|
+
return cls.Logical
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def values(cls) -> list[str]:
|
|
21
|
+
return [elt.value for elt in cls]
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def enum_name(cls) -> str:
|
|
25
|
+
return "base.g.node.class"
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def enum_version(cls) -> str:
|
|
29
|
+
return "000"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from enum import auto
|
|
2
|
+
|
|
3
|
+
from gw_data.sema.enums.gw_str_enum import SemaEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GNodeStatus(SemaEnum):
|
|
7
|
+
"""Sema: https://schemas.electricity.works/enums/g.node.status/000"""
|
|
8
|
+
|
|
9
|
+
Pending = auto()
|
|
10
|
+
Active = auto()
|
|
11
|
+
Suspended = auto()
|
|
12
|
+
PermanentlyDeactivated = auto()
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def default(cls) -> "GNodeStatus":
|
|
16
|
+
return cls.Pending
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def values(cls) -> list[str]:
|
|
20
|
+
return [elt.value for elt in cls]
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def enum_name(cls) -> str:
|
|
24
|
+
return "g.node.status"
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def enum_version(cls) -> str:
|
|
28
|
+
return "000"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from typing import Any, Self
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class GwStrEnum(StrEnum):
|
|
6
|
+
"""
|
|
7
|
+
Mimics fastapi-utils use of StrEnum, which diverges from the
|
|
8
|
+
python-native StrEnum for python 3.11+. Also, fills in with default
|
|
9
|
+
value if a string does not exist in the enum.
|
|
10
|
+
|
|
11
|
+
Specifically (re difference with python StrEnum) if
|
|
12
|
+
|
|
13
|
+
class Foo(Enum):
|
|
14
|
+
Bar = auto()
|
|
15
|
+
|
|
16
|
+
then
|
|
17
|
+
|
|
18
|
+
Foo.Bar.value is 'Bar' (instead of 'bar')
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def _generate_next_value_(
|
|
24
|
+
name: str,
|
|
25
|
+
start: int, # noqa: ARG004
|
|
26
|
+
count: int, # noqa: ARG004
|
|
27
|
+
last_values: list[Any], # noqa: ARG004
|
|
28
|
+
) -> str:
|
|
29
|
+
return name
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def values(cls) -> list[str]:
|
|
33
|
+
return [str(elt) for elt in cls]
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def _init_index_maps(cls) -> None:
|
|
37
|
+
if hasattr(cls, "_index_to_value"):
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
values = [m.value for m in cls]
|
|
41
|
+
cls._index_to_value = values
|
|
42
|
+
cls._value_to_index = {v: i for i, v in enumerate(values)}
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def to_index(cls, value: str) -> int:
|
|
46
|
+
cls._init_index_maps()
|
|
47
|
+
return cls._value_to_index[value]
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def from_index(cls, idx: int) -> str:
|
|
51
|
+
cls._init_index_maps()
|
|
52
|
+
return cls._index_to_value[idx]
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def default(cls) -> Self | None:
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def _missing_(cls, value: str) -> Self:
|
|
60
|
+
default = cls.default()
|
|
61
|
+
if default is None:
|
|
62
|
+
raise ValueError(f"'{value}' is not valid {cls.__name__}")
|
|
63
|
+
return default
|
|
64
|
+
|
|
65
|
+
class SemaEnum(GwStrEnum):
|
|
66
|
+
"""
|
|
67
|
+
Base for enums published in Sema.
|
|
68
|
+
Requires enum_name(). Version is optional (return None for stable enums).
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def enum_name(cls) -> str:
|
|
73
|
+
"""Sema identifier (e.g., 'gw1.relay.state')"""
|
|
74
|
+
raise NotImplementedError(
|
|
75
|
+
f"{cls.__name__} must implement enum_name() for Sema"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def enum_version(cls) -> str:
|
|
80
|
+
"""Sema identifier (e.g., '000')"""
|
|
81
|
+
raise NotImplementedError(
|
|
82
|
+
f"{cls.__name__} must implement enum_name() for Sema"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class SymbolizedEnum(SemaEnum):
|
|
87
|
+
@classmethod
|
|
88
|
+
def symbol_to_value(cls, symbol: str) -> str:
|
|
89
|
+
raise NotImplementedError
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def value_to_symbol(cls, value: str) -> str:
|
|
93
|
+
raise NotImplementedError
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def symbols(cls) -> list[str]:
|
|
97
|
+
raise NotImplementedError
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from definitions/registry.yaml
|
|
3
|
+
|
|
4
|
+
types:
|
|
5
|
+
g.node.gt:
|
|
6
|
+
'004':
|
|
7
|
+
enums:
|
|
8
|
+
- base.g.node.class:000
|
|
9
|
+
- g.node.status:000
|
|
10
|
+
formats:
|
|
11
|
+
- left.right.dot
|
|
12
|
+
- uuid4.str
|
|
13
|
+
types: []
|
|
14
|
+
position.point.gt:
|
|
15
|
+
'000':
|
|
16
|
+
enums: []
|
|
17
|
+
formats:
|
|
18
|
+
- uuid4.str
|
|
19
|
+
types: []
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from definitions/registry.yaml
|
|
3
|
+
#
|
|
4
|
+
# ------------------------------------------------------------------
|
|
5
|
+
# LOCAL LOOKUP (NON-AUTHORITATIVE)
|
|
6
|
+
#
|
|
7
|
+
# This file provides local resolution from Sema vocabulary words
|
|
8
|
+
# to schema files within this snapshot.
|
|
9
|
+
# ------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
types:
|
|
12
|
+
g.node.gt:
|
|
13
|
+
latest_version: '004'
|
|
14
|
+
versioning_strategy: literal
|
|
15
|
+
versions:
|
|
16
|
+
'004': definitions/types/g.node.gt/004.yaml
|
|
17
|
+
position.point.gt:
|
|
18
|
+
latest_version: '000'
|
|
19
|
+
versioning_strategy: literal
|
|
20
|
+
versions:
|
|
21
|
+
'000': definitions/types/position.point.gt/000.yaml
|
|
22
|
+
enums:
|
|
23
|
+
base.g.node.class:
|
|
24
|
+
enum_type: versioned
|
|
25
|
+
latest_version: '000'
|
|
26
|
+
versions:
|
|
27
|
+
'000': definitions/enums/base.g.node.class/000.yaml
|
|
28
|
+
g.node.status:
|
|
29
|
+
enum_type: versioned
|
|
30
|
+
latest_version: '000'
|
|
31
|
+
versions:
|
|
32
|
+
'000': definitions/enums/g.node.status/000.yaml
|
|
33
|
+
formats:
|
|
34
|
+
left.right.dot: definitions/formats/left.right.dot.yaml
|
|
35
|
+
uuid4.str: definitions/formats/uuid4.str.yaml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from definitions/registry.yaml
|
|
3
|
+
|
|
4
|
+
types: {}
|
|
5
|
+
enums:
|
|
6
|
+
base.g.node.class:
|
|
7
|
+
'000':
|
|
8
|
+
used_by:
|
|
9
|
+
- g.node.gt:004
|
|
10
|
+
g.node.status:
|
|
11
|
+
'000':
|
|
12
|
+
used_by:
|
|
13
|
+
- g.node.gt:004
|
|
14
|
+
formats:
|
|
15
|
+
left.right.dot:
|
|
16
|
+
used_by:
|
|
17
|
+
- g.node.gt:004
|
|
18
|
+
uuid4.str:
|
|
19
|
+
used_by:
|
|
20
|
+
- g.node.gt:004
|
|
21
|
+
- position.point.gt:000
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
metadata:
|
|
2
|
+
generated_from: indexes/public_registry.yaml
|
|
3
|
+
generated_at: '2026-05-18T22:35:28Z'
|
|
4
|
+
note: Transitive closure of initial_targets
|
|
5
|
+
initial_targets:
|
|
6
|
+
- position.point.gt:000
|
|
7
|
+
- g.node.gt:004
|
|
8
|
+
- base.g.node.class:000
|
|
9
|
+
- g.node.status:000
|
|
10
|
+
worklist:
|
|
11
|
+
formats:
|
|
12
|
+
left.right.dot:
|
|
13
|
+
path: definitions/formats/left.right.dot.yaml
|
|
14
|
+
uuid4.str:
|
|
15
|
+
path: definitions/formats/uuid4.str.yaml
|
|
16
|
+
enums:
|
|
17
|
+
base.g.node.class:
|
|
18
|
+
'000':
|
|
19
|
+
path: definitions/enums/base.g.node.class/000.yaml
|
|
20
|
+
g.node.status:
|
|
21
|
+
'000':
|
|
22
|
+
path: definitions/enums/g.node.status/000.yaml
|
|
23
|
+
types:
|
|
24
|
+
g.node.gt:
|
|
25
|
+
'004':
|
|
26
|
+
path: definitions/types/g.node.gt/004.yaml
|
|
27
|
+
position.point.gt:
|
|
28
|
+
'000':
|
|
29
|
+
path: definitions/types/position.point.gt/000.yaml
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Generated from definitions/registry.yaml
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
types:
|
|
6
|
+
g.node.gt:
|
|
7
|
+
latest_version: "004"
|
|
8
|
+
versioning_strategy: "literal"
|
|
9
|
+
versions:
|
|
10
|
+
"004":
|
|
11
|
+
summary: "Baseline runtime version (no prior version tracked)."
|
|
12
|
+
|
|
13
|
+
position.point.gt:
|
|
14
|
+
latest_version: "000"
|
|
15
|
+
versioning_strategy: "literal"
|
|
16
|
+
versions:
|
|
17
|
+
"000":
|
|
18
|
+
summary: "Initial Sema version"
|
|
19
|
+
|
|
20
|
+
enums:
|
|
21
|
+
base.g.node.class:
|
|
22
|
+
enum_type: "versioned"
|
|
23
|
+
note: "This enum is versioned; new versions are additive only."
|
|
24
|
+
versions:
|
|
25
|
+
"000": {}
|
|
26
|
+
|
|
27
|
+
g.node.status:
|
|
28
|
+
enum_type: "versioned"
|
|
29
|
+
note: "This enum is versioned; new versions are additive only."
|
|
30
|
+
versions:
|
|
31
|
+
"000": {}
|