uclchem.advanced#

UCLCHEM Advanced Module.

Runtime configuration and introspection for UCLCHEM’s Fortran modules.

This package provides class-based interfaces for: - HeatingSettings: Control heating and cooling mechanisms - NetworkState: Access and modify the chemical network state during runtime - GeneralSettings: Access and modify all UCLCHEM settings

Thread Safety Warning: All classes in this module modify global Fortran module state and are NOT thread-safe. Do not use these classes with multiprocessing, multithreading, or concurrent model runs. Settings should only be modified during initialization, before running models.

Submodules#

Package Contents#

Classes#

GeneralSettings

General interface to all UCLCHEM settings across all Fortran modules.

HeatingSettings

Class-based wrapper for UCLCHEM heating and cooling configuration.

NetworkState

Runtime interface to UCLCHEM's compiled chemical network.

RuntimeNetwork

Runtime interface to UCLCHEM's compiled Fortran network.

Functions#

create_snapshot(→ dict[str, Any])

Capture the current Fortran module state into a picklable dict.

restore_snapshot(→ None)

Apply a previously captured snapshot to the current process.

class uclchem.advanced.GeneralSettings[source]#

General interface to all UCLCHEM settings across all Fortran modules.

Provides dynamic access to modifiable parameters in any uclchemwrap module, with automatic detection of read-only PARAMETERs and internal solver settings.

Each setting is represented by a Setting object that tracks: - Current value (with caching) - Edit status - Default value - Metadata (dtype, shape, flags)

Thread Safety Warning:

This class modifies global Fortran module state and is NOT thread-safe. Do not use with multiprocessing or concurrent model runs. Settings should only be modified during initialization, before running models.

Usage:
>>> from uclchem.advanced.advanced_settings import GeneralSettings
>>> settings = GeneralSettings()
>>>
>>> # Access a setting
>>> setting = settings.defaultparameters.initialdens
>>> print(setting.get())
100.0
>>>
>>> # Modify a setting
>>> setting.set(500.0)
>>>
>>> # Get the modified value
>>> print(setting.get())
500.0
>>>
>>> # Or use attribute-style syntax
>>> settings.defaultparameters.initialdens = 500.0
>>>
>>> # List all settings in a module
>>> settings.defaultparameters.print_settings()
...
>>>
>>> # Use context manager for temporary changes
>>> with settings.temporary_changes():
...     settings.defaultparameters.initialdens = 1000.0
...     print(setting.get())
...     # Run model with modified settings
...
1000.0
>>> # Settings automatically restored after context
>>> print(setting.get())
500.0
>>> # As well as in the GeneralSettings instance
>>> print(settings.defaultparameters.initialdens)
Setting(defaultparameters.initialdens = 500.0 [EDITED])
>>>
>>> # Reset to the original value
>>> setting.set(100.0)

Initialize with all available uclchemwrap modules.

list_modules() None[source]#

List all available modules with statistics.

print_all_edited() None[source]#

Print all settings that have been modified from defaults.

print_all_settings() None[source]#

Print all settings across all modules.

reset_all(confirm: bool = True) None[source]#

Reset all settings to their default values.

Parameters:

confirm (bool) – If True, require user confirmation. Default = True.

search(pattern: str, include_internal: bool = False, include_parameters: bool = False) dict[str, Setting][source]#

Search for settings matching a pattern across all modules.

Parameters:
  • pattern (str) – String pattern to search for (case-insensitive).

  • include_internal (bool) – Include internal solver parameters. Default = False.

  • include_parameters (bool) – Include read-only PARAMETERs. Default = False.

Returns:

Dict mapping “module.setting” to Setting objects

Return type:

dict[str, Setting]

temporary_changes() collections.abc.Iterator[GeneralSettings][source]#

Context manager for temporary setting modifications.

Saves current state on entry and restores it on exit, even if an exception occurs. Useful for running models with temporary parameter changes without affecting the global state.

Yields:

self (GeneralSettings) – The GeneralSettings instance for chaining

Examples

