\(\renewcommand\AA{\unicode{x212B}}\)

amend_config

mantid.kernel.AmendConfig.amend_config(facility: str = None, instrument: str = None, data_dir: str | list = None, prepend_datadir: bool = True, **kwargs) None

Context manager to safely modify Mantid Configuration Service while the function is executed.

facilitystring

Sets the value for default.facility Changing the facility also changes the instrument to the default instrument for the facility. It is recommended to provide an instrument with a facility

instrumentstring

Sets the value for default.instrument

data_dirstring, list

Sets the value for datasearch.directories

prepend_datadirbool

Default True, if False the datasearch.directories will be replaced with the value of data_dir

kwargs

Dictionary of any named keyword arguments from Mantid Properties

Example Usage

from mantid.kernel import amend_config

with amend_config(facility="FacilityA", instrument="InstrumentX"):
    # Inside this block, configuration for FacilityA and InstrumentX is active.
    perform_custom_operation()

# Outside the block, the original configuration is restored.

with amend_config(data_dir="/custom/data"):
    # Configuration with a custom data directory.
    do_something_with_custom_data()

# Original configuration is restored again.

temp_config = {"Notifications.Enabled": "On", "logging.loggers.root.level": "debug"}
with amend_config(**temp_config):
    # Configuration with dictionary of properties
    do_something_else()

# Original configuration is restored again.