Skip to content

Commit 4b84652

Browse files
authored
[DEV-3311] Updated to v1.0.0 (#189)
* Major rework of the file structure and packages. * Renamed package from `zepben.evolve` to `zepben.ewb` and moved to v1. * Stop using protobuf enums for parameters in the `NetworkConsumerClient` * Moved CIM database tables to correct packages. * Updated docstrings for enums. * Moved classes to correct packages and added missing tests. * Reordered to match new packages, and corrected incorrectly placed items. Updated CIM headers to be consistent. * Renamed CIM header blocks. Still needs to be sorted and made consistent. * Changelog * Updated the enum mapping between CIM and Protobuf now we are prefixing our enum values in Protobuf. * Added missing `ZBEX` markers and moved incorrectly located package and classes. Formatted entire repo. * Fixed imports. * Moved extension classes and tests * Added `zepben.auth` into the SDK. Signed-off-by: Anthony Charlton <anthony.charlton@zepben.com>
1 parent e7bcb26 commit 4b84652

963 files changed

Lines changed: 13876 additions & 10308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
source = zepben.evolve
2+
source = zepben.ewb
33

44
[paths]
55
source = src/

CONTRIBUTING.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ python -m pytest
3232
You can generate the [coverage report](htmlcov/index.html) using the following options:
3333

3434
```
35-
pytest --cov=zepben.evolve --cov-report=html --cov-branch
35+
pytest --cov=zepben.ewb --cov-report=html --cov-branch
3636
```
3737

3838
If you need to debug a test, you will need to annotate the test with the following
@@ -47,63 +47,63 @@ to prevent the test from timing out while you step through the code:
4747

4848
1. Update [`setup.py`](setup.py) to import the correct version of `zepben.protobuf`.
4949
1. Model updating:
50-
1. Add new classes to the [cim model package](src/zepben/evolve/model/cim).
50+
1. Add new classes to the [cim model package](src/zepben/ewb/model/cim).
5151
1. Descriptions copied from [Evolve CIM Profile documentation](https://zepben.github.io/evolve/docs/cim/evolve) and added as doc comments to new changes (on
5252
class, property etc)
53-
1. Add comparators to [service packages](src/zepben/evolve/services).
54-
1. [network](src/zepben/evolve/services/network/network_service_comparator.py)
55-
1. [customer](src/zepben/evolve/services/customer/customer_service_comparator.py)
56-
1. [diagram](src/zepben/evolve/services/diagram/diagram_service_comparator.py)
57-
1. Update [translator package](src/zepben/evolve/services/network/translator):
58-
1. Update [```__init__.py```](src/zepben/evolve/services/network/translator/__init__.py):
53+
1. Add comparators to [service packages](src/zepben/ewb/services).
54+
1. [network](src/zepben/ewb/services/network/network_service_comparator.py)
55+
1. [customer](src/zepben/ewb/services/customer/customer_service_comparator.py)
56+
1. [diagram](src/zepben/ewb/services/diagram/diagram_service_comparator.py)
57+
1. Update [translator package](src/zepben/ewb/services/network/translator):
58+
1. Update [```__init__.py```](src/zepben/ewb/services/network/translator/__init__.py):
5959
* ```from zepben.protobuf...<new_class_name>_pb2 import <new_class_name>```
6060
* ```<new_class_name>.mrid = lambda self: self...mrid()```
61-
1. Update [network_cim2proto.py](src/zepben/evolve/services/network/translator/network_cim2proto.py):
61+
1. Update [network_cim2proto.py](src/zepben/ewb/services/network/translator/network_cim2proto.py):
6262
* ```import <new_class_name> as PB<new_class_name>```
6363
* Add ```def <new_class_name>_to_pb```
6464
* Add ```"<new_class_name>_to_pb"``` to ```__all__```
6565
* Add ```<new_class_name>.to_pb = <new_class_name>_to_pb```
66-
1. Update [network_proto2cim.py](src/zepben/evolve/services/network/translator/network_proto2cim.py)
66+
1. Update [network_proto2cim.py](src/zepben/ewb/services/network/translator/network_proto2cim.py)
6767
* ```import <new_class_name> as PB<new_class_name>```
6868
* Add ```def <new_class_name>_to_pb```
6969
* Add ```"<new_class_name>_to_cim"``` to ```__all__```
7070
* Add ```<new_class_name>_to_cim = <new_class_name>_to_cim```
71-
1. Add reference resolver(s) to resolvers in [common package](src/zepben/evolve/services/common) (if new associations).
71+
1. Add reference resolver(s) to resolvers in [common package](src/zepben/ewb/services/common) (if new associations).
7272
1. Update database schema:
73-
1. Increment `TablesVersion.SUPPORTED_VERSION` by 1 in [table_version.py](src/zepben/evolve/database/sqlite/tables/table_version.py)
74-
1. In the [tables package](src/zepben/evolve/database/sqlite/tables), add a table class for each new CIM class and many-to-many association.
73+
1. Increment `TablesVersion.SUPPORTED_VERSION` by 1 in [table_version.py](src/zepben/ewb/database/sqlite/tables/table_version.py)
74+
1. In the [tables package](src/zepben/ewb/database/sqlite/tables), add a table class for each new CIM class and many-to-many association.
7575
Update any previously-existing table classes whose CIM classes have field changes.
7676
1. Register new tables into `_included_tables()`
77-
1. [network](src/zepben/evolve/database/sqlite/network/network_database_tables.py)
78-
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_database_tables.py)
79-
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_database_tables.py)
77+
1. [network](src/zepben/ewb/database/sqlite/network/network_database_tables.py)
78+
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_database_tables.py)
79+
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_database_tables.py)
8080
1. Update `*CIMReader` for new CIM classes/associations and field updates.
81-
1. [network](src/zepben/evolve/database/sqlite/network/network_cim_reader.py)
82-
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_cim_reader.py)
83-
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_cim_reader.py)
81+
1. [network](src/zepben/ewb/database/sqlite/network/network_cim_reader.py)
82+
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_cim_reader.py)
83+
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_cim_reader.py)
8484
Then, update `*ServiceReader` to load from each new tables.
85-
1. [network](src/zepben/evolve/database/sqlite/network/network_service_reader.py)
86-
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_service_reader.py)
87-
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_service_reader.py)
85+
1. [network](src/zepben/ewb/database/sqlite/network/network_service_reader.py)
86+
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_service_reader.py)
87+
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_service_reader.py)
8888
1. Update `*CIMWriter` for new CIM classes/associations and field updates.
89-
1. [network](src/zepben/evolve/database/sqlite/network/network_cim_writer.py)
90-
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_cim_writer.py)
91-
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_cim_writer.py)
89+
1. [network](src/zepben/ewb/database/sqlite/network/network_cim_writer.py)
90+
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_cim_writer.py)
91+
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_cim_writer.py)
9292
Then, update `*ServiceWriter` to write to each new table.
93-
1. [network](src/zepben/evolve/database/sqlite/network/network_service_writer.py)
94-
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_service_writer.py)
95-
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_service_writer.py)
96-
1. Update [```__init__.py```](src/zepben/evolve/__init__.py) to import every new public name (classes, functions, constants, extension methods):
93+
1. [network](src/zepben/ewb/database/sqlite/network/network_service_writer.py)
94+
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_service_writer.py)
95+
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_service_writer.py)
96+
1. Update [```__init__.py```](src/zepben/ewb/__init__.py) to import every new public name (classes, functions, constants, extension methods):
9797

