Skip to content

Commit

Permalink
fix: clear converted ids at the beginning of each OME instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 4, 2023
1 parent 30f471a commit 12f88bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ome_types/_mixins/_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
AUTO_SEQUENCE: Final = "__auto_sequence__"
# map of id_name -> max id value
ID_COUNTER: dict[str, int] = {}

# map of (id_name, id_value) -> converted id
# NOTE: this is cleared in OMEMixin.__init__, so that the set of converted IDs
# is unique to each OME instance
CONVERTED_IDS: dict[tuple[str, str], str] = {}


Expand Down
3 changes: 3 additions & 0 deletions src/ome_types/_mixins/_ome.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, cast

from ome_types._mixins._base_type import OMEType
from ome_types._mixins._ids import CONVERTED_IDS

if TYPE_CHECKING:
from pathlib import Path
Expand All @@ -13,6 +14,8 @@

class OMEMixin:
def __init__(self, **data: Any) -> None:
# Clear the cache of converted IDs, so that they are unique to each OME instance
CONVERTED_IDS.clear()
super().__init__(**data)
self._link_refs()

Expand Down

0 comments on commit 12f88bf

Please sign in to comment.