>>> settings = GeneralSettings()
>>> settings.defaultparameters.initialdens = 100.0
>>> print(settings.defaultparameters.initialdens.get())
100.0
>>>
>>> with settings.temporary_changes():
...     settings.defaultparameters.initialdens = 5000.0
...     print(settings.defaultparameters.initialdens.get())
...     # Run model here
...
5000.0
>>>
>>> print(settings.defaultparameters.initialdens.get())
100.0
class uclchem.advanced.HeatingSettings[source]#

Class-based wrapper for UCLCHEM heating and cooling configuration.

This class provides access to the heating and cooling mechanism controls, solver parameters, and computed values from heating.f90.

PHOTOELECTRIC#

Photoelectric heating implementations - ‘BAKES’: Bakes & Tielens method (index 1) - ‘WEINGARTNER’: Weingartner method (index 2) (Only one can be enabled at a time)

Type:

dict

H2_FORMATION#

Index for H2 formation heating (3)

Type:

int

H2_PHOTODISSOCIATION#

Index for H2 photodissociation heating (4)

Type:

int

H2_FUV_PUMPING#

Index for H2 FUV pumping heating (5)

Type:

int

CARBON_IONIZATION#

Index for carbon ionization heating (6)

Type:

int

COSMIC_RAY#

Index for cosmic ray heating (7)

Type:

int

TURBULENT#

Index for turbulent heating (8)

Type:

int

GAS_GRAIN_COLLISIONS#

Index for gas-grain collisional heating/cooling (9)

Type:

int

ATOMIC_LINE_COOLING#

Index for atomic line cooling

Type:

int

H2_COLLISIONALLY_INDUCED#

Index for H2 collisionally induced emission

Type:

int

COMPTON_COOLING#

Index for Compton cooling

Type:

int

CONTINUUM_EMISSION#

Index for continuum emission cooling

Type:

int

MOLECULAR_LINE_COOLING#

Index for molecular line cooling

Type:

int

DUST_TEMP_HOCUK#

Hocuk et al. 2017 dust temperature method

Type:

int

DUST_TEMP_HOLLENBACH#

Hollenbach 1991 dust temperature method

Type:

int

COOLANT_WARM#

Warm restart mode - initialize LTE, rescale on density change (default)

Type:

int

COOLANT_FORCE_LTE#

Always reset to LTE before SE iteration (original behavior)

Type:

int

COOLANT_FORCE_GROUND#

Always reset to ground state before SE iteration

Type:

int

Examples

>>> from uclchem.advanced import HeatingSettings
>>> settings = HeatingSettings()
>>> settings.print_configuration()
...
>>> # Switch photoelectric method (auto-disables Bakes when enabling Weingartner)
>>> settings.set_heating_mechanism(settings.PHOTOELECTRIC['WEINGARTNER'], True)
>>> # Disable H2 formation
>>> settings.set_heating_mechanism(settings.H2_FORMATION, False)

Initialize the HeatingSettings wrapper.

This connects to the Fortran heating module and provides access to its configuration parameters. Captures the current state as the default configuration for reset_to_defaults().

get_coolant_active() dict[str, bool][source]#

Get the active state of all line coolant species.

Returns:

Dictionary mapping coolant names to their enabled state

Return type:

dict[str, bool]

Examples

>>> settings = HeatingSettings()
>>> state = settings.get_coolant_active()
>>> print(state)
{'H': True, 'C+': True, 'O': True, ...}
get_coolant_directory() str[source]#

Get the current collisional rate data directory.

Returns:

Directory path as string (stripped of trailing spaces)

Return type:

str

get_coolant_restart_mode() int[source]#

Get the current coolant population restart mode.

Returns:

Current restart mode (0=WARM, 1=FORCE_LTE, 2=FORCE_GROUND)

Return type:

int

get_cooling_modules() dict[str, bool][source]#

Obtain the state (on/off) of all cooling mechanisms.

Returns:

Dictionary mapping mechanism names to their enabled state

Return type:

dict[str, bool]

Examples

>>> settings = HeatingSettings()
>>> state = settings.get_cooling_modules()
>>> print(state['AtomicLineEmission'])
True
get_dust_gas_coupling_method() int[source]#

Get the current dust-gas temperature coupling method.

Returns:

Current method (1=Hocuk, 2=Hollenbach)

Return type:

int

get_heating_modules() dict[str, bool][source]#

Obtain the state (on/off) of all heating mechanisms.

Returns:

Dictionary mapping mechanism names to their enabled state

