Skip to content

Dev 7731 implement identifiable interface#218

Open
chestm007 wants to merge 2 commits intomainfrom
DEV-7731-implement-identifiable-interface
Open

Dev 7731 implement identifiable interface#218
chestm007 wants to merge 2 commits intomainfrom
DEV-7731-implement-identifiable-interface

Conversation

@chestm007
Copy link
Copy Markdown
Contributor

Description

Port over jvm sdk changes.

changes that snuck in:

  • renamed decorator add_to_network_or_none to add_to_service_or_none
  • Fixed up alot of the docs in BaseService while i was in there, didnt touch the child classes as i wasnt there, but they need doing too

Associated tasks

List any other tasks / PRs that are required to be merged alongside this one (e.g. front end task for back end change or vice versa). If a PR exists, add a link. If not, just add an appropriate note here so reviewers know there is a dependency and will hold off merging until all things are ready.

Test Steps

Explain in detail how your reviewer can test the changes proposed in this PR. If it cannot be tested, leave an explanation on why.

Checklist

If any of these are not applicable, strikethrough the line ~like this~. Do not delete it!. Let the reviewer decide if you should have done it.

Code

  • I have performed a self review of my own code (including checking issues raised when creating the PR).
  • I have added/updated unit tests for these changes, and if not I have explained why they are not necessary.
  • I have commented my code in any hard-to-understand or hacky areas.
  • I have handled all new warnings generated by the compiler or IDE.
  • I have rebased onto the target branch (usually main).

Security

When developing applications, use following guidelines for information security considerations:

  • Access to applications should be protected with security keys/tokens or usernames and passwords;
  • All sessions are encrypted if possible;
  • All application input is sanitised before being acted on (ie SQL statements, etc);
  • Log messages, and especially client-facing ones, must be handled securely and must not leak credentials information (internal URLs, passwords, tokens).
  • I have considered if this change impacts information security and made sure those impacts are handled.

Documentation

  • I have updated the changelog.
  • I have updated any documentation required for these changes.

Breaking Changes

  • I have considered if this is a breaking change and will communicate it with other team members by posting it on the Slack breaking-changes channel.

Please leave a summary of the breaking changes here and then post it on the Slack breaking-changes channel to notify the team about it.

@ryanjcoleman
Copy link
Copy Markdown
Member

Task linked: DEV-7731 Update Python SDK

@chestm007 chestm007 requested review from charlta and kgreav March 23, 2026 03:15
@charlta charlta marked this pull request as draft March 23, 2026 06:47
Copy link
Copy Markdown
Member

@charlta charlta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much fun did you have trying to figure out what parts of the JVM SDK change you needed to pull across with the vastly different way the proto2cim stuff works? It was a PITA for me to review 😜

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: Missed this one.

from zepben.ewb.services.common.base_service import BaseService
from typing import Callable, Type, TYPE_CHECKING

if TYPE_CHECKING:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Although unlikely to be a problem, moving imports into the if TYPE_CHECKING: stops them being imported, which is a breaking change for anyone that imports this file and relies on these being available.

I assume this has been done as these types are only used for type checking. I also assume you missed the 99% of other cases where we don't if TYPE_CHECKING: guard the others across the code base 😁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we <3 __all__

def __str__(self) -> str:
"""
Printable version of the object including its name, mrid, and optionally, type
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: Didn't promote _validate_reference and _validate_reference_field from IdentifiedObject

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done



def add_to_network_or_none(func: TProtoToCimFunc) -> TProtoToCimFunc:
def add_to_service_or_none(func: TProtoToCimFunc) -> TProtoToCimFunc:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The rename of this function (good) didn't trigger a change to the customerProto2Cim because this isn't used there (bad?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: Missed another

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done?

"""

@property
def mrid(self) -> str:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: You missed the test for this

def _create_name_type(name_type: str, desc: str, name: str, io_mrid: str) -> NameType:
# noinspection PyArgumentList
nt = NameType(name_type, desc)
nt = NameType(name=name_type, description=desc)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: No problem here, but you missed changing the types on a lot (if not all) the validate functions the comparators use. e.g. validate_ordered or validate_unordered

Might be worth looking at any TypeVar with bound=IdentifiedObject

# End Model #
#############

def _add_or_throw(self, identifiable: Identifiable) -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not for here, but the schema tests weren't modified so here is where I am choosing to link it....

CimDatabaseSchemaCommonTests.create_identified_object and its overrides/usage haven't been updated. These probably don't really matter at this stage, but would be nice to keep them inline with the JVM side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done?


responses = self._stub.getCustomersForContainer(self._batch_send(GetCustomersForContainerRequest(), mrids), timeout=self.timeout)
async for response in responses:
for cio in response.identifiedObjects:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: response.identifiedObjects isn't valid anymore, which raises the question of why doesn't this fail in a test?

I can put raise ValueError("is this tested?") here and there are still no test failures, so there is something very wrong , or it is untested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, test fixed

…` subclasses of ``Identifiable``

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

a

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

make ``Name`` a subclass of identifiable

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

bump zepben.protobuf to 1.4.0b4. and make work

Function names, Type hints, docs, and much more are WRONG, but the code works.
Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

GrpcClient kinda done, could definitely refactor some of the child classes into this base to dedupe stuff

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

BaseService, Differences and Comparator. Difference, ReferenceResolvers

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

rename `add_to_network_or_none` to `add_to_service_or_none` as network is misleading and wrong.

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

I think thats all.

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

missed some stuff, docs on BaseService were all sorts of whack

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

PR Changes

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

fix type hinting in ServiceComparatorValidator

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

sum hints bad, good now

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

parameterise, and make pretty

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>

name.mrid and stuff

Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>
Signed-off-by: Max Chesterfield <max.chesterfield@zepben.com>
@chestm007 chestm007 force-pushed the DEV-7731-implement-identifiable-interface branch from d05214e to 5c3979d Compare March 30, 2026 01:46
@chestm007 chestm007 marked this pull request as ready for review March 30, 2026 01:51
@charlta charlta self-requested a review March 30, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants