Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to_collection method returning an Xcollection #405

Merged
merged 35 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
756c436
add wildcard
jukent Sep 18, 2020
90fd1ce
linting
jukent Sep 18, 2020
6524705
Merge branch 'master' of github.com:jukent/intake-esm
jukent Nov 8, 2021
f5501a1
first pass at editing to_dataset_dict
jukent Nov 8, 2021
955c3ed
add xcollection to intake-esm requirements
jukent Nov 8, 2021
474e23e
Merge branch 'intake:main' into collection
jukent Nov 24, 2021
5fc56fb
first pass at collection
jukent Nov 24, 2021
3b1626f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
500357c
rm xr from imports
jukent Nov 24, 2021
52af83e
Merge branch 'collection' of github.com:jukent/intake-esm into collec…
jukent Nov 24, 2021
3c07c6d
git syntax
jukent Nov 24, 2021
7496fa7
pin mamba version
jukent Nov 24, 2021
0e4194a
Delete wildcard.ipynb
jukent Nov 24, 2021
ff58201
unpin mamba
jukent Nov 24, 2021
f62c2e3
Update requirements.txt
Nov 24, 2021
d8af735
update setup.py
jukent Nov 24, 2021
451f8eb
change hack
jukent Nov 24, 2021
3302477
Update requirements.txt
Nov 24, 2021
9d52148
add xarray back
jukent Nov 24, 2021
424be8a
Merge branch 'collection' of github.com:jukent/intake-esm into collec…
jukent Nov 24, 2021
4f9ef5c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
ffa1dd2
Update intake_esm/core.py
jukent Nov 24, 2021
aae8457
add to_dataet_dict original back
jukent Nov 24, 2021
23bd360
call to_dataset_dict
jukent Nov 24, 2021
befc742
update docstring
jukent Nov 24, 2021
b92b7a0
add to_dataset_dict input kwargs
jukent Nov 24, 2021
96a5631
Delete to_datset_dict_test.ipynb
jukent Nov 24, 2021
68f4275
Merge branch 'main' into collection
jukent Nov 24, 2021
dfdb763
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
755dce2
add test
jukent Nov 24, 2021
5dfea27
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
d65e9b1
get parameterize
jukent Nov 24, 2021
f8aa214
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2021
0ee96ad
use published xcollection
jukent Nov 24, 2021
254f709
Update intake_esm/core.py
jukent Nov 24, 2021
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
14 changes: 8 additions & 6 deletions intake_esm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pandas as pd
import pydantic
import xarray as xr
import xcollection as xc
from fastprogress.fastprogress import progress_bar
from intake.catalog import Catalog

Expand Down Expand Up @@ -441,9 +442,9 @@ def to_dataset_dict(
aggregate: pydantic.StrictBool = None,
skip_on_error: pydantic.StrictBool = False,
**kwargs,
) -> typing.Dict[str, xr.Dataset]:
) -> typing.Collection[str, xc.Collection]:
jukent marked this conversation as resolved.
Show resolved Hide resolved
"""
Load catalog entries into a dictionary of xarray datasets.
Load catalog entries into a Collection of xarray datasets.

Parameters
----------
Expand All @@ -466,8 +467,8 @@ def to_dataset_dict(

Returns
-------
dsets : dict
A dictionary of xarray :py:class:`~xarray.Dataset`.
dsets : Collection
A Collection of xarray :py:class:`~xarray.Dataset`.

Examples
--------
Expand Down Expand Up @@ -506,7 +507,7 @@ def to_dataset_dict(
UserWarning,
stacklevel=2,
)
return {}
return xc.Collection({})

if (
self.esmcat.aggregation_control.variable_column_name
Expand Down Expand Up @@ -548,7 +549,7 @@ def to_dataset_dict(
self.progressbar = progressbar
if self.progressbar:
print(
f"""\n--> The keys in the returned dictionary of datasets are constructed as follows:\n\t'{self.key_template}'"""
f"""\n--> The keys in the returned Collection of datasets are constructed as follows:\n\t'{self.key_template}'"""
)
sources = {key: source(**source_kwargs) for key, source in self.items()}
datasets = {}
Expand All @@ -570,6 +571,7 @@ def to_dataset_dict(
if not skip_on_error:
raise exc
self.datasets = self._create_derived_variables(datasets, skip_on_error)
self.datasets = xc.Collection(self.datasets)
return self.datasets

def _create_derived_variables(self, datasets, skip_on_error):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ requests>=2.24.0
xarray>=0.19
zarr>=2.5
pydantic>=1.8.2
git+https://github.com/NCAR/xcollection.git
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from setuptools import find_packages, setup

with open('requirements.txt') as f:
install_requires = f.read().strip().split('\n')
install_requires = f.read().strip().split('\n')[0:-1]
jukent marked this conversation as resolved.
Show resolved Hide resolved


if exists('README.md'):
Expand Down