freva-client 2404.0.1__py3-none-any.whl → 2408.0.0.dev2__py3-none-any.whl
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.
- freva_client/__init__.py +3 -2
- freva_client/auth.py +197 -0
- freva_client/cli/auth_cli.py +71 -0
- freva_client/cli/cli_app.py +22 -9
- freva_client/cli/cli_parser.py +152 -0
- freva_client/cli/cli_utils.py +13 -147
- freva_client/cli/databrowser_cli.py +177 -9
- freva_client/query.py +166 -23
- freva_client/utils/__init__.py +1 -1
- freva_client/utils/databrowser_utils.py +26 -9
- freva_client/utils/logger.py +2 -2
- {freva_client-2404.0.1.dist-info → freva_client-2408.0.0.dev2.dist-info}/METADATA +3 -1
- freva_client-2408.0.0.dev2.dist-info/RECORD +19 -0
- freva_client-2404.0.1.dist-info/RECORD +0 -16
- {freva_client-2404.0.1.data → freva_client-2408.0.0.dev2.data}/data/share/freva/freva.toml +0 -0
- {freva_client-2404.0.1.dist-info → freva_client-2408.0.0.dev2.dist-info}/WHEEL +0 -0
- {freva_client-2404.0.1.dist-info → freva_client-2408.0.0.dev2.dist-info}/entry_points.txt +0 -0
|
@@ -26,8 +26,8 @@ class Config:
|
|
|
26
26
|
uniq_key: Literal["file", "uri"] = "file",
|
|
27
27
|
flavour: str = "freva",
|
|
28
28
|
) -> None:
|
|
29
|
-
|
|
30
|
-
self.
|
|
29
|
+
self.databrowser_url = f"{self.get_api_url(host)}/databrowser"
|
|
30
|
+
self.auth_url = f"{self.get_api_url(host)}/auth/v2"
|
|
31
31
|
self.uniq_key = uniq_key
|
|
32
32
|
self._flavour = flavour
|
|
33
33
|
|
|
@@ -57,7 +57,9 @@ class Config:
|
|
|
57
57
|
host = f"{host}:{port}"
|
|
58
58
|
return f"{scheme}://{host}"
|
|
59
59
|
|
|
60
|
-
def _read_config(
|
|
60
|
+
def _read_config(
|
|
61
|
+
self, path: Path, file_type: Literal["toml", "ini"]
|
|
62
|
+
) -> str:
|
|
61
63
|
"""Read the configuration."""
|
|
62
64
|
data_types = {"toml": self._read_toml, "ini": self._read_ini}
|
|
63
65
|
try:
|
|
@@ -72,7 +74,9 @@ class Config:
|
|
|
72
74
|
try:
|
|
73
75
|
res = requests.get(f"{self.databrowser_url}/overview", timeout=3)
|
|
74
76
|
except requests.exceptions.ConnectionError:
|
|
75
|
-
raise ValueError(
|
|
77
|
+
raise ValueError(
|
|
78
|
+
f"Could not connect to {self.databrowser_url}"
|
|
79
|
+
) from None
|
|
76
80
|
return cast(Dict[str, Any], res.json())
|
|
77
81
|
|
|
78
82
|
def _get_databrowser_host_from_config(self) -> str:
|
|
@@ -87,7 +91,9 @@ class Config:
|
|
|
87
91
|
Path(appdirs.user_config_dir("freva")) / "freva.toml": "toml",
|
|
88
92
|
Path(self.get_dirs(user=True)) / "freva.toml": "toml",
|
|
89
93
|
freva_config: "toml",
|
|
90
|
-
Path(
|
|
94
|
+
Path(
|
|
95
|
+
os.environ.get("EVALUATION_SYSTEM_CONFIG_FILE") or eval_conf
|
|
96
|
+
): "ini",
|
|
91
97
|
}
|
|
92
98
|
for config_path, config_type in paths.items():
|
|
93
99
|
if config_path.is_file():
|
|
@@ -114,13 +120,24 @@ class Config:
|
|
|
114
120
|
@property
|
|
115
121
|
def search_url(self) -> str:
|
|
116
122
|
"""Define the data search endpoint."""
|
|
117
|
-
return f"{self.databrowser_url}/data_search/
|
|
123
|
+
return f"{self.databrowser_url}/data_search/{self.flavour}/{self.uniq_key}"
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def zarr_loader_url(self) -> str:
|
|
127
|
+
"""Define the url for getting zarr files."""
|
|
128
|
+
return f"{self.databrowser_url}/load/{self.flavour}/"
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def intake_url(self) -> str:
|
|
132
|
+
"""Define the url for creating intake catalogues."""
|
|
133
|
+
return f"{self.databrowser_url}/intake_catalogue/{self.flavour}/{self.uniq_key}"
|
|
118
134
|
|
|
119
135
|
@property
|
|
120
136
|
def metadata_url(self) -> str:
|
|
121
137
|
"""Define the endpoint for the metadata search."""
|
|
122
138
|
return (
|
|
123
|
-
f"{self.databrowser_url}/metadata_search/"
|
|
139
|
+
f"{self.databrowser_url}/metadata_search/"
|
|
140
|
+
f"{self.flavour}/{self.uniq_key}"
|
|
124
141
|
)
|
|
125
142
|
|
|
126
143
|
@staticmethod
|
|
@@ -132,7 +149,7 @@ class Config:
|
|
|
132
149
|
scheme = scheme or "http"
|
|
133
150
|
return scheme, hostname
|
|
134
151
|
|
|
135
|
-
def
|
|
152
|
+
def get_api_url(self, url: Optional[str]) -> str:
|
|
136
153
|
"""Construct the databrowser url from a given hostname."""
|
|
137
154
|
url = url or self._get_databrowser_host_from_config()
|
|
138
155
|
scheme, hostname = self._split_url(url)
|
|
@@ -140,7 +157,7 @@ class Config:
|
|
|
140
157
|
if port:
|
|
141
158
|
hostname = f"{hostname}:{port}"
|
|
142
159
|
hostname = hostname.partition("/")[0]
|
|
143
|
-
return f"{scheme}://{hostname}/api
|
|
160
|
+
return f"{scheme}://{hostname}/api"
|
|
144
161
|
|
|
145
162
|
@staticmethod
|
|
146
163
|
def get_dirs(user: bool = True) -> Path:
|
freva_client/utils/logger.py
CHANGED
|
@@ -21,10 +21,10 @@ logger_format = logging.Formatter(
|
|
|
21
21
|
|
|
22
22
|
logger_stream_handle = RichHandler(
|
|
23
23
|
rich_tracebacks=True,
|
|
24
|
-
show_path=
|
|
24
|
+
show_path=False,
|
|
25
25
|
markup=True,
|
|
26
26
|
log_time_format="[%Y-%m-%dT%H:%M:%S]",
|
|
27
|
-
console=Console(soft_wrap=
|
|
27
|
+
console=Console(soft_wrap=False, stderr=True),
|
|
28
28
|
)
|
|
29
29
|
logger_stream_handle.setLevel(logging.ERROR)
|
|
30
30
|
logging.basicConfig(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: freva-client
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2408.0.0.dev2
|
|
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
|
|
@@ -18,7 +18,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Requires-Dist: appdirs
|
|
20
20
|
Requires-Dist: pyyaml
|
|
21
|
+
Requires-Dist: authlib
|
|
21
22
|
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: intake_esm
|
|
22
24
|
Requires-Dist: rich
|
|
23
25
|
Requires-Dist: tomli
|
|
24
26
|
Requires-Dist: typer
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
freva_client/__init__.py,sha256=wewJE1Pd4LfDcnunOWIoFa4LldlxMdSvoQmFlCRvWHY,856
|
|
2
|
+
freva_client/__main__.py,sha256=JVj12puT4o8JfhKLAggR2-NKCZa3wKwsYGi4HQ61DOQ,149
|
|
3
|
+
freva_client/auth.py,sha256=80avhfDzZuDH7hxZuR5eHsbYU9OnMHrPbqqZbX13aLk,6517
|
|
4
|
+
freva_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
freva_client/query.py,sha256=VJHUxuESORsXgyqFs7xbCpoGjCmQikM3453yMtOEmFw,27950
|
|
6
|
+
freva_client/cli/__init__.py,sha256=NgTqBZGdozmTZtJduJUMrZj-opGw2KoT20tg6sc_xqo,149
|
|
7
|
+
freva_client/cli/auth_cli.py,sha256=_WaEL6iSeE2agv-G-qka-cC6UoedtfoCAC_Vqfk0jKw,1856
|
|
8
|
+
freva_client/cli/cli_app.py,sha256=qiOm1-tak_dei4TNilZ09S5lowJ4DMw0mGYFH65zDpo,782
|
|
9
|
+
freva_client/cli/cli_parser.py,sha256=c-_WG56g6arLvnayb9SO1OeHt7AjBV4egI_vTEYee4I,5042
|
|
10
|
+
freva_client/cli/cli_utils.py,sha256=ygwkNYqnjYJFRQu1M0r1VFQLAAl5lT05bM4tVsR0Xpc,841
|
|
11
|
+
freva_client/cli/databrowser_cli.py,sha256=kFu44cAzwQ-HLd--d649ER6BCCxjRt9LeJA7xgIBlJ4,20924
|
|
12
|
+
freva_client/utils/__init__.py,sha256=ySHn-3CZBwfZW2s0EpZ3INxUWOw1V4LOlKIxSLYr52U,1000
|
|
13
|
+
freva_client/utils/databrowser_utils.py,sha256=sPnPk8KgQSztfr7sDrBYillFiSzYIB5if66pv-VFR40,6380
|
|
14
|
+
freva_client/utils/logger.py,sha256=xd_3jjbsD1UBWlZZe8OUtKLpG7lbLcH46yiJ_bftyKg,2464
|
|
15
|
+
freva_client-2408.0.0.dev2.data/data/share/freva/freva.toml,sha256=64Rh4qvWc9TaGJMXMi8tZW14FnESt5Z24y17BfD2VyM,736
|
|
16
|
+
freva_client-2408.0.0.dev2.dist-info/entry_points.txt,sha256=zGyEwHrH_kAGLsCXv00y7Qnp-WjXkUuIomHkfGMCxtA,53
|
|
17
|
+
freva_client-2408.0.0.dev2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
18
|
+
freva_client-2408.0.0.dev2.dist-info/METADATA,sha256=5SnVCl-nKZL-BMuwmfQEx4YqyWY3XOmbKK1z6QDNBhI,2455
|
|
19
|
+
freva_client-2408.0.0.dev2.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
freva_client/__init__.py,sha256=G-ctas9phozvNBeV56A5lIRz5aphHL0hssBjuefvU3Y,804
|
|
2
|
-
freva_client/__main__.py,sha256=JVj12puT4o8JfhKLAggR2-NKCZa3wKwsYGi4HQ61DOQ,149
|
|
3
|
-
freva_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
freva_client/query.py,sha256=WE1g51ssTu2lsHVD5WR7w3Be952K0LVQOiYZ_fN-0gY,23388
|
|
5
|
-
freva_client/cli/__init__.py,sha256=NgTqBZGdozmTZtJduJUMrZj-opGw2KoT20tg6sc_xqo,149
|
|
6
|
-
freva_client/cli/cli_app.py,sha256=RUEjGpvZLPQE4lrxfUg9r71NeQ7XtZ2THNPwqhDOLQk,504
|
|
7
|
-
freva_client/cli/cli_utils.py,sha256=9RzwQ51Z4vq6sWcKucUqNXOFWg9GeU5Pjesq3ojOlBs,5471
|
|
8
|
-
freva_client/cli/databrowser_cli.py,sha256=Ldj8OBZ0MWMhJ7-7eu9wKs6CaTrreP8PKoYumKSOxng,15365
|
|
9
|
-
freva_client/utils/__init__.py,sha256=g3-UbSpF5Z-EaDi1xJbOYvLqB1YfDyBvPTHWDIKpMvo,999
|
|
10
|
-
freva_client/utils/databrowser_utils.py,sha256=TBTE1hZ7_wTydKV4fbiIm6A0cBwvYgZgvZdW9dmh6EE,5884
|
|
11
|
-
freva_client/utils/logger.py,sha256=PiYIlW7z7dnrZ6f4DGuWU0Vu7pHg4QBGbpHNmoQX3mw,2462
|
|
12
|
-
freva_client-2404.0.1.data/data/share/freva/freva.toml,sha256=64Rh4qvWc9TaGJMXMi8tZW14FnESt5Z24y17BfD2VyM,736
|
|
13
|
-
freva_client-2404.0.1.dist-info/entry_points.txt,sha256=zGyEwHrH_kAGLsCXv00y7Qnp-WjXkUuIomHkfGMCxtA,53
|
|
14
|
-
freva_client-2404.0.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
15
|
-
freva_client-2404.0.1.dist-info/METADATA,sha256=-9SIyTizpDiOqhs76viVfAAn7RKUqjODBhHgchSRJEM,2401
|
|
16
|
-
freva_client-2404.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|