Skip to content

Commit

Permalink
fix(accessor): add .local/.remote option
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Jan 6, 2025
1 parent 41c7355 commit a90d6f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/jupyter/xarray-preview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
"ds.pan3d.preview"
"ds.pan3d.local.preview"
]
},
{
Expand Down
27 changes: 24 additions & 3 deletions pan3d/xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,32 @@ def next_id(cls):
def __init__(self, xarray):
self.xarray = xarray
self.accessor_id = 0
self._local_rendering = None
self._viewer_preview = None
self._viewer_slicer = None
self._viewer_globe = None

@property
def local(self):
"""Builder pattern for viewer creation using local rendering"""
self._local_rendering = "wasm"
return self

@property
def remote(self):
"""Builder pattern for viewer creation using remote rendering"""
self._local_rendering = None
return self

@property
def preview(self):
from pan3d.viewers.preview import XArrayViewer

if self._viewer_preview is None:
self._viewer_preview = XArrayViewer(
xarray=self.xarray, server=self.next_id()
xarray=self.xarray,
server=self.next_id(),
local_rendering=self._local_rendering,
)

return self._viewer_preview
Expand All @@ -51,7 +66,9 @@ def slicer(self):

if self._viewer_slicer is None:
self._viewer_slicer = XArraySlicer(
xarray=self.xarray, server=self.next_id()
xarray=self.xarray,
server=self.next_id(),
# local_rendering=self._local_rendering, # FIXME Abhishek
)

return self._viewer_slicer
Expand All @@ -61,7 +78,11 @@ def globe(self):
from pan3d.explorers.globe import GlobeViewer

if self._viewer_globe is None:
self._viewer_globe = GlobeViewer(xarray=self.xarray, server=self.next_id())
self._viewer_globe = GlobeViewer(
xarray=self.xarray,
server=self.next_id(),
local_rendering=self._local_rendering,
)

return self._viewer_globe

Expand Down

0 comments on commit a90d6f2

Please sign in to comment.