Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5305024
First pass moving classes around. Heaps of imports broken...
charlta Jul 5, 2025
dcee3bc
Added unique annotation to all enums.
charlta Jul 5, 2025
76d9fb4
WIP - god what a mess...
charlta Jul 5, 2025
22ae1b9
WIP - test running... just not passing...
charlta Jul 5, 2025
b2928b7
WIP - most tests passing...
charlta Jul 6, 2025
39004ab
WIP - more formatting...
charlta Jul 6, 2025
3d846ff
WIP - more formatting...
charlta Jul 6, 2025
48b9dd6
WIP - more formatting and adding missing calls...
charlta Jul 6, 2025
73d9be9
WIP - more formatting and adding missing calls...
charlta Jul 6, 2025
ba06e12
WIP - more formatting and adding missing calls...
charlta Jul 7, 2025
85e8bd5
WIP - more formatting and adding missing calls...
charlta Jul 7, 2025
f3aaa93
WIP - enum mappings
charlta Jul 7, 2025
53cc03d
Copyright dates updated
charlta Jul 7, 2025
536e836
WIP: Continue getting tests working with associated code fixes.
charlta Jul 7, 2025
991c165
WIP: And its working...
charlta Jul 7, 2025
e8b6e3f
Stop using protobuf enums for parameters in the `NetworkConsumerClient`
charlta Jul 8, 2025
9d39638
Removed unused import
charlta Jul 8, 2025
7fe2e87
renamed top level package to `zepben.ewb` and moved to v1 snapshot.
charlta Jul 8, 2025
de4dd7a
fixed failing tests and added better test failure logging to the gRPC…
charlta Jul 8, 2025
60caaee
Corrected protobuf library import and added new todo for failing tests.
charlta Jul 9, 2025
baa097e
Fixed `run_streaming` to work with updated `connect_insecure`.
charlta Jul 11, 2025
c3a6f8d
Added a package rename entry to the change log.
charlta Jul 11, 2025
e669e82
Added changelog for WIP entries missed earlier.
charlta Jul 11, 2025
39c62d3
Corrected change log version
charlta Jul 11, 2025
05ed57f
Pulled `zepben.auth` into the SDK.
charlta Jul 11, 2025
f17e303
Removed readme block incorrectly copied from the JVM SDK
charlta Jul 11, 2025
5ce485b
Fixed changelog after rebase onto new release
charlta Jul 11, 2025
25d6c04
Added missing dependencies from `zepben.auth`
charlta Jul 11, 2025
659a693
Updated missed `zepben.evolve` references.
charlta Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[run]
source = zepben.evolve
source = zepben.ewb

[paths]
source = src/
Expand Down
66 changes: 33 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ python -m pytest
You can generate the [coverage report](htmlcov/index.html) using the following options:

```
pytest --cov=zepben.evolve --cov-report=html --cov-branch
pytest --cov=zepben.ewb --cov-report=html --cov-branch
```

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

