Skip to content

Commit

Permalink
feat: add set_manager
Browse files Browse the repository at this point in the history
b.c. pydantic does not allow defining custom property setter
via a property decorator
  • Loading branch information
aaraney committed Jan 30, 2024
1 parent 42f9f43 commit 54b724e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions python/lib/core/dmod/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,18 @@ def manager(self) -> Optional[DatasetManager]:
"""
return self._manager

@manager.setter
def manager(self, value: DatasetManager = None):
self._manager = value if isinstance(value, DatasetManager) else None
def set_manager(self, value: DatasetManager):
"""
Sets the ::class:`DatasetManager` and updates the
::attribute:`manager_uuid` property on this instances.
if value is not None:
# pydantic will not validate this, so we need to check it
if not isinstance(value.uuid, UUID):
raise ValueError(f"Expected UUID got {type(value.uuid)}")
self.manager_uuid = value.uuid
Parameters
----------
value: DatasetManager
The new value for ::attribute:`manager`.
"""
self._manager = value
self.manager_uuid = value.uuid

def __hash__(self):
members = [
Expand Down

0 comments on commit 54b724e

Please sign in to comment.