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.
- {freva_client-2506.0.1 → freva_client-2507.0.0}/PKG-INFO +7 -7
- {freva_client-2506.0.1 → freva_client-2507.0.0}/README.md +3 -3
- {freva_client-2506.0.1 → freva_client-2507.0.0}/pyproject.toml +3 -3
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/__init__.py +1 -1
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/auth.py +3 -7
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/auth_cli.py +0 -1
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/databrowser_cli.py +4 -1
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/query.py +38 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/MANIFEST.in +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/assets/share/freva/freva.toml +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/__main__.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/__init__.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_app.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_parser.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/cli/cli_utils.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/py.typed +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/__init__.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/auth_utils.py +0 -0
- {freva_client-2506.0.1 → freva_client-2507.0.0}/src/freva_client/utils/databrowser_utils.py +0 -0
- {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:
|
|
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-
|
|
30
|
-
Project-URL: Issues, https://github.com/
|
|
31
|
-
Project-URL: Source, https://github.com/
|
|
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)
|
|
37
37
|
[](https://pypi.org/project/freva-client/)
|
|
38
|
-
[](https://freva-
|
|
39
|
-
[](https://freva-org.github.io/freva-nextgen)
|
|
39
|
+
[](https://github.com/freva-org/freva-nextgen/actions)
|
|
40
|
+
[](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)
|
|
4
4
|
[](https://pypi.org/project/freva-client/)
|
|
5
|
-
[](https://freva-
|
|
6
|
-
[](https://freva-org.github.io/freva-nextgen)
|
|
6
|
+
[](https://github.com/freva-org/freva-nextgen/actions)
|
|
7
|
+
[](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-
|
|
39
|
-
Issues = "https://github.com/
|
|
40
|
-
Source = "https://github.com/
|
|
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"]
|
|
@@ -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
|
|
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
|
)
|
|
@@ -289,7 +289,7 @@ def data_search(
|
|
|
289
289
|
token_file: Optional[Path] = typer.Option(
|
|
290
290
|
None,
|
|
291
291
|
"--token-file",
|
|
292
|
-
"-
|
|
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
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|