1. Update [`setup.py`](setup.py) to import the correct version of `zepben.protobuf`.
1. Model updating:
1. Add new classes to the [cim model package](src/zepben/evolve/model/cim).
1. Add new classes to the [cim model package](src/zepben/ewb/model/cim).
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
class, property etc)
1. Add comparators to [service packages](src/zepben/evolve/services).
1. [network](src/zepben/evolve/services/network/network_service_comparator.py)
1. [customer](src/zepben/evolve/services/customer/customer_service_comparator.py)
1. [diagram](src/zepben/evolve/services/diagram/diagram_service_comparator.py)
1. Update [translator package](src/zepben/evolve/services/network/translator):
1. Update [```__init__.py```](src/zepben/evolve/services/network/translator/__init__.py):
1. Add comparators to [service packages](src/zepben/ewb/services).
1. [network](src/zepben/ewb/services/network/network_service_comparator.py)
1. [customer](src/zepben/ewb/services/customer/customer_service_comparator.py)
1. [diagram](src/zepben/ewb/services/diagram/diagram_service_comparator.py)
1. Update [translator package](src/zepben/ewb/services/network/translator):
1. Update [```__init__.py```](src/zepben/ewb/services/network/translator/__init__.py):
* ```from zepben.protobuf...<new_class_name>_pb2 import <new_class_name>```
* ```<new_class_name>.mrid = lambda self: self...mrid()```
1. Update [network_cim2proto.py](src/zepben/evolve/services/network/translator/network_cim2proto.py):
1. Update [network_cim2proto.py](src/zepben/ewb/services/network/translator/network_cim2proto.py):
* ```import <new_class_name> as PB<new_class_name>```
* Add ```def <new_class_name>_to_pb```
* Add ```"<new_class_name>_to_pb"``` to ```__all__```
* Add ```<new_class_name>.to_pb = <new_class_name>_to_pb```
1. Update [network_proto2cim.py](src/zepben/evolve/services/network/translator/network_proto2cim.py)
1. Update [network_proto2cim.py](src/zepben/ewb/services/network/translator/network_proto2cim.py)
* ```import <new_class_name> as PB<new_class_name>```
* Add ```def <new_class_name>_to_pb```
* Add ```"<new_class_name>_to_cim"``` to ```__all__```
* Add ```<new_class_name>_to_cim = <new_class_name>_to_cim```
1. Add reference resolver(s) to resolvers in [common package](src/zepben/evolve/services/common) (if new associations).
1. Add reference resolver(s) to resolvers in [common package](src/zepben/ewb/services/common) (if new associations).
1. Update database schema:
1. Increment `TablesVersion.SUPPORTED_VERSION` by 1 in [table_version.py](src/zepben/evolve/database/sqlite/tables/table_version.py)
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.
1. Increment `TablesVersion.SUPPORTED_VERSION` by 1 in [table_version.py](src/zepben/ewb/database/sqlite/tables/table_version.py)
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.
Update any previously-existing table classes whose CIM classes have field changes.
1. Register new tables into `_included_tables()`
1. [network](src/zepben/evolve/database/sqlite/network/network_database_tables.py)
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_database_tables.py)
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_database_tables.py)
1. [network](src/zepben/ewb/database/sqlite/network/network_database_tables.py)
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_database_tables.py)
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_database_tables.py)
1. Update `*CIMReader` for new CIM classes/associations and field updates.
1. [network](src/zepben/evolve/database/sqlite/network/network_cim_reader.py)
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_cim_reader.py)
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_cim_reader.py)
1. [network](src/zepben/ewb/database/sqlite/network/network_cim_reader.py)
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_cim_reader.py)
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_cim_reader.py)
Then, update `*ServiceReader` to load from each new tables.
1. [network](src/zepben/evolve/database/sqlite/network/network_service_reader.py)
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_service_reader.py)
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_service_reader.py)
1. [network](src/zepben/ewb/database/sqlite/network/network_service_reader.py)
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_service_reader.py)
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_service_reader.py)
1. Update `*CIMWriter` for new CIM classes/associations and field updates.
1. [network](src/zepben/evolve/database/sqlite/network/network_cim_writer.py)
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_cim_writer.py)
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_cim_writer.py)
1. [network](src/zepben/ewb/database/sqlite/network/network_cim_writer.py)
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_cim_writer.py)
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_cim_writer.py)
Then, update `*ServiceWriter` to write to each new table.
1. [network](src/zepben/evolve/database/sqlite/network/network_service_writer.py)
1. [customer](src/zepben/evolve/database/sqlite/customer/customer_service_writer.py)
1. [diagram](src/zepben/evolve/database/sqlite/diagram/diagram_service_writer.py)
1. Update [```__init__.py```](src/zepben/evolve/__init__.py) to import every new public name (classes, functions, constants, extension methods):
1. [network](src/zepben/ewb/database/sqlite/network/network_service_writer.py)
1. [customer](src/zepben/ewb/database/sqlite/customer/customer_service_writer.py)
1. [diagram](src/zepben/ewb/database/sqlite/diagram/diagram_service_writer.py)
1. Update [```__init__.py```](src/zepben/ewb/__init__.py) to import every new public name (classes, functions, constants, extension methods):


* ```from zepben.evolve...<new_module_name> import *```
* ```from zepben.ewb...<new_module_name> import *```


1. Testing:


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


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

## Adding support for new services ##

