Skip to content

Commit 0a472e4

Browse files
committed
fix(control): expose get_current_object_uuid() on proxy API
Internal ObjectView.get_current_item_id() had no public proxy counterpart, forcing callers (and AI assistants) to fetch the full current object just to read its UUID. (cherry picked from commit 0fe8a02)
1 parent c565e17 commit 0a472e4

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

datalab/control/baseproxy.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ def get_sel_object_uuids(self, include_groups: bool = False) -> list[str]:
380380
List of selected objects uuids.
381381
"""
382382

383+
@abc.abstractmethod
384+
def get_current_object_uuid(self) -> str | None:
385+
"""Return current object uuid in current panel.
386+
387+
Returns:
388+
UUID of the current object, or None if no object is current.
389+
"""
390+
383391
@abc.abstractmethod
384392
def select_objects(
385393
self,
@@ -815,6 +823,14 @@ def get_sel_object_uuids(self, include_groups: bool = False) -> list[str]:
815823
"""
816824
return self._datalab.get_sel_object_uuids(include_groups)
817825

826+
def get_current_object_uuid(self) -> str | None:
827+
"""Return current object uuid in current panel.
828+
829+
Returns:
830+
UUID of the current object, or None if no object is current.
831+
"""
832+
return self._datalab.get_current_object_uuid()
833+
818834
def add_group(
819835
self, title: str, panel: str | None = None, select: bool = False
820836
) -> None:

datalab/control/remote.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,15 @@ def get_sel_object_uuids(self, include_groups: bool = False) -> list[str]:
483483
"""
484484
return self.win.get_sel_object_uuids(include_groups)
485485

486+
@remote_call
487+
def get_current_object_uuid(self) -> str | None:
488+
"""Return current object uuid in current panel.
489+
490+
Returns:
491+
UUID of the current object, or None if no object is current.
492+
"""
493+
return self.win.get_current_object_uuid()
494+
486495
@remote_call
487496
def add_group(
488497
self, title: str, panel: str | None = None, select: bool = False

datalab/gui/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ def get_sel_object_uuids(self, include_groups: bool = False) -> list[str]:
410410
panel = self.__get_current_basedatapanel()
411411
return panel.objview.get_sel_object_uuids(include_groups)
412412

413+
@remote_controlled
414+
def get_current_object_uuid(self) -> str | None:
415+
"""Return current object uuid in current panel.
416+
417+
Returns:
418+
UUID of the current object, or None if no object is current.
419+
"""
420+
panel = self.__get_current_basedatapanel()
421+
return panel.objview.get_current_object_uuid()
422+
413423
@remote_controlled
414424
def add_group(
415425
self,

datalab/gui/objectview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,11 @@ def get_current_object(self) -> SignalObj | ImageObj | None:
765765
return self.objmodel[oid]
766766
return None
767767

768+
def get_current_object_uuid(self) -> str | None:
769+
"""Return current object uuid, or None if current item is a group
770+
or if no item is current"""
771+
return self.get_current_item_id(object_only=True)
772+
768773
def set_current_object(self, obj: SignalObj | ImageObj) -> None:
769774
"""Set current object"""
770775
self.set_current_item_id(get_uuid(obj))

datalab/tests/features/control/remoteclient_unit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def multiple_commands(remote: RemoteProxy):
3636
area = rect.get_rect()
3737
remote.add_annotations_from_items([rect])
3838
uuid = remote.get_sel_object_uuids()[0]
39+
assert remote.get_current_object_uuid() == uuid
3940
items = remote.get_object_shapes()
4041
assert len(items) == 1 and items[0].get_rect() == area
4142
remote.add_label_with_title(f"Image uuid: {uuid}")

0 commit comments

Comments
 (0)