Return type:

dict[str, bool]

Examples

>>> settings = HeatingSettings()
>>> state = settings.get_heating_modules()
>>> print(state['H2Formation'])
False
get_line_solver_attempts() int[source]#

Get the current number of line cooling solver attempts.

Returns:

Number of solver attempts

Return type:

int

get_pah_abundance() float[source]#

Get the current PAH abundance.

Returns:

PAH abundance

Return type:

float

print_configuration() None[source]#

Print the current heating and cooling configuration.

Examples

>>> settings = HeatingSettings()
>>> settings.print_configuration()
...
reset_to_defaults() None[source]#

Reset all heating and cooling mechanisms to their initial values.

Restores the configuration that was present when this HeatingSettings instance was first initialized. This allows reverting any changes made during the session back to the starting state.

Examples

>>> settings = HeatingSettings()
>>> settings.set_heating_mechanism(settings.H2_FORMATION, False)
>>> settings.reset_to_defaults()  # Restores original state
set_coolant_active(coolant_name: str, enabled: bool = True) None[source]#

Enable or disable a specific line coolant species.

This controls individual coolant species within the molecular line cooling mechanism (cooling_modules index 5). When a coolant is disabled, its level population calculation is skipped entirely and its cooling contribution is set to zero.

Parameters:
  • coolant_name (str) – Name of the coolant species (e.g. “CO”, “C+”, “p-H2”). Use get_coolant_active() to see available names.

  • enabled (bool) – True to enable, False to disable. Default: True

Raises:

ValueError – If coolant_name is not found in the network.

Examples

>>> settings = HeatingSettings()
>>> settings.set_coolant_active("CO", False)
>>> settings.set_coolant_active("p-H2", False)
set_coolant_directory(directory: str | pathlib.Path) None[source]#

Set the directory containing collisional rate data files.

This directory must contain the LAMDA-format collisional rate files (e.g., co.dat, o-h2.dat, etc.) used for molecular line cooling calculations.

Parameters:

directory (str | Path) – Path to directory containing LAMDA-format rate files. Must end with ‘/’. Max 255 characters.

Raises:

Examples

>>> settings = HeatingSettings()
>>> settings.set_coolant_directory("/custom/rates/")
set_coolant_restart_mode(mode: int) None[source]#

Set the coolant population restart mode.

Parameters:

mode (int) – Restart mode (0=WARM, 1=FORCE_LTE, 2=FORCE_GROUND)

Raises:
  • ValueError – If mode is not one of [0, 1, 2].

  • AssertionError – If the mode could not be set in the Fortran module.

Examples

>>> settings = HeatingSettings()
>>> settings.set_coolant_restart_mode(settings.COOLANT_WARM)
set_cooling_mechanism(mechanism_id: int, enabled: bool = True) None[source]#

Enable or disable a specific cooling mechanism.

Parameters:
  • mechanism_id (int) – Index of the cooling mechanism (1-5). Use class constants (e.g., self.ATOMIC_LINE_COOLING)

  • enabled (bool) – True to enable, False to disable. Default: True

Raises:

ValueError – If mechanism_id is not between 1 and the number of cooling mechanisms.

Examples

>>> settings = HeatingSettings()
>>> settings.set_cooling_mechanism(settings.MOLECULAR_LINE_COOLING, False)
set_dust_gas_coupling_method(method: int) None[source]#

Set the dust-gas temperature coupling method.

Parameters:

method (int) – Coupling method to use: - 1 (DUST_TEMP_HOCUK): Hocuk et al. 2017 - 2 (DUST_TEMP_HOLLENBACH): Hollenbach 1991

Raises:

ValueError – If method is not one of [1, 2].

Examples

>>> settings = HeatingSettings()
>>> settings.set_dust_gas_coupling_method(settings.DUST_TEMP_HOLLENBACH)
set_heating_mechanism(mechanism_id: int, enabled: bool = True) None[source]#

Enable or disable a specific heating mechanism.

For mechanisms with multiple implementations (like PHOTOELECTRIC), enabling one automatically disables others in the same group.

Parameters:
  • mechanism_id (int) – Index of the heating mechanism (1-9). Use class constants (e.g., self.PHOTOELECTRIC[‘BAKES’], self.H2_FORMATION)

  • enabled (bool) – True to enable, False to disable. Default: True

