freva-client 2507.0.0__tar.gz → 2508.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of freva-client might be problematic. Click here for more details.

Files changed (20) hide show
  1. {freva_client-2507.0.0 → freva_client-2508.0.0}/PKG-INFO +1 -1
  2. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/__init__.py +1 -1
  3. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/utils/auth_utils.py +1 -1
  4. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/utils/databrowser_utils.py +24 -11
  5. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/utils/logger.py +1 -1
  6. {freva_client-2507.0.0 → freva_client-2508.0.0}/MANIFEST.in +0 -0
  7. {freva_client-2507.0.0 → freva_client-2508.0.0}/README.md +0 -0
  8. {freva_client-2507.0.0 → freva_client-2508.0.0}/assets/share/freva/freva.toml +0 -0
  9. {freva_client-2507.0.0 → freva_client-2508.0.0}/pyproject.toml +0 -0
  10. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/__main__.py +0 -0
  11. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/auth.py +0 -0
  12. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/__init__.py +0 -0
  13. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/auth_cli.py +0 -0
  14. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/cli_app.py +0 -0
  15. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/cli_parser.py +0 -0
  16. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/cli_utils.py +0 -0
  17. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/cli/databrowser_cli.py +0 -0
  18. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/py.typed +0 -0
  19. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/query.py +0 -0
  20. {freva_client-2507.0.0 → freva_client-2508.0.0}/src/freva_client/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: freva-client
3
- Version: 2507.0.0
3
+ Version: 2508.0.0
4
4
  Summary: Search for climate data based on key-value pairs
5
5
  Author-email: "DKRZ, Clint" <freva@dkrz.de>
6
6
  Requires-Python: >=3.8
@@ -17,5 +17,5 @@ need to apply data analysis plugins, please visit the
17
17
  from .auth import authenticate
18
18
  from .query import databrowser
19
19
 
20
- __version__ = "2507.0.0"
20
+ __version__ = "2508.0.0"
21
21
  __all__ = ["authenticate", "databrowser", "__version__"]
@@ -86,7 +86,7 @@ def is_jupyter_notebook() -> bool:
86
86
  True if inside a Jupyter notebook or Jupyter kernel.
87
87
  """
88
88
  try:
89
- from IPython import get_ipython
89
+ from IPython import get_ipython # type: ignore[attr-defined]
90
90
 
91
91
  return get_ipython() is not None # pragma: no cover
92
92
  except Exception:
@@ -215,7 +215,7 @@ class UserDataHandler:
215
215
  def __init__(self, userdata_items: List[Union[str, xr.Dataset]]) -> None:
216
216
  self._suffixes = [".nc", ".nc4", ".grb", ".grib", ".zarr", "zar"]
217
217
  self.user_metadata: List[
218
- Dict[str, Union[str, List[str], Dict[str, str]]]
218
+ Dict[str, Union[str, List[str], Dict[str, str], None]]
219
219
  ] = []
220
220
  self._metadata_collection: List[Dict[str, Union[str, List[str]]]] = []
221
221
  try:
@@ -228,9 +228,12 @@ class UserDataHandler:
228
228
 
229
229
  def _gather_files(self, path: Path, pattern: str = "*") -> Iterator[Path]:
230
230
  """Gather all valid files from directory and wildcard pattern."""
231
- for item in path.rglob(pattern):
232
- if item.is_file() and item.suffix in self._suffixes:
233
- yield item
231
+ try:
232
+ for item in path.rglob(pattern):
233
+ if item.is_file() and item.suffix in self._suffixes:
234
+ yield item
235
+ except (OSError, PermissionError) as e: # pragma: no cover
236
+ logger.warning(f"Error accessing path {path}: {e}")
234
237
 
235
238
  def _validate_user_data(
236
239
  self,
@@ -328,7 +331,7 @@ class UserDataHandler:
328
331
 
329
332
  def _get_metadata(
330
333
  self, path: Union[os.PathLike[str], xr.Dataset]
331
- ) -> Dict[str, Union[str, List[str], Dict[str, str]]]:
334
+ ) -> Dict[str, Optional[Union[str, List[str], Dict[str, str]]]]:
332
335
  """Get metadata from a path or xarray dataset."""
333
336
  time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)
334
337
  try:
@@ -352,9 +355,12 @@ class UserDataHandler:
352
355
  return {}
353
356
  if len(times) > 0:
354
357
  try:
355
- time_str = (
356
- f"[{times[0].isoformat()}Z TO {times[-1].isoformat()}Z]"
357
- )
358
+ try:
359
+ time_str = (
360
+ f"[{times[0].isoformat()}Z TO {times[-1].isoformat()}Z]"
361
+ )
362
+ except (AttributeError, IndexError):
363
+ time_str = "fx"
358
364
  dt = (
359
365
  abs((times[1] - times[0]).total_seconds())
360
366
  if len(times) > 1
@@ -389,8 +395,15 @@ class UserDataHandler:
389
395
  and var.lower() not in ["rotated_pole", "rot_pole"]
390
396
  ]
391
397
 
392
- _data: Dict[str, Union[str, List[str], Dict[str, str]]] = {}
393
- _data.setdefault("variable", variables[0])
398
+ _data: Dict[str, Optional[Union[str, List[str], Dict[str, str]]]] = {}
399
+ if variables:
400
+ _data.setdefault("variable", variables[0])
401
+ elif data_vars: # pragma: no cover
402
+ _data.setdefault("variable", data_vars[0])
403
+ logger.info(f"No filtered variables found in {path}, using {data_vars[0]}")
404
+ else: # pragma: no cover
405
+ _data.setdefault("variable", None)
406
+ logger.warning(f"No data variables found in {path}")
394
407
  _data.setdefault(
395
408
  "time_frequency", self._get_time_frequency(dt, time_freq)
396
409
  )
@@ -400,5 +413,5 @@ class UserDataHandler:
400
413
  if isinstance(path, Path):
401
414
  _data["file"] = str(path)
402
415
  if isinstance(path, xr.Dataset):
403
- _data["file"] = str(dset.encoding["source"])
416
+ _data["file"] = dset.encoding.get("source", None)
404
417
  return _data
@@ -8,7 +8,7 @@ from rich.console import Console
8
8
  from rich.logging import RichHandler
9
9
 
10
10
  try:
11
- from IPython import get_ipython
11
+ from IPython import get_ipython # type: ignore[attr-defined]
12
12
  except ImportError:
13
13
  get_ipython = lambda: None # noqa: E731
14
14