Expand Down
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Python Evolve SDK contains everything necessary to communicate with a [Zepbe
# Installation #

```
pip install zepben.evolve
pip install zepben.ewb
```

# Building #
Expand All @@ -23,3 +23,33 @@ python setup.py bdist_wheel
# Usage #

See [Evolve Python SDK Documentation](https://zepben.github.io/evolve/docs/python-sdk/).

# Zepben Auth Library #

This library provides Authentication mechanisms for Zepben SDKs used with Energy Workbench and other Zepben services.

Typically, this library will be used by the SDKs to plug into connection mechanisms. It is unlikely that end users will
need to use this library directly.

# Example Usage #

```python
from zepben.ewb.client import get_token_fetcher

authenticator = get_token_fetcher(
issuer="https://login.microsoftonline.com/293784982371c-8797-4168-a5e7-923874928734/v2.0/",
audience="49875987458e-e217-4c8f-abf6-394875984758",
client_id="asdaf98798-0584-41c3-b30c-1f9874596da",
username="",
password=""
)

authenticator.token_request_data.update({
'grant_type': 'client_credentials',
'client_secret': 'W.Tt5KSzX6Q28lksdajflkajsdflkjaslkdjfxx',
'client_id': 'asdaf98798-0584-41c3-b30c-1f9874596da',
'scope': '9873498234-e217-4c8f-abf6-9789889987/.default'})
#

print(authenticator.fetch_token())
```
122 changes: 119 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,92 @@
# Zepben Python SDK
## [0.49.0] - UNRELEASED
## [1.0.0] - UNRELEASED
### Breaking Changes
* None.
* 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
`zepben.ewb`.
* Renamed `length_from_t1_or_0` to `length_from_t1_or_0`.
* Relocated the following classes into the Zepben extensions area, marking them as [ZBEX]:
* `DistanceRelay`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `EvChargingUnit`: `cim.iec61970.infiec61970.wires.generation.production` -> `cim.extensions.iec61970.base.generation.production`.
* `Loop`: `cim.iec61970.infiec61970.feeder` -> `cim.extensions.iec61970.base.feeder`.
* `LvFeeder`: `cim.iec61970.infiec61970.feeder` -> `cim.extensions.iec61970.base.feeder`.
* `PowerDirectionKind`: `cim.iec61970.infiec61970.protection` -> `cim.extensions.iec61970.base.protection`.
* `ProtectionKind`: `cim.iec61970.infiec61970.protection` -> `cim.extensions.iec61970.base.protection`.
* `ProtectionRelayFunction`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `ProtectionRelayScheme`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `ProtectionRelaySystem`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `RelayInfo`: `cim.iec61968.infiec61968.infassetinfo` -> `cim.extensions.iec61968.assetinfo`.
* `RelaySetting`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `Site`: `cim.iec61970.base.core` -> `cim.extensions.iec61970.base.core`.
* `TransformerCoolingType`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
* `TransformerEndRatedS`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
* `VectorGroup`: `cim.iec61970.base.wires` -> `cim.extensions.iec61970.base.wires`.
* `VoltageRelay`: `cim.iec61970.base.protection` -> `cim.extensions.iec61970.base.protection`.
* `WindingConnection`: `cim.iec61970.base.wires.winding` -> `cim.iec61970.base.wires`.
* Relocated the following classes that were in the wrong packages:
* `Pole`: `cim.iec61968.assets` -> `cim.iec61968.infiec61968.infassets`.
* `StreetlightLampKind`: `cim.iec61968.assets` -> `cim.iec61968.infiec61968.infassets`.
* All classes in the incorrectly located `cim.iec61970.base.wires.generation.production` -> `cim.iec61970.base.generation.production`.
* The protobuf implementation has the following changes, which will only have an impact if you are using protobuf directly:
* Updated the values of the following enums to conform to Protobuf standard naming:
* `BatteryControlMode`
* `BatteryStateKind`
* `CustomerKind`
* `DiagramStyle`
* `EndDeviceFunctionKind`
* `FeederDirection`
* `IncludedEnergizedContainers`
* `IncludedEnergizingContainers`
* `LogLevel`
* `LogSource`
* `NetworkState`
* `OrientationKind`
* `PhaseCode`
* `PhaseShuntConnectionKind`
* `PotentialTransformerKind`
* `PowerDirectionKind`
* `ProtectionKind`
* `RegulatingControlModeKind`
* `SinglePhaseKind`
* `StreetlightLampKind`
* `SVCControlMode`
* `SwitchAction`
* `SynchronousMachineKind`
* `TransformerConstructionKind`
* `TransformerCoolingType`
* `TransformerFunctionKind`
* `UnitSymbol`
* `VectorGroup`
* `WindingConnection`
* `WireMaterialKind`
* Renumbered the protobuf fields for:
* `AcLineSegment`
* `Control`
* `Diagram`
* `TransformerEnd`
* Renamed the following enum values:
* `PowerDirectionKind.UNKNOWN_DIRECTION` -> `PowerDirectionKind.UNKNOWN`
* `RegulatingControlModeKind.UNKNOWN_CONTROL_MODE` -> `RegulatingControlModeKind.UNKNOWN`
* `TransformerCoolingType.UNKNOWN_COOLING_TYPE` -> `TransformerCoolingType.UNKNOWN`
* `WindingConnection.UNKNOWN_WINDING` -> `WindingConnection.UNKNOWN`
* Added `TransformerFunctionKind.UNKNOWN` to allow distinction between an unknown function, and a function that is not covered by the enum (i.e. `other`). This
addition has changed the order of the enum values, with `other` now being the last entry, instead of the first.
* `NetworkConsumerClient` and `SyncNetworkConsumerClient` no longer use the protobuf `IncludedEnergizedContainers`, `IncludedEnergizingContainers` and
`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
versions of the enum values:
* `IncludedEnergizedContainers` from package `zepben.ewb.streaming.get`.
* `EXCLUDE_ENERGIZED_CONTAINERS` -> `NONE`.
* `INCLUDE_ENERGIZED_FEEDERS` -> `FEEDERS`.
* `INCLUDE_ENERGIZED_LV_FEEDERS` -> `LV_FEEDERS`.
* `IncludedEnergizingContainers` from package `zepben.ewb.streaming.get`.
* `EXCLUDE_ENERGIZING_CONTAINERS` -> `NONE`.
* `INCLUDE_ENERGIZING_FEEDERS` -> `FEEDERS`.
* `INCLUDE_ENERGIZING_SUBSTATIONS` -> `SUBSTATIONS`.
* `NetworkState` from package `zepben.ewb.services.network`.
* `ALL_NETWORK_STATE` -> `ALL`.
* `NORMAL_NETWORK_STATE` -> `NORMAL`.
* `CURRENT_NETWORK_STATE` -> `CURRENT`.
* The `zepben.auth` dependency has been incorporated into the SDK with the following package change:
* `zepben.auth` -> `zepben.ewb.auth`. You can also import these directly from `zepben.ewb`.

### New Features
* None.
Expand All @@ -10,7 +95,38 @@
* None.

### Fixes
* None.
* 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
package:
* `PhaseCode.Y`
* `PhaseCode.YN`
* `PowerElectronicsConnection.inverterStandard`
* `PowerElectronicsConnection.sustainOpOvervoltLimit`
* `PowerElectronicsConnection.stopAtOverFreq`
* `PowerElectronicsConnection.stopAtUnderFreq`
* `PowerElectronicsConnection.invVoltWattRespMode`
* `PowerElectronicsConnection.invWattRespV1`
* `PowerElectronicsConnection.invWattRespV2`
* `PowerElectronicsConnection.invWattRespV3`
* `PowerElectronicsConnection.invWattRespV4`
* `PowerElectronicsConnection.invWattRespPAtV1`
* `PowerElectronicsConnection.invWattRespPAtV2`
* `PowerElectronicsConnection.invWattRespPAtV3`
* `PowerElectronicsConnection.invWattRespPAtV4`
* `PowerElectronicsConnection.invVoltVarRespMode`
* `PowerElectronicsConnection.invVarRespV1`
* `PowerElectronicsConnection.invVarRespV2`
* `PowerElectronicsConnection.invVarRespV3`
* `PowerElectronicsConnection.invVarRespV4`
* `PowerElectronicsConnection.invVarRespQAtV1`
* `PowerElectronicsConnection.invVarRespQAtV2`
* `PowerElectronicsConnection.invVarRespQAtV3`
* `PowerElectronicsConnection.invVarRespQAtV4`
* `PowerElectronicsConnection.invReactivePowerMode`
* `PowerElectronicsConnection.invFixReactivePower`
* `PowerTransformerEnd.ratings`
* `RegulatingControl.ratedCurrent`
* `Sensor.relayFunctions`
* `UsagePoint.approvedInverterCapacity`

### Notes
* None.
Expand Down
Loading