Raises:

ValueError – If mechanism_id is not between 1 and the number of heating mechanisms.

Examples

>>> settings = HeatingSettings()
>>> # Enable Weingartner photoelectric (auto-disables Bakes)
>>> settings.set_heating_mechanism(settings.PHOTOELECTRIC['WEINGARTNER'], True)
>>> # Or disable H2 formation
>>> settings.set_heating_mechanism(settings.H2_FORMATION, False)
set_line_solver_attempts(attempts: int) None[source]#

Set the number of line cooling solver iterations.

The line cooling is computed multiple times and the median is used.

Parameters:

attempts (int) – Number of solver attempts (odd number recommended). Default is 5. Recommended range: 3-11.

Raises:

ValueError – If attempts is less than 1.

Examples

>>> settings = HeatingSettings()
>>> settings.set_line_solver_attempts(7)
set_pah_abundance(abundance: float) None[source]#

Set the PAH (Polycyclic Aromatic Hydrocarbon) abundance.

Parameters:

abundance (float) – PAH abundance relative to hydrogen. Default: 6e-7

Raises:

ValueError – if abundance is smaller than 0

Examples

>>> settings = HeatingSettings()
>>> settings.set_pah_abundance(1e-6)
ATOMIC_LINE_COOLING = 1#
CARBON_IONIZATION = 6#
COMPTON_COOLING = 3#
CONTINUUM_EMISSION = 4#
COOLANT_FORCE_GROUND = 2#
COOLANT_FORCE_LTE = 1#
COOLANT_WARM = 0#
COSMIC_RAY = 7#
DUST_TEMP_HOCUK = 1#
DUST_TEMP_HOLLENBACH = 2#
GAS_GRAIN_COLLISIONS = 9#
H2_COLLISIONALLY_INDUCED = 2#
H2_FORMATION = 3#
H2_FUV_PUMPING = 5#
H2_PHOTODISSOCIATION = 4#
MOLECULAR_LINE_COOLING = 5#
PHOTOELECTRIC#
TURBULENT = 8#
class uclchem.advanced.NetworkState[source]#

Runtime interface to UCLCHEM’s compiled chemical network.

Loads the network from CSV files (on-disk version) and compares with the compiled Fortran network (in-memory version) to ensure consistency.

Thread Safety Warning: This class modifies global Fortran module state and is NOT thread-safe. Do not use with multiprocessing, multithreading, or concurrent model runs.

Examples

>>> from uclchem.advanced import NetworkState
>>> network = NetworkState()
>>> network.validate()  # Check on-disk matches in-memory
>>> print(f"Species: {len(network.species_list)}")
Species: ...
>>> print(f"Reactions: {len(network.reaction_list)}")
Reactions: ...

Initialize the NetworkState interface.

Loads species and reactions from CSV files and compares with the compiled Fortran network data. Caches the initial state of all modifiable network parameters for fast resetting.

reset_network_from_csv() None[source]#

Reset the Fortran network to match the cached initial state.

This method now uses cached values for better performance and reliability. It’s equivalent to reset_state() but kept for backward compatibility.

Note: This uses the cached initial state from when NetworkState was created, not by re-reading CSV files. Use reset_state() for the same functionality with a clearer name.

Modifiable arrays restored: - alpha, beta, gama: Reaction rate parameters - bindingenergy: Species binding energies

Examples

>>> network = NetworkState()
>>> # Modify some reaction...
>>> network._network.alpha[0] = 999.0
>>> # Reset back to initial values
>>> network.reset_state()
reset_state() None[source]#

Reset the Fortran network to its initial cached state.

Uses cached values instead of re-reading and parsing CSV files. Restores all modifiable network parameters to their initial values from when NetworkState was created.

Modifiable arrays restored: - alpha, beta, gama: Reaction rate parameters - bindingenergy: Species binding energies - formationenthalpy: Formation enthalpies (if available)

Examples

>>> network = NetworkState()
>>> # Modify some reaction parameters
>>> network._network.alpha[0] = 999.0
>>> # Restore to initial state
>>> network.reset_state()
validate() None[source]#

Re-run validation to check on-disk matches in-memory.

