freva-client 2509.1.0__tar.gz → 2509.2.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-2509.1.0 → freva_client-2509.2.0}/PKG-INFO +1 -1
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/__init__.py +1 -1
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/utils/databrowser_utils.py +44 -33
- {freva_client-2509.1.0 → freva_client-2509.2.0}/MANIFEST.in +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/README.md +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/assets/share/freva/freva.toml +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/pyproject.toml +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/__main__.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/auth.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/__init__.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/auth_cli.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/cli_app.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/cli_parser.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/cli_utils.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/cli/databrowser_cli.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/py.typed +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/query.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/utils/__init__.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/utils/auth_utils.py +0 -0
- {freva_client-2509.1.0 → freva_client-2509.2.0}/src/freva_client/utils/logger.py +0 -0
|
@@ -42,11 +42,18 @@ class Config:
|
|
|
42
42
|
uniq_key: Literal["file", "uri"] = "file",
|
|
43
43
|
flavour: Optional[str] = None,
|
|
44
44
|
) -> None:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
self.
|
|
45
|
+
config_host = host or cast(str, self._get_databrowser_param_from_config("host"))
|
|
46
|
+
|
|
47
|
+
self.databrowser_url = f"{self.get_api_url(config_host)}/databrowser"
|
|
48
|
+
self.auth_url = f"{self.get_api_url(config_host)}/auth/v2"
|
|
49
|
+
self.get_api_main_url = self.get_api_url(config_host)
|
|
48
50
|
self.uniq_key = uniq_key
|
|
49
|
-
self.
|
|
51
|
+
self._flavour = (
|
|
52
|
+
flavour or self._get_databrowser_param_from_config(
|
|
53
|
+
"flavour",
|
|
54
|
+
optional=True
|
|
55
|
+
)
|
|
56
|
+
)
|
|
50
57
|
|
|
51
58
|
@cached_property
|
|
52
59
|
def validate_server(self) -> bool:
|
|
@@ -59,18 +66,17 @@ class Config:
|
|
|
59
66
|
f"Could not connect to {self.databrowser_url}: {e}"
|
|
60
67
|
) from None
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return "freva"
|
|
69
|
+
@property
|
|
70
|
+
def flavour(self) -> str:
|
|
71
|
+
"""Get the flavour, using server default if not configured."""
|
|
72
|
+
if self._flavour:
|
|
73
|
+
return self._flavour
|
|
74
|
+
try:
|
|
75
|
+
flavours = self.overview.get("flavours", [])
|
|
76
|
+
self._flavour = flavours[0] if flavours else "freva"
|
|
77
|
+
except (ValueError, IndexError, KeyError):
|
|
78
|
+
self._flavour = "freva"
|
|
79
|
+
return self._flavour
|
|
74
80
|
|
|
75
81
|
def _read_ini(self, path: Path) -> Dict[str, str]:
|
|
76
82
|
"""Read an ini file.
|
|
@@ -115,8 +121,11 @@ class Config:
|
|
|
115
121
|
"""
|
|
116
122
|
try:
|
|
117
123
|
config = tomli.loads(path.read_text()).get("freva", {})
|
|
118
|
-
|
|
124
|
+
raw_host = cast(str, config.get("host", ""))
|
|
119
125
|
flavour = config.get("default_flavour", "")
|
|
126
|
+
if not raw_host:
|
|
127
|
+
return {"host": "", "flavour": flavour}
|
|
128
|
+
scheme, host = self._split_url(raw_host)
|
|
120
129
|
except (tomli.TOMLDecodeError, KeyError):
|
|
121
130
|
return {}
|
|
122
131
|
host, _, port = host.partition(":")
|
|
@@ -186,9 +195,10 @@ class Config:
|
|
|
186
195
|
f"Could not connect to {self.databrowser_url}"
|
|
187
196
|
) from None
|
|
188
197
|
|
|
189
|
-
def
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
def _get_databrowser_param_from_config(
|
|
199
|
+
self, key: str, optional: bool = False
|
|
200
|
+
) -> Optional[str]:
|
|
201
|
+
"""Get a single config parameter following proper precedence."""
|
|
192
202
|
eval_conf = self.get_dirs(user=False) / "evaluation_system.conf"
|
|
193
203
|
freva_config = Path(
|
|
194
204
|
os.environ.get("FREVA_CONFIG")
|
|
@@ -202,20 +212,22 @@ class Config:
|
|
|
202
212
|
os.environ.get("EVALUATION_SYSTEM_CONFIG_FILE") or eval_conf
|
|
203
213
|
): "ini",
|
|
204
214
|
}
|
|
215
|
+
|
|
205
216
|
for config_path, config_type in paths.items():
|
|
206
217
|
if config_path.is_file():
|
|
207
218
|
config_data = self._read_config(config_path, config_type)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
219
|
+
value = config_data.get(key, "")
|
|
220
|
+
# we cannot igonore the empty string here, because
|
|
221
|
+
# it needs to check the next config file
|
|
222
|
+
if value:
|
|
223
|
+
return value if value else None
|
|
224
|
+
if optional:
|
|
225
|
+
return None
|
|
226
|
+
|
|
215
227
|
raise ValueError(
|
|
216
|
-
"No databrowser
|
|
217
|
-
" configuration defining a databrowser
|
|
218
|
-
" set a host name using the `
|
|
228
|
+
f"No databrowser {key} configured, please use a"
|
|
229
|
+
f" configuration defining a databrowser {key} or"
|
|
230
|
+
f" set a host name using the `{key}` key"
|
|
219
231
|
)
|
|
220
232
|
|
|
221
233
|
@property
|
|
@@ -257,9 +269,8 @@ class Config:
|
|
|
257
269
|
scheme = scheme or "http"
|
|
258
270
|
return scheme, hostname
|
|
259
271
|
|
|
260
|
-
def get_api_url(self, url:
|
|
272
|
+
def get_api_url(self, url: str) -> str:
|
|
261
273
|
"""Construct the databrowser url from a given hostname."""
|
|
262
|
-
url = url or self._get_databrowser_params_from_config().get("host", "")
|
|
263
274
|
scheme, hostname = self._split_url(url)
|
|
264
275
|
hostname, _, port = hostname.partition(":")
|
|
265
276
|
if port:
|
|
@@ -385,7 +396,7 @@ class UserDataHandler:
|
|
|
385
396
|
) -> None:
|
|
386
397
|
for data in validated_userdata:
|
|
387
398
|
metadata = self._get_metadata(data)
|
|
388
|
-
if
|
|
399
|
+
if metadata == {}:
|
|
389
400
|
logger.warning("Error getting metadata: %s", metadata)
|
|
390
401
|
else:
|
|
391
402
|
self.user_metadata.append(metadata)
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|