9898

99-
* ```from zepben.evolve...<new_module_name> import *```
99+
* ```from zepben.ewb...<new_module_name> import *```
100100

101101

102102
1. Testing:
103103

104104

105-
* Import public names via ```from zepben.evolve import <name>``` when writing/updating tests. This ensures that
106-
[```__init__.py```](src/zepben/evolve/__init__.py) was updated correctly.
105+
* Import public names via ```from zepben.ewb import <name>``` when writing/updating tests. This ensures that
106+
[```__init__.py```](src/zepben/ewb/__init__.py) was updated correctly.
107107
* Test for model classes.
108108
* Add new classes to corresponding service translator test. [```test/services/.../translator```](test/services)
109109
* Add the required creators to:
@@ -122,7 +122,7 @@ to prevent the test from timing out while you step through the code:
122122

123123

124124
1. Update release notes in [```changelog.md```](changelog.md).
125-
1. Update _nio_type_to_cim in [```network_consumer.py```](src/zepben/evolve/streaming/get/network_consumer.py) to include newly added classes.
125+
1. Update _nio_type_to_cim in [```network_consumer.py```](src/zepben/ewb/streaming/get/network_consumer.py) to include newly added classes.
126126

127127
## Adding support for new services ##
128128

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Python Evolve SDK contains everything necessary to communicate with a [Zepbe
1111
# Installation #
1212

1313
```
14-
pip install zepben.evolve
14+
pip install zepben.ewb
1515
```
1616

1717
# Building #
@@ -23,3 +23,33 @@ python setup.py bdist_wheel
2323
# Usage #
2424

2525
See [Evolve Python SDK Documentation](https://zepben.github.io/evolve/docs/python-sdk/).
26+
27+
# Zepben Auth Library #
28+
29+
This library provides Authentication mechanisms for Zepben SDKs used with Energy Workbench and other Zepben services.
30+
31+
Typically, this library will be used by the SDKs to plug into connection mechanisms. It is unlikely that end users will
32+
need to use this library directly.
33+
34+
# Example Usage #
35+
36+
```python
37+
from zepben.ewb.client import get_token_fetcher
38+
39+
authenticator = get_token_fetcher(
40+
issuer="https://login.microsoftonline.com/293784982371c-8797-4168-a5e7-923874928734/v2.0/",
41+
audience="49875987458e-e217-4c8f-abf6-394875984758",
42+
client_id="asdaf98798-0584-41c3-b30c-1f9874596da",
43+
username="",
44+
password=""
45+
)
46+
47+
authenticator.token_request_data.update({
48+
'grant_type': 'client_credentials',
49+
'client_secret': 'W.Tt5KSzX6Q28lksdajflkajsdflkjaslkdjfxx',
50+
'client_id': 'asdaf98798-0584-41c3-b30c-1f9874596da',
51+
'scope': '9873498234-e217-4c8f-abf6-9789889987/.default'})
52+
#
53+
54+
print(authenticator.fetch_token())
55+
```

changelog.md

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,92 @@
11
# Zepben Python SDK
2-
## [0.49.0] - UNRELEASED
2+
## [1.0.0] - UNRELEASED
33
### Breaking Changes
4-
* None.
4+
* Renamed the package to `zepben.ewb`. You will need to update all your imports `zepben.evolve.*` -> `zepben.ewb.*`. This also updates the pypi artifact to
5+
`zepben.ewb`.
6+
* Renamed `length_from_t1_or_0` to `length_from_t1_or_0`.
7+
* Relocated the following classes into the Zepben extensions area, marking them as [ZBEX]:
8+
* `DistanceRelay`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
9+
* `EvChargingUnit`: `cim.iec61970.infiec61970.wires.generation.production` -> `cim.extensions.iec61970.base.generation.production`.
10+
* `Loop`: `cim.iec61970.infiec61970.feeder` -> `cim.extensions.iec61970.base.feeder`.
11+
* `LvFeeder`: `cim.iec61970.infiec61970.feeder` -> `cim.extensions.iec61970.base.feeder`.
12+
* `PowerDirectionKind`: `cim.iec61970.infiec61970.protection` -> `cim.extensions.iec61970.base.protection`.
13+
* `ProtectionKind`: `cim.iec61970.infiec61970.protection` -> `cim.extensions.iec61970.base.protection`.
14+
* `ProtectionRelayFunction`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
15+
* `ProtectionRelayScheme`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
16+
* `ProtectionRelaySystem`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
17+
* `RelayInfo`: `cim.iec61968.infiec61968.infassetinfo` -> `cim.extensions.iec61968.assetinfo`.
18+
* `RelaySetting`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
19+
* `Site`: `cim.iec61970.base.core` -> `cim.extensions.iec61970.base.core`.
20+
* `TransformerCoolingType`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
21+
* `TransformerEndRatedS`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
22+
* `VectorGroup`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
23+
* `VoltageRelay`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
24+
* `WindingConnection`: `cim.iec61970.base.wires.winding` -> `cim.iec61970.base.wires`.
25+
* Relocated the following classes that were in the wrong packages:
26+
* `Pole`: `cim.iec61968.assets` -> `cim.iec61968.infiec61968.infassets`.
27+
* `StreetlightLampKind`: `cim.iec61968.assets` -> `cim.iec61968.infiec61968.infassets`.
28+
* All classes in the incorrectly located `cim.iec61970.base.wires.generation.production` -> `cim.iec61970.base.generation.production`.
29+
* The protobuf implementation has the following changes, which will only have an impact if you are using protobuf directly:
30+
* Updated the values of the following enums to conform to Protobuf standard naming:
31+
* `BatteryControlMode`
32+
* `BatteryStateKind`
33+
* `CustomerKind`
34+
* `DiagramStyle`
35+
* `EndDeviceFunctionKind`
36+
* `FeederDirection`
37+
* `IncludedEnergizedContainers`
38+
* `IncludedEnergizingContainers`
39+
* `LogLevel`
40+
* `LogSource`
41+
* `NetworkState`
42+
* `OrientationKind`
43+
* `PhaseCode`
44+
* `PhaseShuntConnectionKind`
45+
* `PotentialTransformerKind`
46+
* `PowerDirectionKind`
47+
* `ProtectionKind`
48+
* `RegulatingControlModeKind`
49+
* `SinglePhaseKind`
50+
* `StreetlightLampKind`
51+
* `SVCControlMode`
52+
* `SwitchAction`
53+
* `SynchronousMachineKind`
54+
* `TransformerConstructionKind`
55+
* `TransformerCoolingType`
56+
* `TransformerFunctionKind`
57+
* `UnitSymbol`
58+
* `VectorGroup`
59+
* `WindingConnection`
60+
* `WireMaterialKind`
61+
* Renumbered the protobuf fields for:
62+
* `AcLineSegment`
63+
* `Control`
64+
* `Diagram`
65+
* `TransformerEnd`
66+
* Renamed the following enum values:
67+
* `PowerDirectionKind.UNKNOWN_DIRECTION` -> `PowerDirectionKind.UNKNOWN`
68+
* `RegulatingControlModeKind.UNKNOWN_CONTROL_MODE` -> `RegulatingControlModeKind.UNKNOWN`
69+
* `TransformerCoolingType.UNKNOWN_COOLING_TYPE` -> `TransformerCoolingType.UNKNOWN`
70+
* `WindingConnection.UNKNOWN_WINDING` -> `WindingConnection.UNKNOWN`
71+
* Added `TransformerFunctionKind.UNKNOWN` to allow distinction between an unknown function, and a function that is not covered by the enum (i.e. `other`). This
72+
addition has changed the order of the enum values, with `other` now being the last entry, instead of the first.
73+
* `NetworkConsumerClient` and `SyncNetworkConsumerClient` no longer use the protobuf `IncludedEnergizedContainers`, `IncludedEnergizingContainers` and
74+
`NetworkState` enums directly, it now uses SDK versions of these enums. To use these enums you will need to update your imports, and use the simplified
75+
versions of the enum values:
76+
* `IncludedEnergizedContainers` from package `zepben.ewb.streaming.get`.
77+
* `EXCLUDE_ENERGIZED_CONTAINERS` -> `NONE`.
78+
* `INCLUDE_ENERGIZED_FEEDERS` -> `FEEDERS`.
79+
* `INCLUDE_ENERGIZED_LV_FEEDERS` -> `LV_FEEDERS`.
80+
* `IncludedEnergizingContainers` from package `zepben.ewb.streaming.get`.
81+
* `EXCLUDE_ENERGIZING_CONTAINERS` -> `NONE`.
82+
* `INCLUDE_ENERGIZING_FEEDERS` -> `FEEDERS`.
83+
* `INCLUDE_ENERGIZING_SUBSTATIONS` -> `SUBSTATIONS`.
84+
* `NetworkState` from package `zepben.ewb.services.network`.
85+
* `ALL_NETWORK_STATE` -> `ALL`.
86+
* `NORMAL_NETWORK_STATE` -> `NORMAL`.
87+
* `CURRENT_NETWORK_STATE` -> `CURRENT`.
88+
* The `zepben.auth` dependency has been incorporated into the SDK with the following package change:
89+
* `zepben.auth` -> `zepben.ewb.auth`. You can also import these directly from `zepben.ewb`.
590

691
### New Features
792
* None.
@@ -10,7 +95,38 @@
1095
* None.
1196

1297
### Fixes
13-
* None.
98+
* Marked some extensions properties and classes with [ZBEX] that were missing them (might still be more). In addition to the ones moved into the extensions
99+
package:
100+
* `PhaseCode.Y`
101+
* `PhaseCode.YN`
102+
* `PowerElectronicsConnection.inverterStandard`
103+
* `PowerElectronicsConnection.sustainOpOvervoltLimit`
104+
* `PowerElectronicsConnection.stopAtOverFreq`
105+
* `PowerElectronicsConnection.stopAtUnderFreq`
106+
* `PowerElectronicsConnection.invVoltWattRespMode`
107+
* `PowerElectronicsConnection.invWattRespV1`
108+
* `PowerElectronicsConnection.invWattRespV2`
109+
* `PowerElectronicsConnection.invWattRespV3`
110+
* `PowerElectronicsConnection.invWattRespV4`
111+
* `PowerElectronicsConnection.invWattRespPAtV1`
112+
* `PowerElectronicsConnection.invWattRespPAtV2`
113+
* `PowerElectronicsConnection.invWattRespPAtV3`
114+
* `PowerElectronicsConnection.invWattRespPAtV4`
115+
* `PowerElectronicsConnection.invVoltVarRespMode`
116+
* `PowerElectronicsConnection.invVarRespV1`
117+
* `PowerElectronicsConnection.invVarRespV2`
118+
* `PowerElectronicsConnection.invVarRespV3`
119+
* `PowerElectronicsConnection.invVarRespV4`
120+
* `PowerElectronicsConnection.invVarRespQAtV1`
121+
* `PowerElectronicsConnection.invVarRespQAtV2`
122+
* `PowerElectronicsConnection.invVarRespQAtV3`
123+
* `PowerElectronicsConnection.invVarRespQAtV4`
124+
* `PowerElectronicsConnection.invReactivePowerMode`
125+
* `PowerElectronicsConnection.invFixReactivePower`
126+
* `PowerTransformerEnd.ratings`
127+
* `RegulatingControl.ratedCurrent`
128+
* `Sensor.relayFunctions`
129+
* `UsagePoint.approvedInverterCapacity`
14130

15131
### Notes
16132
* None.

0 commit comments

Comments
 (0)