Skip to content

Commit 3230a0d

Browse files
maarten-icolivhoenen
authored andcommitted
Update UDA warnings and docs
1 parent aa88658 commit 3230a0d

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

docs/source/lazy_loading.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,13 @@ Lazy loading of data may speed up your programs, but also comes with some limita
9090
more efficient to do a full :code:`get()` or :code:`get_slice()` when you intend to
9191
use most of the data stored in an IDS.
9292
5. When using IMAS-Python with remote data access (i.e. the UDA backend), a full
93-
:code:`get()` or :code:`get_slice()` is more efficient than lazy loading.
93+
:code:`get()` or :code:`get_slice()` may be more efficient than using lazy loading.
94+
95+
It is recommended to add the parameter ``;cache_mode=none`` [#cache_mode_none]_ to
96+
the end of a UDA IMAS URI when using lazy loading: otherwise the UDA backend will
97+
still load the full IDS from the remote server.
98+
99+
100+
.. [#cache_mode_none] The option ``cache_mode=none`` requires IMAS Core version 5.5.1 or
101+
newer, and a remote UDA server with `IMAS UDA-Plugins
102+
<https://github.com/iterorganization/UDA-Plugins>`__ version 1.7.0 or newer.

imas/backends/imas_core/db_entry_al.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from typing import Any, Deque, List, Optional, Union
1010
from urllib.parse import urlparse
1111

12+
from packaging.version import Version
13+
1214
from imas.backends.db_entry_impl import GetSampleParameters, GetSliceParameters
1315
from imas.db_entry import DBEntryImpl
1416
from imas.exception import DataEntryException, LowlevelError
@@ -187,13 +189,7 @@ def get(
187189
if lazy and self.backend == "ascii":
188190
raise RuntimeError("Lazy loading is not supported by the ASCII backend.")
189191
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)
197193

198194
# Mixing contexts can be problematic, ensure all lazy contexts are closed:
199195
self._clear_lazy_ctx_cache()
@@ -350,3 +346,28 @@ def list_all_occurrences(self, ids_name: str) -> List[int]:
350346
"Access Layer 5.1 or newer is required."
351347
) from None
352348
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

Comments
 (0)