Skip to content

Commit

Permalink
MAINT: Use relative import for Viewer class
Browse files Browse the repository at this point in the history
Use lazy import to avoid circular import error.
  • Loading branch information
bnmajor committed Dec 11, 2023
1 parent 67fb6f3 commit e29b162
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions itkwidgets/cell_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from queue import Queue
from imjoy_rpc.utils import FuturePromise

import itkwidgets

background_tasks = set()


Expand Down Expand Up @@ -207,14 +205,15 @@ def _callback(self, *args, **kwargs):
self.create_task(self.execute_next_request)

def find_view_object_names(self):
from .viewer import Viewer
# Used to determine that all references to Viewer
# objects are ready before a cell is run
objs = self.viewers.viewer_objects
user_vars = [k for k in self.shell.user_ns.keys() if not k.startswith('_')]
for var in user_vars:
# Identify which variable the view object has been assigned to
value = self.shell.user_ns[var]
if isinstance(value, itkwidgets.viewer.Viewer) and value.__str__() in objs:
if isinstance(value, Viewer) and value.__str__() in objs:
idx = objs.index(value.__str__())
self.viewers.set_name(objs[idx], var)

Expand Down

0 comments on commit e29b162

Please sign in to comment.