Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions imas/backends/imas_core/al_context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is part of IMAS-Python.
# You should have received the IMAS-Python LICENSE file with this project.
"""Object-oriented interface to the IMAS lowlevel.
"""
"""Object-oriented interface to the IMAS lowlevel."""

import logging
import weakref
Expand Down Expand Up @@ -61,17 +60,21 @@ def __enter__(self) -> "ALContext":
def __exit__(self, exc_type, exc_value, traceback) -> None:
ll_interface.end_action(self.ctx)

def global_action(self, path: str, rwmode: int) -> "ALContext":
def global_action(self, path: str, rwmode: int, datapath: str = "") -> "ALContext":
"""Begin a new global action for use in a ``with`` context.

Args:
path: access layer path for this global action: ``<idsname>[/<occurrence>]``
rwmode: read-only or read-write operation mode: ``READ_OP``/``WRITE_OP``
datapath: used by UDA backend to fetch only part of the data.

Returns:
The created context.
"""
status, ctx = ll_interface.begin_global_action(self.ctx, path, rwmode)
args = [self.ctx, path, rwmode]
if datapath: # AL4 compatibility: datapath arg was added in AL5
args.append(datapath)
status, ctx = ll_interface.begin_global_action(*args)
if status != 0:
raise LowlevelError("global_action", status)
return ALContext(ctx)
Expand Down
6 changes: 4 additions & 2 deletions imas/backends/imas_core/db_entry_al.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def get(
if occurrence != 0:
ll_path += f"/{occurrence}"

with self._db_ctx.global_action(ll_path, READ_OP) as read_ctx:
datapath = "ids_properties" if self.backend == "uda" else ""
with self._db_ctx.global_action(ll_path, READ_OP, datapath) as read_ctx:
time_mode_path = "ids_properties/homogeneous_time"
time_mode = read_ctx.read_data(time_mode_path, "", INTEGER_DATA, 0)
# This is already checked by read_dd_version, but ensure:
Expand Down Expand Up @@ -314,7 +315,8 @@ def read_dd_version(self, ids_name: str, occurrence: int) -> str:
if occurrence != 0:
ll_path += f"/{occurrence}"

with self._db_ctx.global_action(ll_path, READ_OP) as read_ctx:
datapath = "ids_properties" if self.backend == "uda" else ""
with self._db_ctx.global_action(ll_path, READ_OP, datapath) as read_ctx:
time_mode_path = "ids_properties/homogeneous_time"
time_mode = read_ctx.read_data(time_mode_path, "", INTEGER_DATA, 0)
dd_version_path = "ids_properties/version_put/data_dictionary"
Expand Down
Loading