Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Add the following items to your setup.py:
```
install_requires=[
"zepben.auth==<VERSION>",
"zepben.evolve==<VERSION>"
"zepben.ewb==<VERSION>"
],
```

The latest versions can be found on the Python package index:

* [zepben.evolve](https://pypi.org/project/zepben.evolve/)
* [zepben.ewb](https://pypi.org/project/zepben.ewb/)
* [zepben.auth](https://pypi.org/project/zepben.auth/)

> [!NOTE]
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# EWB Python SDK examples
## [0.4.0] - UNRELEASED
### Breaking Changes
* None.
* Update `zepben.evolve` to latest version, renamed too `zepben.ewb` 1.0.0b7. Previous versions will be incompatible.

### New Features
* None.
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ build-backend = "setuptools.build_meta"
name = "zepben.examples"
description = "Module containing examples for interacting with Zepben's platform"
version = "0.4.0b2"
readme = {file = "README.md", content-type = "test/markdown"}
readme = {file = "README.md", content-type = "text/markdown"}
license = "MPL-2.0"
requires-python = '>=3.9,<3.13'
requires-python = '>=3.10,<3.13'
authors = [
{name = "Zeppelin Bend", email = "[email protected]"}
]
dependencies = [
"zepben.eas==0.19.0",
"zepben.evolve==0.48.0",
"zepben.ewb==1.0.0b7",
"numba==0.60.0",
"geojson==2.5.0",
"gql[requests]==3.4.1",
Expand All @@ -34,7 +34,6 @@ dependencies = [
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down
2 changes: 1 addition & 1 deletion src/zepben/examples/building_network_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

from zepben.evolve import NetworkHierarchy, GeographicalRegion, SubGeographicalRegion, Feeder, Substation, Loop, Circuit
from zepben.ewb import NetworkHierarchy, GeographicalRegion, SubGeographicalRegion, Feeder, Substation, Loop, Circuit

if __name__ == '__main__':

Expand Down
12 changes: 6 additions & 6 deletions src/zepben/examples/connecting_to_grpc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async def plaintext_connection():
Connects to an RPC server without TLS or authentication.
This method should only be used in development and for demos.
"""
from zepben.evolve import connect_insecure, NetworkConsumerClient
from zepben.ewb import connect_insecure, NetworkConsumerClient
async with connect_insecure("hostname", 1234) as insecure_channel:
client = NetworkConsumerClient(insecure_channel)
grpc_result = await client.get_network_hierarchy()
Expand All @@ -22,7 +22,7 @@ async def secure_connection():
Connects to an RPC server over TLS.
No user/client credentials are used.
"""
from zepben.evolve import connect_tls, NetworkConsumerClient
from zepben.ewb import connect_tls, NetworkConsumerClient
async with connect_tls("hostname", 1234) as secure_channel:
client = NetworkConsumerClient(secure_channel)
grpc_result = await client.get_network_hierarchy()
Expand All @@ -35,7 +35,7 @@ async def secure_connection_with_user_credentials():
fetched from https://hostname/auth or https://hostname/ewb/auth by default, which includes
the domain of the OAuth token provider.
"""
from zepben.evolve import connect_with_password, NetworkConsumerClient
from zepben.ewb import connect_with_password, NetworkConsumerClient
async with connect_with_password(
"client ID",
"username",
Expand Down Expand Up @@ -70,7 +70,7 @@ async def secure_connection_with_client_credentials():
fetched from https://hostname/auth or https://hostname/ewb/auth by default, which includes the
domain of the OAuth token provider.
"""
from zepben.evolve import connect_with_secret, NetworkConsumerClient
from zepben.ewb import connect_with_secret, NetworkConsumerClient
async with connect_with_secret(
"client ID",
"client secret",
Expand Down Expand Up @@ -102,7 +102,7 @@ def connect_sync():
You may use `SyncNetworkConsumerClient` if you prefer not to use asyncio.
The API calls are the same between `SyncNetworkConsumerClient` and `NetworkConsumerClient`.
"""
from zepben.evolve import connect_insecure, SyncNetworkConsumerClient
from zepben.ewb import connect_insecure, SyncNetworkConsumerClient
channel = connect_insecure("hostname", 1234)
client = SyncNetworkConsumerClient(channel)
grpc_result = client.get_network_hierarchy()
Expand All @@ -111,7 +111,7 @@ def connect_sync():

async def connect_using_token():
import json
from zepben.evolve import connect_with_token, NetworkConsumerClient
from zepben.ewb import connect_with_token, NetworkConsumerClient

with open("config.json") as f:
c = json.load(f)
Expand Down
14 changes: 6 additions & 8 deletions src/zepben/examples/current_state_manipulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@

import asyncio
import json
import sys
from typing import List, Set

from zepben.evolve import (
Feeder, PowerTransformer, Switch, Tracing, NetworkConsumerClient, connect_with_password, Terminal,
BusbarSection, ConductingEquipment, Breaker, EquipmentContainer, StepContext, NetworkTraceStep, connect_with_token
from zepben.ewb import (
Feeder, PowerTransformer, Switch, Tracing, NetworkConsumerClient, Terminal, BusbarSection,
ConductingEquipment, Breaker, EquipmentContainer, StepContext, NetworkTraceStep, connect_with_token,
IncludedEnergizedContainers, IncludedEnergizingContainers
)

from zepben.protobuf.nc.nc_requests_pb2 import INCLUDE_ENERGIZED_FEEDERS, INCLUDE_ENERGIZING_FEEDERS

"""
Primary question to answer/example for:
1. How to access the CIM model? Show examples of how the static/design and dynamic/current states
Expand Down Expand Up @@ -49,8 +47,8 @@ async def fetch_zone_feeders(client: NetworkConsumerClient):
await client.get_equipment_container(
feeder.mrid,
Feeder,
include_energizing_containers=INCLUDE_ENERGIZING_FEEDERS,
include_energized_containers=INCLUDE_ENERGIZED_FEEDERS
include_energizing_containers=IncludedEnergizingContainers.FEEDERS,
include_energized_containers=IncludedEnergizedContainers.FEEDERS
)
print("CPM feeders fetched.")

Expand Down
7 changes: 3 additions & 4 deletions src/zepben/examples/dsub_from_nmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
import asyncio
import json

from zepben.evolve import (
from zepben.ewb import (
NetworkStateOperators, NetworkTraceActionType, NetworkTraceStep, StepContext,
NetworkConsumerClient, ConductingEquipment, connect_with_token
)
from zepben.evolve import PowerTransformer, UsagePoint, Tracing, Switch
from zepben.protobuf.nc.nc_requests_pb2 import INCLUDE_ENERGIZED_LV_FEEDERS
from zepben.ewb import PowerTransformer, UsagePoint, Tracing, Switch, IncludedEnergizedContainers


with open("config.json") as f:
Expand Down Expand Up @@ -47,7 +46,7 @@ def step_action(step: NetworkTraceStep, context: StepContext):
async def main(mrid: str, feeder_mrid: str):
channel = connect_with_token(host=c["host"], access_token=c["access_token"], rpc_port=c["rpc_port"])
client = NetworkConsumerClient(channel)
await client.get_equipment_container(feeder_mrid, include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS)
await client.get_equipment_container(feeder_mrid, include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS)
network = client.service

try:
Expand Down
4 changes: 2 additions & 2 deletions src/zepben/examples/energy_consumer_device_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from typing import Union

import pandas as pd
from zepben.evolve import NetworkConsumerClient, connect_with_token, Tracing, upstream, EnergyConsumer, NetworkTraceStep, StepContext, PowerTransformer, \
from zepben.ewb import NetworkConsumerClient, connect_with_token, Tracing, upstream, EnergyConsumer, NetworkTraceStep, StepContext, PowerTransformer, \
TransformerFunctionKind, Breaker, ConductingEquipment, Fuse, IdentifiedObject, NetworkTrace, Feeder
from zepben.protobuf.nc.nc_requests_pb2 import IncludedEnergizingContainers, IncludedEnergizedContainers
from zepben.protobuf.nc.nc_requests_pb2 import IncludedEnergizedContainers


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from typing import Dict

import pandas as pd
from zepben.evolve import NetworkConsumerClient, connect_with_token, Tracing, EnergyConsumer, PowerTransformer, \
TransformerFunctionKind, Breaker, Fuse, IdentifiedObject, EquipmentTreeBuilder, downstream, TreeNode, Feeder
from zepben.protobuf.nc.nc_requests_pb2 import IncludedEnergizedContainers
from zepben.ewb import NetworkConsumerClient, connect_with_token, Tracing, EnergyConsumer, PowerTransformer, \
TransformerFunctionKind, Breaker, Fuse, IdentifiedObject, EquipmentTreeBuilder, downstream, TreeNode, \
Feeder, IncludedEnergizedContainers


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/zepben/examples/examining_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from zepben.evolve import (
from zepben.ewb import (
EnergySource, AcLineSegment, Fuse, PowerTransformer, Breaker, EnergyConsumer, NetworkService,
Terminal, connected_equipment, ConductingEquipment, PhaseCode, connected_terminals,
ConnectivityResult
Expand Down
2 changes: 1 addition & 1 deletion src/zepben/examples/fetching_network_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import asyncio
import json

from zepben.evolve import connect_with_token, NetworkConsumerClient
from zepben.ewb import connect_with_token, NetworkConsumerClient

with open("config.json") as f:
c = json.loads(f.read())
Expand Down
22 changes: 10 additions & 12 deletions src/zepben/examples/fetching_network_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import json
from collections import defaultdict

from zepben.evolve import (
Conductor, PowerTransformer, ConductingEquipment, EnergyConsumer, Switch, connect_with_token, NetworkConsumerClient
)
from zepben.protobuf.nc.nc_requests_pb2 import (
INCLUDE_ENERGIZED_LV_FEEDERS, INCLUDE_ENERGIZED_FEEDERS, INCLUDE_ENERGIZING_SUBSTATIONS, INCLUDE_ENERGIZING_FEEDERS
from zepben.ewb import (
Conductor, PowerTransformer, ConductingEquipment, EnergyConsumer, Switch, connect_with_token,
NetworkConsumerClient, IncludedEnergizedContainers, IncludedEnergizingContainers
)


Expand All @@ -31,7 +29,7 @@ async def main():
# Fetch feeder and all its LvFeeders
await client.get_equipment_container(
feeder_mrid,
include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS
include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS
)

print(f"\nTotal Number of objects: {client.service.len_of()}")
Expand Down Expand Up @@ -66,13 +64,13 @@ async def main():
# Fetch substation equipment and include equipment from HV/MV feeders powered by it
await client.get_equipment_container(
"substation ID",
include_energized_containers=INCLUDE_ENERGIZED_FEEDERS
include_energized_containers=IncludedEnergizedContainers.FEEDERS
)

# Same as above, but also fetch equipment from LV feeders powered by the HV/MV feeders
await client.get_equipment_container(
"substation ID",
include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS
include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS
)

# Fetch feeder equipment without fetching any additional equipment from powering/powered containers
Expand All @@ -82,20 +80,20 @@ async def main():
# and the equipment from the LV feeders it powers
await client.get_equipment_container(
"feeder ID",
include_energizing_containers=INCLUDE_ENERGIZING_SUBSTATIONS,
include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS
include_energizing_containers=IncludedEnergizingContainers.SUBSTATIONS,
include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS
)

# Fetch LV feeder equipment and include equipment from HV/MV feeders powering it
await client.get_equipment_container(
"LV feeder ID",
include_energizing_containers=INCLUDE_ENERGIZING_FEEDERS
include_energizing_containers=IncludedEnergizingContainers.FEEDERS
)

# Same as above, but also fetch equipment from the substations powering the HV/MV feeders
await client.get_equipment_container(
"LV feeder ID",
include_energizing_containers=INCLUDE_ENERGIZING_SUBSTATIONS
include_energizing_containers=IncludedEnergizingContainers.SUBSTATIONS
)


Expand Down
9 changes: 4 additions & 5 deletions src/zepben/examples/find_isolation_section_from_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
import asyncio
import json

from zepben.evolve import (
from zepben.ewb import (
NetworkStateOperators, NetworkTraceActionType, NetworkTraceStep, StepContext,
NetworkConsumerClient, AcLineSegment, connect_with_token, stop_at_open
NetworkConsumerClient, AcLineSegment, connect_with_token, stop_at_open, IncludedEnergizedContainers
)
from zepben.evolve import Tracing, Switch
from zepben.protobuf.nc.nc_requests_pb2 import INCLUDE_ENERGIZED_LV_FEEDERS
from zepben.ewb import Tracing, Switch


async def main(conductor_mrid: str, feeder_mrid: str):
Expand All @@ -31,7 +30,7 @@ async def main(conductor_mrid: str, feeder_mrid: str):
)
client = NetworkConsumerClient(channel)
await client.get_equipment_container(
feeder_mrid, include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS
feeder_mrid, include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS
)
network = client.service

Expand Down
10 changes: 5 additions & 5 deletions src/zepben/examples/id_csv_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
from typing import Optional
import pandas as pd

from zepben.protobuf.nc.nc_requests_pb2 import IncludedEnergizedContainers

from zepben.evolve import NetworkConsumerClient, connect_with_token, ConductingEquipment, Feeder, connect_tls
from zepben.ewb import NetworkConsumerClient, connect_with_token, ConductingEquipment, Feeder, IncludedEnergizedContainers

with open("./config.json") as f:
c = json.loads(f.read())
Expand Down Expand Up @@ -58,8 +56,10 @@ async def process_nodes(feeder_mrid: str, channel):
print("Fetching from server ...")
network_client = NetworkConsumerClient(channel=channel)
network_service = network_client.service
(await network_client.get_equipment_container(feeder_mrid,
include_energized_containers=IncludedEnergizedContainers.INCLUDE_ENERGIZED_LV_FEEDERS)).throw_on_error()
(await network_client.get_equipment_container(
feeder_mrid,
include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS)
).throw_on_error()

print("Processing equipment ...")
feeder = network_service.get(feeder_mrid, Feeder)
Expand Down
2 changes: 1 addition & 1 deletion src/zepben/examples/ieee_13_node_test_feeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Tuple

import numpy
from zepben.evolve import (
from zepben.ewb import (
AcLineSegment, Disconnector, PowerTransformer, TransformerFunctionKind, NetworkService, Terminal,
PowerTransformerEnd, EnergyConsumer, PerLengthSequenceImpedance, PhaseCode, EnergyConsumerPhase,
SinglePhaseKind, LinearShuntCompensator, ShuntCompensatorInfo, Feeder, LvFeeder, BaseVoltage, Breaker
Expand Down
8 changes: 4 additions & 4 deletions src/zepben/examples/isolation_equipment_between_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import json
from typing import Tuple, Type

from zepben.evolve import (
from zepben.ewb import (
NetworkStateOperators, NetworkTraceActionType, NetworkTraceStep, StepContext, Tracing,
NetworkConsumerClient, ProtectedSwitch, Recloser, LoadBreakSwitch, connect_with_token
NetworkConsumerClient, ProtectedSwitch, Recloser, LoadBreakSwitch, connect_with_token,
IncludedEnergizedContainers
)
from zepben.protobuf.nc.nc_requests_pb2 import INCLUDE_ENERGIZED_LV_FEEDERS


async def main(mrids: Tuple[str, str], io_type: Type[ProtectedSwitch], feeder_mrid):
Expand All @@ -32,7 +32,7 @@ async def main(mrids: Tuple[str, str], io_type: Type[ProtectedSwitch], feeder_mr
client = NetworkConsumerClient(channel)
await client.get_equipment_container(
feeder_mrid,
include_energized_containers=INCLUDE_ENERGIZED_LV_FEEDERS
include_energized_containers=IncludedEnergizedContainers.LV_FEEDERS
)
network = client.service

Expand Down
2 changes: 1 addition & 1 deletion src/zepben/examples/list_ewb_network_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import tempfile

from zepben.evolve import EwbDataFilePaths, DatabaseType
from zepben.ewb import EwbDataFilePaths, DatabaseType
from pathlib import Path
from datetime import date

Expand Down
4 changes: 2 additions & 2 deletions src/zepben/examples/network_service_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from zepben.evolve.services.common.resolver import per_length_impedance
from zepben.evolve import (
from zepben.ewb.services.common.resolver import per_length_impedance
from zepben.ewb import (
NetworkService, AcLineSegment, PerLengthSequenceImpedance, Switch, Breaker,
ConductingEquipment, NameType, Meter, EnergySource, Terminal
)
Expand Down
Loading
Loading