freva-client 2506.0.1__tar.gz → 2507.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-2506.0.1 → freva_client-2507.0.0}/PKG-INFO +7 -7
  2. {freva_client-2506.0.1 → freva_client-2507.0.0}/README.md +3 -3
  3. {freva_client-2506.0.1 → freva_client-2507.0.0}/pyproject.toml +3 -3
  4. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/__init__.py +1 -1
  5. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/auth.py +3 -7
  6. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/auth_cli.py +0 -1
  7. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/databrowser_cli.py +4 -1
  8. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/query.py +38 -0
  9. {freva_client-2506.0.1 → freva_client-2507.0.0}/MANIFEST.in +0 -0
  10. {freva_client-2506.0.1 → freva_client-2507.0.0}/assets/share/freva/freva.toml +0 -0
  11. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/__main__.py +0 -0
  12. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/__init__.py +0 -0
  13. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_app.py +0 -0
  14. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_parser.py +0 -0
  15. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_utils.py +0 -0
  16. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/py.typed +0 -0
  17. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/__init__.py +0 -0
  18. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/auth_utils.py +0 -0
  19. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/databrowser_utils.py +0 -0
  20. {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/logger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: freva-client
3
- Version: 2506.0.1
3
+ Version: 2507.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
@@ -26,18 +26,18 @@ Requires-Dist: setuptools
26
26
  Requires-Dist: tomli
27
27
  Requires-Dist: typer
28
28
  Requires-Dist: tox ; extra == "dev"
29
- Project-URL: Documentation, https://freva-clint.github.io/freva-nextgen
30
- Project-URL: Issues, https://github.com/FREVA-CLINT/freva-nextgen/issues
31
- Project-URL: Source, https://github.com/FREVA-CLINT/freva-nextgen/
29
+ Project-URL: Documentation, https://freva-org.github.io/freva-nextgen
30
+ Project-URL: Issues, https://github.com/freva-org/freva-nextgen/issues
31
+ Project-URL: Source, https://github.com/freva-org/freva-nextgen/
32
32
  Provides-Extra: dev
33
33
 
34
34
  # A REST API for the freva databrowser
35
35
 
36
36
  [![License](https://img.shields.io/badge/License-BSD-purple.svg)](LICENSE)
37
37
  [![PyPI](https://img.shields.io/pypi/pyversions/freva-client.svg)](https://pypi.org/project/freva-client/)
38
- [![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/freva-nextgen)
39
- [![Tests](https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/freva-nextgen/actions)
40
- [![Test-Coverage](https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/freva-nextgen)
38
+ [![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-org.github.io/freva-nextgen)
39
+ [![Tests](https://github.com/freva-org/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/freva-org/freva-nextgen/actions)
40
+ [![Test-Coverage](https://codecov.io/github/freva-org/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/freva-org/freva-nextgen)
41
41
 
42
42
  The freva-client library is a small library that makes connections to the freva
43
43
  server. The client library currently supports the following services:
@@ -2,9 +2,9 @@
2
2
 
3
3
  [![License](https://img.shields.io/badge/License-BSD-purple.svg)](LICENSE)
4
4
  [![PyPI](https://img.shields.io/pypi/pyversions/freva-client.svg)](https://pypi.org/project/freva-client/)
5
- [![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-clint.github.io/freva-nextgen)
6
- [![Tests](https://github.com/FREVA-CLINT/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/FREVA-CLINT/freva-nextgen/actions)
7
- [![Test-Coverage](https://codecov.io/github/FREVA-CLINT/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/FREVA-CLINT/freva-nextgen)
5
+ [![Docs](https://img.shields.io/badge/API-Doc-green.svg)](https://freva-org.github.io/freva-nextgen)
6
+ [![Tests](https://github.com/freva-org/freva-nextgen/actions/workflows/ci_job.yml/badge.svg)](https://github.com/freva-org/freva-nextgen/actions)
7
+ [![Test-Coverage](https://codecov.io/github/freva-org/freva-nextgen/branch/init/graph/badge.svg?token=dGhXxh7uP3)](https://codecov.io/github/freva-org/freva-nextgen)
8
8
 
9
9
  The freva-client library is a small library that makes connections to the freva
10
10
  server. The client library currently supports the following services:
@@ -35,9 +35,9 @@ dependencies = [
35
35
  [project.scripts]
36
36
  freva-client = "freva_client:cli.app"
37
37
  [project.urls]
38
- Documentation = "https://freva-clint.github.io/freva-nextgen"
39
- Issues = "https://github.com/FREVA-CLINT/freva-nextgen/issues"
40
- Source = "https://github.com/FREVA-CLINT/freva-nextgen/"
38
+ Documentation = "https://freva-org.github.io/freva-nextgen"
39
+ Issues = "https://github.com/freva-org/freva-nextgen/issues"
40
+ Source = "https://github.com/freva-org/freva-nextgen/"
41
41
 
42
42
  [project.optional-dependencies]
43
43
  dev = ["tox"]
@@ -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__ = "2506.0.1"
20
+ __version__ = "2507.0.0"
21
21
  __all__ = ["authenticate", "databrowser", "__version__"]
@@ -243,17 +243,16 @@ class Auth:
243
243
  config: Optional[Config] = None,
244
244
  *,
245
245
  force: bool = False,
246
- _auto: bool = True,
247
246
  _cli: bool = False,
248
247
  ) -> Token:
249
248
  """Authenticate the user to the host."""
250
249
  cfg = config or Config(host)
251
250
  token = self._auth_token or load_token(self.token_file)
252
251
  reason: Optional[str] = None
253
- if _auto:
254
- strategy = choose_token_strategy(token)
255
- else:
252
+ if force:
256
253
  strategy = "browser_auth"
254
+ else:
255
+ strategy = choose_token_strategy(token)
257
256
  if strategy == "use_token" and token:
258
257
  self._auth_token = token
259
258
  return self._auth_token
@@ -261,8 +260,6 @@ class Auth:
261
260
  if strategy == "refresh_token" and token:
262
261
  return self._refresh(cfg.auth_url, token["refresh_token"])
263
262
  if strategy == "browser_auth":
264
- if _auto:
265
- logger.warning("Automatically launching browser-based login")
266
263
  return self._login(cfg.auth_url, force=force)
267
264
  except AuthError as error:
268
265
  reason = str(error)
@@ -330,5 +327,4 @@ def authenticate(
330
327
  return auth.authenticate(
331
328
  host=host,
332
329
  force=force,
333
- _auto=False,
334
330
  )
@@ -59,6 +59,5 @@ def authenticate_cli(
59
59
  host=host,
60
60
  force=force,
61
61
  _cli=True,
62
- _auto=False,
63
62
  )
64
63
  print(json.dumps(token, indent=3))
@@ -289,7 +289,7 @@ def data_search(
289
289
  token_file: Optional[Path] = typer.Option(
290
290
  None,
291
291
  "--token-file",
292
- "-t",
292
+ "-tf",
293
293
  help=(
294
294
  "Instead of authenticating via code based authentication flow "
295
295
  "you can set the path to the json file that contains a "
@@ -468,6 +468,7 @@ def intake_catalogue(
468
468
  token_file: Optional[Path] = typer.Option(
469
469
  None,
470
470
  "--token-file",
471
+ "-tf",
471
472
  help=(
472
473
  "Instead of authenticating via code based authentication flow "
473
474
  "you can set the path to the json file that contains a "
@@ -861,6 +862,7 @@ def user_data_add(
861
862
  token_file: Optional[Path] = typer.Option(
862
863
  None,
863
864
  "--token-file",
865
+ "-tf",
864
866
  help=(
865
867
  "Instead of authenticating via code based authentication flow "
866
868
  "you can set the path to the json file that contains a "
@@ -917,6 +919,7 @@ def user_data_delete(
917
919
  token_file: Optional[Path] = typer.Option(
918
920
  None,
919
921
  "--token-file",
922
+ "-tf",
920
923
  help=(
921
924
  "Instead of authenticating via code based authentication flow "
922
925
  "you can set the path to the json file that contains a "
@@ -28,6 +28,7 @@ from rich import print as pprint
28
28
 
29
29
  from .auth import Auth
30
30
  from .utils import logger
31
+ from .utils.auth_utils import Token, choose_token_strategy, load_token
31
32
  from .utils.databrowser_utils import Config, UserDataHandler
32
33
 
33
34
  __all__ = ["databrowser"]
@@ -205,6 +206,8 @@ class databrowser:
205
206
 
206
207
  .. code-block:: python
207
208
 
209
+ from freva_client import authenticate
210
+ token_info = authenticate()
208
211
  import xarray as xr
209
212
  dset = xr.open_dataset(
210
213
  zarr_files[0],
@@ -385,6 +388,41 @@ class databrowser:
385
388
  f"Couldn't write catalogue content: {error}"
386
389
  ) from None
387
390
 
391
+ @property
392
+ def auth_token(self) -> Optional[Token]:
393
+ """Get the current OAuth2 token - if it is still valid.
394
+
395
+ Returns
396
+ -------
397
+ Token:
398
+ If the OAuth2 token exists,is valid and can be used it will
399
+ be returned, None otherwise.
400
+
401
+ Example
402
+ -------
403
+
404
+ .. code-block:: python
405
+
406
+ from freva_client import databrowser
407
+ import xarray as xr
408
+ db = databrowser(dataset="cmip6-hsm", stream_zarr=True)
409
+ dset = xr.open_dataset(
410
+ zarr_files[0],
411
+ chunks="auto",
412
+ engine="zarr",
413
+ storage_options={"headers":
414
+ {"Authorization": f"Bearer {db.auth_token['access_token']}"}
415
+ }
416
+ )
417
+ """
418
+ token = self._auth._auth_token or load_token(self._auth.token_file)
419
+ strategy = choose_token_strategy(token)
420
+ if strategy in ("browser_auth", "fail"):
421
+ return None
422
+ if strategy == "refresh_token":
423
+ token = self._auth.authenticate(config=self._cfg)
424
+ return token
425
+
388
426
  def intake_catalogue(self) -> intake_esm.core.esm_datastore:
389
427
  """Create an intake esm catalogue object from the search.
390
428