imas.backends.imas_core.al_context.LazyALContext

class imas.backends.imas_core.al_context.LazyALContext(parent_ctx: LazyALContext | None = None, method: Callable | None = None, args: tuple = (), *, dbentry: ALDBEntryImpl | None = None, nbc_map: NBCPathMap | None = None, time_mode: int | None = None)

Bases: object

Replacement for ALContext that is used during lazy loading.

This class implements global_action, slice_action and read_data, such that it can be used as a drop-in replacement in imas.db_entry._get_children and only custom logic is needed for IDSStructArray there.

This class tracks:

  • The ALDBEntryImpl object which was used for get() / get_slice().

  • The context object from that ALDBEntryImpl (such that we can detect if the underlying AL context was closed or replaced).

  • Potentially a parent LazyALContext for nested contexts (looking at you, arraystruct_action!).

  • The ALContext method and arguments that we need to call on the ALContext we obtain from our parent, to obtain the actual ALContext we should use for loading data.

  • The NBC map that imas.db_entry._get_children needs when lazy loading children of an IDSStructArray.

When constructing a LazyALContext, you need to supply either the dbentry and nbc_map, or a parent_ctx.

__init__(parent_ctx: LazyALContext | None = None, method: Callable | None = None, args: tuple = (), *, dbentry: ALDBEntryImpl | None = None, nbc_map: NBCPathMap | None = None, time_mode: int | None = None)

Methods

__init__([parent_ctx, method, args, ...])

arraystruct_action(path, timebase, size)

Lazily start an arraystruct action.

get_child(child)

Retrieve a child entry from the field.

get_context()

Create and yield the actual ALContext.

global_action(path, rwmode)

Lazily start a lowlevel global action, see ALContext.global_action()

slice_action(path, rwmode, time_requested, ...)

Lazily start a lowlevel slice action, see ALContext.slice_action()

timerange_action(path, rwmode, tmin, tmax, ...)

Lazily start a lowlevel timerange action, see ALContext.timerange_action().

Attributes

dbentry

ALDBEntryImpl object that created us, or our parent.

dbentry_ctx

The ALContext of the ALDBEntryImpl at the time of get/get_slice.

parent_ctx

Optional parent context that provides our parent ALContext.

method

Method we need to call with our parent ALContext to get our ALContext.

args

Additional arguments we need to supply to self.method

nbc_map

NBC map for _get_children() when lazy loading IDSStructArray items.

time_mode

Time mode used by the IDS being lazy loaded.

context

Potential weak reference to opened context.

args

Additional arguments we need to supply to self.method

arraystruct_action(path: str, timebase: str, size: int) LazyALArrayStructContext

Lazily start an arraystruct action.

context

Potential weak reference to opened context.

dbentry

ALDBEntryImpl object that created us, or our parent.

dbentry_ctx

The ALContext of the ALDBEntryImpl at the time of get/get_slice.

get_child(child)

Retrieve a child entry from the field.

Parameters:
child : str

The name or identifier of the child entry to retrieve.

Returns:

The child entry retrieved from the database.

get_context() ALContext

Create and yield the actual ALContext.

global_action(path: str, rwmode: int) Iterator[LazyALContext]

Lazily start a lowlevel global action, see ALContext.global_action()

method

Method we need to call with our parent ALContext to get our ALContext.

nbc_map

NBC map for _get_children() when lazy loading IDSStructArray items.

parent_ctx

Optional parent context that provides our parent ALContext.

slice_action(path: str, rwmode: int, time_requested: float, interpolation_method: int) Iterator[LazyALContext]

Lazily start a lowlevel slice action, see ALContext.slice_action()

time_mode

Time mode used by the IDS being lazy loaded.

timerange_action(path: str, rwmode: int, tmin: float, tmax: float, dtime: ndarray | None, interpolation_method: int) Iterator[LazyALContext]

Lazily start a lowlevel timerange action, see ALContext.timerange_action().


Last update: 2026-01-28