This library depends on protobuf and gRPC for messaging. To set up for developing against this library, clone it first:
git clone https://github.com/zepben/evolve-sdk-python.git
Install grpc updates locally as an editable install.
cd evolve-grpc
pip install -e .
Install as an editable install. It's recommended to install in a Python virtualenv
cd evolve-sdk-python
pip install -e .[test]
#If the above pip install doesn't work.
python -m pip install --editable '.[test]'
Run the tests:
python -m pytest
You can generate the coverage report using the following options:
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 to prevent the test from timing out while you step through the code:
# todo remove timeout before commit
@pytest.mark.timeout(100000)
- Update
setup.pyto import the correct version ofzepben.protobuf. - Model updating:
- Add new classes to the cim model package.
- Descriptions copied from Evolve CIM Profile documentation and added as doc comments to new changes (on class, property etc)
- Add comparators to service packages.
- network
- customer
- diagram
- Update translator package:
- Update
__init__.py:from zepben.protobuf...<new_class_name>_pb2 import <new_class_name><new_class_name>.mrid = lambda self: self...mrid()
- Update 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__ - Annotate
<new_class_name>_to_pbwith the@bind_to_pbdecorator
- Update 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__ - Annotate
<new_class_name>_to_cimwith the@bind_to_cimdecorator
- Add reference resolver(s) to resolvers in common package (if new associations).
- Update database schema:
- Increment
TablesVersion.SUPPORTED_VERSIONby 1 in table_version.py - In the tables package, 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.
- Register new tables into
_included_tables() - network
- customer
- diagram
- Update
*CIMReaderfor new CIM classes/associations and field updates. - network
- customer
- diagram
Then, update
*ServiceReaderto load from each new tables. - network
- customer
- diagram
- Update
*CIMWriterfor new CIM classes/associations and field updates. - network
- customer
- diagram
Then, update
*ServiceWriterto write to each new table. - network
- customer
- diagram
- Update
__init__.pyto import every new public name (classes, functions, constants, extension methods):
from zepben.ewb...<new_module_name> import *
- Testing:
- Import public names via
from zepben.ewb import <name>when writing/updating tests. This ensures that__init__.pywas updated correctly. - Test for model classes.
- Add new classes to corresponding service translator test.
test/services/.../translator - Add the required creators to:
pb_creators.pyfill_fields.py- If a relationship involving a branch class has been introduced. Add an entry in SAMPLE SET to ensure the correct leaf class is created for testing.
- Add test for each new comparator to test/services/... package.
- Add test for each new class to test/cim/... package.
- Test database schema:
- Handle each new direct association in
_add_with_references(): schema_utils.py - Include new concrete CIM classes in
test_database_sqlite.py.
- Handle each new direct association in
- Verify that all the tests are passing.
- Update release notes in
changelog.md. - Update _nio_type_to_cim in
network_consumer.pyto include newly added classes.
Include new grpc services in the list of services GrpcChannelBuilder._test_connection() uses when attempting to confirm the connectivity of newly created
grpc channels.