Useful after modifications to verify consistency.

class uclchem.advanced.RuntimeNetwork[source]#

Bases: uclchem.makerates.network.BaseNetwork

Runtime interface to UCLCHEM’s compiled Fortran network.

Provides read access and parameter modification for the compiled chemical network during model execution. The network structure (species/reactions) is fixed, but parameters can be modified.

To “remove” a reaction: set its alpha parameter to 0.0 using disable_reaction(). To reset changes: call reset_to_initial_state().

Examples

>>> # Load runtime network
>>> network = RuntimeNetwork()
>>> print(f"Species: {len(network.get_species_list())}")
Species: ...
>>> print(f"Reactions: {len(network.get_reaction_list())}")
Reactions: ...
>>> # Modify parameters
>>> network.modify_reaction_parameters(0, alpha=1e-10, beta=2.0)
>>> network.change_binding_energy("#H2O", 5773.0)
>>> # Disable a reaction
>>> network.disable_reaction(5)
>>> # Reset when done
>>> network.reset_to_initial_state()

You can use this to do a sensitivity analysis in a simple way.

>>> # Artificially set a higher diffusion barrier of atomic hydrogen
>>> network.change_diffusion_barrier("#H", 600)
>>>
>>> # Run a model at the increased hydrogen diffusion barrier
>>> import uclchem
>>> param_dict = {"initialDens": 1e5, "initialTemp": 10, "finalTime": 1e5}
>>> high_diffusion_barrier_model = uclchem.model.Cloud(param_dict=param_dict)
>>>
>>> # Reset to initial state, and then run a "standard" model
>>> network.reset_to_initial_state()
>>> regular_diffusion_barrier_model = uclchem.model.Cloud(param_dict=param_dict)
>>>
>>> # Do some analysis to see the effect of a higher hydrogen diffusion barrier
>>> # ...

Initialize RuntimeNetwork by loading the compiled Fortran module.

Automatically imports uclchemwrap.network and validates against species.csv and reactions.csv from the installation directory.

Raises:

ImportError – If uclchemwrap.network cannot be imported

add_reactions(reactions: uclchem.makerates.reaction.Reaction | list[uclchem.makerates.reaction.Reaction]) None[source]#

NOT SUPPORTED: Cannot add reactions to compiled Fortran network.

Parameters:

reactions (Reaction | list[Reaction]) – Reactions to add to the network.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

add_species(species: uclchem.makerates.species.Species | list[uclchem.makerates.species.Species]) None[source]#

NOT SUPPORTED: Cannot add species to compiled Fortran network.

Parameters:

species (Species | list[Species]) – Species instance or list of species to add.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

change_binding_energy(specie: str, new_binding_energy: float) None[source]#

Change binding energy of a species (modifies Fortran array).

Parameters:
  • specie (str) – Name of the species

  • new_binding_energy (float) – New binding energy in Kelvin

change_diffusion_barrier(specie: str, new_diffusion_barrier: float) None[source]#

Change diffusion barrier of a species (modifies Fortran array).

Parameters:
  • specie (str) – Name of the species.

  • new_diffusion_barrier (float) – New diffusion barrier in Kelvin.

change_reaction_barrier(reaction: uclchem.makerates.reaction.Reaction, barrier: float) None[source]#

Change activation barrier of a reaction (modifies Fortran gamma).

Parameters:
  • reaction (Reaction) – Reaction to modify

  • barrier (float) – New activation barrier in Kelvin

Raises:

RuntimeError – If reaction is not a reaction on the ices.

disable_reaction(reaction_idx: int) None[source]#

Disable a reaction by setting alpha=0.

This is the only way to “remove” a reaction at runtime since the Fortran network has fixed structure. Setting alpha=0 makes the reaction have zero rate.

Parameters:

reaction_idx (int) – Index of reaction to disable (0-based)

Examples

>>> network = RuntimeNetwork()
>>> network.disable_reaction(5)
>>> network.reset_to_initial_state()
modify_reaction_parameters(reaction_idx: int, alpha: float | None = None, beta: float | None = None, gamma: float | None = None) None[source]#

Modify reaction rate parameters in Fortran arrays.

