Skip to content

Commit

Permalink
feat: add viewer kwarg to Builder constructor to instantiate Viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley authored and johnkit committed Apr 30, 2024
1 parent a8fccca commit 4927a9c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
9 changes: 3 additions & 6 deletions examples/jupyter/import_config_esgf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
"outputs": [],
"source": [
"config_path = '../example_config_esgf.json'\n",
"builder = DatasetBuilder(esgf=True)\n",
"\n",
"# optional: to apply UI config, access viewer before importing\n",
"viewer = builder.viewer\n",
"builder = DatasetBuilder(esgf=True, viewer=True)\n",
"\n",
"builder.import_config(config_path)\n",
"\n",
"# Show viewer in cell output\n",
"await viewer.ready\n",
"viewer.ui\n"
"await builder.viewer.ready\n",
"builder.viewer.ui\n"
]
}
],
Expand Down
9 changes: 3 additions & 6 deletions examples/jupyter/import_config_pangeo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
"outputs": [],
"source": [
"config_path = '../example_config_pangeo.json'\n",
"builder = DatasetBuilder(pangeo=True)\n",
"\n",
"# optional: to apply UI config, access viewer before importing\n",
"viewer = builder.viewer\n",
"builder = DatasetBuilder(pangeo=True, viewer=True)\n",
"\n",
"builder.import_config(config_path)\n",
"\n",
"# Show viewer in cell output\n",
"await viewer.ready\n",
"viewer.ui\n"
"await builder.viewer.ready\n",
"builder.viewer.ui\n"
]
}
],
Expand Down
11 changes: 4 additions & 7 deletions examples/jupyter/import_config_xarray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "bf9da680",
"metadata": {},
"outputs": [],
Expand All @@ -18,16 +18,13 @@
"outputs": [],
"source": [
"config_path = '../example_config_xarray.json'\n",
"builder = DatasetBuilder()\n",
"\n",
"# optional: to apply UI config, access viewer before importing\n",
"viewer = builder.viewer\n",
"builder = DatasetBuilder(viewer=True)\n",
"\n",
"builder.import_config(config_path)\n",
"\n",
"# Show viewer in cell output\n",
"await viewer.ready\n",
"viewer.ui\n"
"await builder.viewer.ready\n",
"builder.viewer.ui\n"
]
}
],
Expand Down
5 changes: 5 additions & 0 deletions pan3d/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
self,
dataset: str = None,
server: Any = None,
viewer: bool = False,
pangeo: bool = False,
esgf: bool = False,
) -> None:
Expand All @@ -37,6 +38,10 @@ def __init__(
self._pangeo = pangeo
self._esgf = esgf

if viewer:
# Access to instantiate
self.viewer

if dataset:
self.dataset_info = {
"source": "default",
Expand Down

0 comments on commit 4927a9c

Please sign in to comment.