Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions intake_esm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class esm_datastore(Catalog):

Parameters
----------
obj : str, dict
obj : str, dict, ESMCatalogModel
The ESM Catalog to use, or a path to a JSON file containing the catalog.
If string, this must be a path or URL to an ESM catalog JSON file.
If dict, this must be a dict representation of an ESM catalog.
This dict must have two keys: 'esmcat' and 'df'. The 'esmcat' key must be a
Expand Down Expand Up @@ -79,7 +80,7 @@ class esm_datastore(Catalog):

def __init__(
self,
obj: pydantic.FilePath | pydantic.AnyUrl | dict[str, typing.Any],
obj: pydantic.FilePath | pydantic.AnyUrl | dict[str, typing.Any] | ESMCatalogModel,
*,
progressbar: bool = True,
sep: str = '.',
Expand All @@ -104,7 +105,9 @@ def __init__(
self.read_csv_kwargs = read_csv_kwargs
self.progressbar = progressbar
self.sep = sep
if isinstance(obj, dict):
if isinstance(obj, ESMCatalogModel):
self.esmcat = obj
elif isinstance(obj, dict):
self.esmcat = ESMCatalogModel.from_dict(obj)
else:
self.esmcat = ESMCatalogModel.load(
Expand Down
1 change: 1 addition & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def func_multivar(ds):
(multi_variable_cat, '*', {'converters': {'variable': ast.literal_eval}}, None),
(multi_variable_cat, '*', None, ['variable']),
({'esmcat': sample_esmcat_data, 'df': sample_df}, '.', None, None),
(intake_esm.cat.ESMCatalogModel.load(cdf_cat_sample_cmip6), '.', None, None),
],
)
def test_catalog_init(capsys, obj, sep, read_csv_kwargs, columns_with_iterables):
Expand Down
Loading