-
Notifications
You must be signed in to change notification settings - Fork 141
[BUG] open_virtual_dataset raises opaque error when called before login #1274
Description
Is this issue already tracked somewhere, or is this a new report?
- I've reviewed existing issues and couldn't find a duplicate for this problem.
Have you checked the status of Earthdata services?
- I've executed
earthaccess.status()and both CMR and EDL returned'OK'.
Current Behavior
Calling earthaccess.open_virtual_dataset before authenticating with earthaccess.login raises an opaque error. See traceback below.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 vds = earthaccess.open_virtual_dataset(results[0], access="indirect", load=False)
3 vds
File ~/opt/miniforge3/envs/vds312/lib/python3.12/site-packages/earthaccess/dmrpp_zarr.py:240, in open_virtual_dataset(granule, load, group, access)
198 def open_virtual_dataset(
199 granule: earthaccess.DataGranule,
200 load: bool = True,
201 group: str | None = None,
202 access: str = "indirect",
203 ) -> xr.Dataset:
204 """Open a granule as a single virtual xarray Dataset.
205
206 Uses NASA DMR++ metadata files to create a virtual xarray dataset with ManifestArrays. This virtual dataset can be used to create zarr reference files. See [https://virtualizarr.readthedocs.io](https://virtualizarr.readthedocs.io) for more information on virtual xarray datasets.
(...) 238 ```
239 """
--> 240 return open_virtual_mfdataset(
241 granules=[granule],
242 load=load,
243 group=group,
244 access=access,
245 parallel=False,
246 preprocess=None,
247 )
File ~/opt/miniforge3/envs/vds312/lib/python3.12/site-packages/earthaccess/dmrpp_zarr.py:115, in open_virtual_mfdataset(granules, group, access, preprocess, parallel, load, reference_dir, reference_format, **xr_combine_nested_kwargs)
112 raise ValueError("No granules provided. At least one granule is required.")
114 parsed_url = urlparse(granules[0].data_links(access=access)[0])
--> 115 fs = earthaccess.get_fsspec_https_session()
116 if len(granules):
117 collection_id = granules[0]["meta"]["collection-concept-id"]
File ~/opt/miniforge3/envs/vds312/lib/python3.12/site-packages/earthaccess/api.py:553, in get_fsspec_https_session()
537 def get_fsspec_https_session() -> AbstractFileSystem:
538 """Returns a fsspec session that can be used to access datafiles across many different DAACs.
539
540 Returns:
(...) 551 ```
552 """
--> 553 session = earthaccess.__store__.get_fsspec_session()
554 return session
AttributeError: 'NoneType' object has no attribute 'get_fsspec_session'The error indicates that earthaccess.__store__ is None. It's set when the user calls the earthaccess.login routine, as demonstrated below.
>>> import earthaccess
>>> earthaccess.__version__
'0.16.0'
>>> earthaccess.__store__ is None
True
>>> earthaccess.login("netrc")
<earthaccess.auth.Auth object at 0x7f7462df4fe0>
>>> earthaccess.__store__.get_fsspec_session
<bound method Store.get_fsspec_session of <earthaccess.store.Store object at 0x7f99442fb500>>I'm on v0.16.0.
Note that this is in "indirect" access mode. I haven't tested in "direct" access mode.
Expected Behavior
Raise an appropriate exception and remind the user to call earthaccess.login before trying again.
Perhaps that could happen here (called by earthaccess.open_virtual_dataset here).
Sorry in advance if I missed an existing issue about this.
Steps To Reproduce
Import earthaccess and search for any granule. Do not call the login routine. Try open_virtual_dataset in "indirect" access mode. (I haven't tried it in "direct" access mode.)
Environment
- OS: Debian 13, behavior is not os-specific presumably
- Python: 3.12.13Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status