|
9 | 9 | from typing import Any, Deque, List, Optional, Union |
10 | 10 | from urllib.parse import urlparse |
11 | 11 |
|
| 12 | +from packaging.version import Version |
| 13 | + |
12 | 14 | from imas.backends.db_entry_impl import GetSampleParameters, GetSliceParameters |
13 | 15 | from imas.db_entry import DBEntryImpl |
14 | 16 | from imas.exception import DataEntryException, LowlevelError |
@@ -187,13 +189,7 @@ def get( |
187 | 189 | if lazy and self.backend == "ascii": |
188 | 190 | raise RuntimeError("Lazy loading is not supported by the ASCII backend.") |
189 | 191 | if self.backend == "uda": |
190 | | - # cache_mode=none doesn't work right now, so the warning won't recommend it |
191 | | - # See: https://jira.iter.org/browse/IMAS-5644 |
192 | | - if lazy and self._querydict.get("cache_mode") != "none": |
193 | | - logger.warning( |
194 | | - "The UDA backend will load all IDS data from the remote server. " |
195 | | - "Lazy loading with the UDA backend may therefore still be slow." |
196 | | - ) |
| 192 | + self._check_uda_warnings(lazy) |
197 | 193 |
|
198 | 194 | # Mixing contexts can be problematic, ensure all lazy contexts are closed: |
199 | 195 | self._clear_lazy_ctx_cache() |
@@ -350,3 +346,28 @@ def list_all_occurrences(self, ids_name: str) -> List[int]: |
350 | 346 | "Access Layer 5.1 or newer is required." |
351 | 347 | ) from None |
352 | 348 | return occurrence_list |
| 349 | + |
| 350 | + def _check_uda_warnings(self, lazy: bool) -> None: |
| 351 | + """Various checks / warnings for the UDA backend.""" |
| 352 | + cache_mode = self._querydict.get("cache_mode") |
| 353 | + if lazy and cache_mode != "none": |
| 354 | + # cache_mode=none requires imas core 5.5.1 or newer, and a recent enough UDA |
| 355 | + # server plugin (which we cannot check...) |
| 356 | + cache_mode_hint = "" |
| 357 | + if ll_interface._al_version >= Version("5.5.1"): |
| 358 | + cache_mode_hint = ( |
| 359 | + "\nYou may add the parameter ';cache_mode=none' to the IMAS URI " |
| 360 | + "to avoid loading all of the data from the remote server." |
| 361 | + ) |
| 362 | + logger.warning( |
| 363 | + "The UDA backend will load all IDS data from the remote server. " |
| 364 | + "Lazy loading with the UDA backend may therefore still be slow.%s", |
| 365 | + cache_mode_hint, |
| 366 | + ) |
| 367 | + |
| 368 | + if cache_mode == "none" and ll_interface._al_version < Version("5.5.1"): |
| 369 | + logger.warning( |
| 370 | + "UDA option 'cache_mode=None' may not work correctly with " |
| 371 | + "IMAS Core version %s.", |
| 372 | + ll_interface._al_version, |
| 373 | + ) |
0 commit comments