Parameters:
  • reaction_idx (int) – Index of reaction to modify (0-based)

  • alpha (float | None) – New alpha value (pre-exponential factor) (Default value = None)

  • beta (float | None) – New beta value (temperature exponent) (Default value = None)

  • gamma (float | None) – New gamma value (activation energy in K) (Default value = None)

Raises:

IndexError – If reaction_idx out of range

Examples

>>> network = RuntimeNetwork()
>>> network.modify_reaction_parameters(0, alpha=1e-10, beta=2.0)
>>> network.reset_to_initial_state()
remove_reaction(reaction: uclchem.makerates.reaction.Reaction) None[source]#

NOT SUPPORTED: Cannot remove reactions from compiled Fortran network.

Use disable_reaction() to set alpha=0 instead.

Parameters:

reaction (Reaction) – Reaction instance to look up or modify.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

remove_reaction_by_index(reaction_idx: int) None[source]#

NOT SUPPORTED: Cannot remove reactions from compiled Fortran network.

Use disable_reaction() to set alpha=0 instead.

Parameters:

reaction_idx (int) – Index of the reaction in the network.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

remove_species(specie_name: str) None[source]#

NOT SUPPORTED: Cannot remove species from compiled Fortran network.

Parameters:

specie_name (str) – Name of the species.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

reset_to_initial_state() None[source]#

Reset all Fortran parameters to their initial cached values.

Restores: - All reaction parameters (alpha, beta, gamma) - All species binding energies

Examples

>>> network = RuntimeNetwork()
>>> network.modify_reaction_parameters(0, alpha=999.0)
>>> network.reset_to_initial_state()  # Restores original alpha
set_reaction(reaction_idx: int, reaction: uclchem.makerates.reaction.Reaction) None[source]#

NOT SUPPORTED: Cannot replace reactions in compiled Fortran network.

Parameters:
  • reaction_idx (int) – Index of the reaction in the network.

  • reaction (Reaction) – Reaction instance to look up or modify.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

set_reaction_dict(new_dict: dict[int, uclchem.makerates.reaction.Reaction]) None[source]#

NOT SUPPORTED: Cannot replace reaction dictionary.

Parameters:

new_dict (dict[int, Reaction]) – Replacement reactions dictionary.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

set_specie(species_name: str, species: uclchem.makerates.species.Species) None[source]#

NOT SUPPORTED: Cannot replace species in compiled Fortran network.

Parameters:
  • species_name (str) – Name of the species.

  • species (Species) – Species instance or list of species to add.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

set_species_dict(new_species_dict: dict[str, uclchem.makerates.species.Species]) None[source]#

NOT SUPPORTED: Cannot replace species dictionary.

Parameters:

new_species_dict (dict[str, Species]) – Replacement species dictionary.

Raises:

NotImplementedError – Always - Fortran arrays have fixed size

sort_reactions() None[source]#

NOT SUPPORTED: Reaction order is fixed in compiled network.

Raises:

NotImplementedError – Always - reaction order is fixed

sort_species() None[source]#

NOT SUPPORTED: Species order is fixed in compiled network.

Raises:

NotImplementedError – Always - species order is fixed

property fortran_module: types.ModuleType#

Direct access to Fortran module for advanced users.

Warning: Use with caution. Direct modification bypasses safety checks.

Returns:

The underlying Fortran module handle for this runtime network.

Return type:

ModuleType

uclchem.advanced.create_snapshot() dict[str, Any][source]#

Capture the current Fortran module state into a picklable dict.

Reads directly from Fortran memory (not cached Python values) to ensure accuracy even when settings were modified outside the wrapper classes.

The returned dict has three sections:

  • "general" – scalar settings from all uclchemwrap sub-modules (excluding PARAMETERs, INTERNAL, FILE_PATH, and arrays).

  • "heating" – heating/cooling boolean arrays, scalars, and coolant configuration.

  • "network" – Everything in _NETWORK_ARRAYS_TO_TAKE_SNAPSHOT_OF.

Returns:

Fully picklable dict suitable for passing to restore_snapshot().

Return type:

dict[str, Any]

uclchem.advanced.restore_snapshot(snapshot: dict[str, Any]) None[source]#

Apply a previously captured snapshot to the current process.

Must be called before running any model in the worker process.

Parameters:

snapshot (dict[str, Any]) – Dict produced by create_snapshot().