Skip to content

Latest commit

 

History

History
130 lines (105 loc) · 6.47 KB

File metadata and controls

130 lines (105 loc) · 6.47 KB

Developing

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)

Checklist for model changes

  1. Update setup.py to import the correct version of zepben.protobuf.
  2. Model updating:
  3. Add new classes to the cim model package.
  4. Descriptions copied from Evolve CIM Profile documentation and added as doc comments to new changes (on class, property etc)
  5. Add comparators to service packages.
  6. network
  7. customer
  8. diagram
  9. Update translator package:
  10. Update __init__.py:
    • from zepben.protobuf...<new_class_name>_pb2 import <new_class_name>
    • <new_class_name>.mrid = lambda self: self...mrid()
  11. 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_pb with the @bind_to_pb decorator
  12. 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_cim with the @bind_to_cim decorator
  13. Add reference resolver(s) to resolvers in common package (if new associations).
  14. Update database schema:
  15. Increment TablesVersion.SUPPORTED_VERSION by 1 in table_version.py
  16. 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.
  17. Register new tables into _included_tables()
  18. network
  19. customer
  20. diagram
  21. Update *CIMReader for new CIM classes/associations and field updates.
  22. network
  23. customer
  24. diagram Then, update *ServiceReader to load from each new tables.
  25. network
  26. customer
  27. diagram
  28. Update *CIMWriter for new CIM classes/associations and field updates.
  29. network
  30. customer
  31. diagram Then, update *ServiceWriter to write to each new table.
  32. network
  33. customer
  34. diagram
  35. Update __init__.py to import every new public name (classes, functions, constants, extension methods):
  • from zepben.ewb...<new_module_name> import *
  1. Testing:
  • Import public names via from zepben.ewb import <name> when writing/updating tests. This ensures that __init__.py was updated correctly.
  • Test for model classes.
  • Add new classes to corresponding service translator test. test/services/.../translator
  • Add the required creators to:
    • pb_creators.py
    • fill_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:
  • Verify that all the tests are passing.
  1. Update release notes in changelog.md.
  2. Update _nio_type_to_cim in network_consumer.py to include newly added classes.

Adding support for new services

Include new grpc services in the list of services GrpcChannelBuilder._test_connection() uses when attempting to confirm the connectivity of newly created grpc channels.