pyfli.io.save_direction#

Turn a save_config dictionary into a ready DataSaver session.

This module belongs to pyfli.io and is part of PyFLI detector importers, file readers, saving helpers, and processed-data loaders. Public API includes the class SaveLoadDirector, which centralizes the branching that decides – from a single config dict – whether a session is saved, loaded, or skipped, and where its folder lives.

Classes

SaveLoadDirector([config])

Resolve a save_config dictionary into a DataSaver session.

class SaveLoadDirector(config=None, **overrides)[source]#

Bases: object

Resolve a save_config dictionary into a DataSaver session.

Instead of scattering if mode == ... / if auto_path ... checks through a script, collect every save/load decision in one dict and hand it to this class. build() returns a writable session (mode='save'), reconnects to an existing one (mode='load'), or returns None (mode=None).

Parameters:
  • config (dict | None) –

    User-supplied settings. Any key that is omitted falls back to DEFAULTS. Recognized keys:

    mode{‘save’, ‘load’, None}

    'save' builds a writable session, 'load' reconnects to an existing one, None disables saving.

    auto_pathbool

    If True, the session folder is derived from DATA_PATH. If False, a manual path is required (see below).

    DATA_PATHstr | None

    Source data path; required when auto_path=True (for both save and load).

    manual_load_pathstr | None

    Exact existing session folder to load; used when mode='load' and auto_path=False.

    manual_save_root_pathstr | None

    Root under which the session folder is created; required when mode='save' and auto_path=False (also accepted as a load root).

    bin_rint

    Spatial binning radius; part of the derived save_suffix.

    versionint

    Analysis version; part of the derived save_suffix.

    new_sessionbool

    Forwarded to DataSaver when mode='save'.

    MODEL_TYPE, free_memorycarried through untouched for

    downstream consumers.

  • **overrides (Any) – Convenience keyword overrides merged on top of config.

config#

The fully merged configuration, including the derived save_suffix.

Type:

dict

DEFAULTS: ClassVar[dict[str, Any]] = {'DATA_PATH': None, 'MODEL_TYPE': 'bi-exponential', 'auto_path': True, 'bin_r': 0, 'free_memory': True, 'manual_load_path': None, 'manual_save_root_path': None, 'mode': 'save', 'new_session': True, 'version': 1}#
VALID_MODES: ClassVar[tuple[str | None, ...]] = ('save', 'load', None)#
get(key, default=None)[source]#

Return self.config[key] if present, else default.

Parameters:
Return type:

Any

to_dict()[source]#

Return a shallow copy of the merged configuration.

Return type:

dict

property save_suffix: str#

Folder-name suffix derived from bin_r and version.

property mode: str | None#

'save', 'load', or None.

Type:

Configured session mode

build()[source]#

Construct the DataSaver described by the configuration.

Returns:

A writable session (mode='save'), a reconnected session (mode='load'), or None (mode=None).

Return type:

DataSaver | None

classmethod from_config(config=None, **overrides)[source]#

One-shot helper: SaveLoadDirector(config, **overrides).build().

Returns:

Same as build().

Return type:

DataSaver | None

Parameters:
  • config (dict | None)

  • overrides (Any)