prsctrl.prsctrl_interactive.PrsInteractiveSettings#
- class PrsInteractiveSettings(data_dir: str | list[str] = '~/Desktop/PR/data', data_dir_cache: str = '~/.cache/prsctrl/data', data_dir_archive: str | list[str] = '~/.cache/prsctrl/archive', archive_file_count_threshold: int = 30, reference_data_dir: str | None = None, log_dir: str = '~/.cache/prsctrl', compress_data: bool = False, power_calibration_laser: str | None = None, power_calibration_led: str | None = None, sample_db: str = 'sample-db.yaml', power_calibration_db: str = '~/.cache/prsctrl/power-calibrations.yaml', setup_info_db: str = '~/.config/prsctrl/setups.yaml', setup: str = 'default', plugin_dir: str | list[str] = '~/.config/prsctrl/plugins', device_connection_infos_path: str = '~/.cache/prsctrl/devices.yaml')[source]#
Bases:
SettingsClassSettings for the interactive shell, loaded from and saved to the config file.
Methods
Convenience wrapper for dataclasses.asdict(self)
Convenience method for copy.deepcopy(self)
Return a tuple describing the fields of this dataclass.
Recursively construct a
SettingsClassfrom a dictionary.Return the settings as a dictionary.
Write the settings to the config file.
Attributes
Minimum number of files in a data directory for it to be archived
Whether to compress measurement data
Output directory for data directories containing only the final important files (full-data.pkl, plots, csv).
Directory for zip archives of the entire data directory.
Output directory for the partial files during the measurement
File storing which device type and name was last connected for each device key
Directory user plugins are loaded from.
Path of the pump-power calibration database
Name of the active power calibration for the laser
Name of the active power calibration for the LED
Data directory used as reference for the absorption calculation.
Path of the sample database, relative to the working directory
Key of the active setup info in the setup database
Path of the setup info database
- __annotations__ = {'archive_file_count_threshold': <class 'int'>, 'compress_data': <class 'bool'>, 'data_dir': str | list[str], 'data_dir_archive': str | list[str], 'data_dir_cache': <class 'str'>, 'device_connection_infos_path': <class 'str'>, 'log_dir': <class 'str'>, 'plugin_dir': str | list[str], 'power_calibration_db': <class 'str'>, 'power_calibration_laser': str | None, 'power_calibration_led': str | None, 'reference_data_dir': str | None, 'sample_db': <class 'str'>, 'setup': <class 'str'>, 'setup_info_db': <class 'str'>}#
- __dataclass_fields__ = {'archive_file_count_threshold': Field(name='archive_file_count_threshold',type=<class 'int'>,default=30,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'compress_data': Field(name='compress_data',type=<class 'bool'>,default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir': Field(name='data_dir',type=str | list[str],default='~/Desktop/PR/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_archive': Field(name='data_dir_archive',type=str | list[str],default='~/.cache/prsctrl/archive',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_cache': Field(name='data_dir_cache',type=<class 'str'>,default='~/.cache/prsctrl/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device_connection_infos_path': Field(name='device_connection_infos_path',type=<class 'str'>,default='~/.cache/prsctrl/devices.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'log_dir': Field(name='log_dir',type=<class 'str'>,default='~/.cache/prsctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'plugin_dir': Field(name='plugin_dir',type=str | list[str],default='~/.config/prsctrl/plugins',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_db': Field(name='power_calibration_db',type=<class 'str'>,default='~/.cache/prsctrl/power-calibrations.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_laser': Field(name='power_calibration_laser',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_led': Field(name='power_calibration_led',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'reference_data_dir': Field(name='reference_data_dir',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'sample_db': Field(name='sample_db',type=<class 'str'>,default='sample-db.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup': Field(name='setup',type=<class 'str'>,default='default',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup_info_db': Field(name='setup_info_db',type=<class 'str'>,default='~/.config/prsctrl/setups.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}#
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
- __dict__ = mappingproxy({'__module__': 'prsctrl.prsctrl_interactive', '__firstlineno__': 119, '__annotations__': {'data_dir': str | list[str], 'data_dir_cache': <class 'str'>, 'data_dir_archive': str | list[str], 'archive_file_count_threshold': <class 'int'>, 'reference_data_dir': str | None, 'log_dir': <class 'str'>, 'compress_data': <class 'bool'>, 'power_calibration_laser': str | None, 'power_calibration_led': str | None, 'sample_db': <class 'str'>, 'power_calibration_db': <class 'str'>, 'setup_info_db': <class 'str'>, 'setup': <class 'str'>, 'plugin_dir': str | list[str], 'device_connection_infos_path': <class 'str'>}, '__doc__': 'Settings for the interactive shell, loaded from and saved to the config file.', 'data_dir': '~/Desktop/PR/data', 'data_dir_cache': '~/.cache/prsctrl/data', 'data_dir_archive': '~/.cache/prsctrl/archive', 'archive_file_count_threshold': 30, 'reference_data_dir': None, 'log_dir': '~/.cache/prsctrl', 'compress_data': False, 'power_calibration_laser': None, 'power_calibration_led': None, 'sample_db': 'sample-db.yaml', 'power_calibration_db': '~/.cache/prsctrl/power-calibrations.yaml', 'setup_info_db': '~/.config/prsctrl/setups.yaml', 'setup': 'default', 'plugin_dir': '~/.config/prsctrl/plugins', 'device_connection_infos_path': '~/.cache/prsctrl/devices.yaml', 'save': <function PrsInteractiveSettings.save>, '__static_attributes__': (), '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'data_dir': Field(name='data_dir',type=str | list[str],default='~/Desktop/PR/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_cache': Field(name='data_dir_cache',type=<class 'str'>,default='~/.cache/prsctrl/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_archive': Field(name='data_dir_archive',type=str | list[str],default='~/.cache/prsctrl/archive',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'archive_file_count_threshold': Field(name='archive_file_count_threshold',type=<class 'int'>,default=30,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'reference_data_dir': Field(name='reference_data_dir',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'log_dir': Field(name='log_dir',type=<class 'str'>,default='~/.cache/prsctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'compress_data': Field(name='compress_data',type=<class 'bool'>,default=False,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_laser': Field(name='power_calibration_laser',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_led': Field(name='power_calibration_led',type=str | None,default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'sample_db': Field(name='sample_db',type=<class 'str'>,default='sample-db.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'power_calibration_db': Field(name='power_calibration_db',type=<class 'str'>,default='~/.cache/prsctrl/power-calibrations.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup_info_db': Field(name='setup_info_db',type=<class 'str'>,default='~/.config/prsctrl/setups.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup': Field(name='setup',type=<class 'str'>,default='default',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'plugin_dir': Field(name='plugin_dir',type=str | list[str],default='~/.config/prsctrl/plugins',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device_connection_infos_path': Field(name='device_connection_infos_path',type=<class 'str'>,default='~/.cache/prsctrl/devices.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function PrsInteractiveSettings.__init__>, '__repr__': <function PrsInteractiveSettings.__repr__>, '__eq__': <function PrsInteractiveSettings.__eq__>, '__match_args__': ('data_dir', 'data_dir_cache', 'data_dir_archive', 'archive_file_count_threshold', 'reference_data_dir', 'log_dir', 'compress_data', 'power_calibration_laser', 'power_calibration_led', 'sample_db', 'power_calibration_db', 'setup_info_db', 'setup', 'plugin_dir', 'device_connection_infos_path')})#
- __eq__(other)#
Return self==value.
- __firstlineno__ = 119#
- __hash__ = None#
- __init__(data_dir: str | list[str] = '~/Desktop/PR/data', data_dir_cache: str = '~/.cache/prsctrl/data', data_dir_archive: str | list[str] = '~/.cache/prsctrl/archive', archive_file_count_threshold: int = 30, reference_data_dir: str | None = None, log_dir: str = '~/.cache/prsctrl', compress_data: bool = False, power_calibration_laser: str | None = None, power_calibration_led: str | None = None, sample_db: str = 'sample-db.yaml', power_calibration_db: str = '~/.cache/prsctrl/power-calibrations.yaml', setup_info_db: str = '~/.config/prsctrl/setups.yaml', setup: str = 'default', plugin_dir: str | list[str] = '~/.config/prsctrl/plugins', device_connection_infos_path: str = '~/.cache/prsctrl/devices.yaml') None#
- __match_args__ = ('data_dir', 'data_dir_cache', 'data_dir_archive', 'archive_file_count_threshold', 'reference_data_dir', 'log_dir', 'compress_data', 'power_calibration_laser', 'power_calibration_led', 'sample_db', 'power_calibration_db', 'setup_info_db', 'setup', 'plugin_dir', 'device_connection_infos_path')#
- __module__ = 'prsctrl.prsctrl_interactive'#
- __or__(other)#
Merge with another settings class or a dictionary. Unknown keys in a dictionary are ignored.
- __replace__(**changes)#
- __repr__()#
Return repr(self).
- __static_attributes__ = ()#
- __weakref__#
list of weak references to the object
- _get_dict(remove_empty_containers: bool = False, remove_None: bool = False, remove_if_None: list[str] | None = None) dict#
Return the settings as a dictionary, optionally cleaning up the output.
Base implementation for
get_dict(). Subclasses may call it with different arguments to configure the output.- Parameters:
remove_empty_containers – If True, remove empty
dict,list,tupleorsetvalues.remove_None – If True, remove all keys with a
Nonevalue.remove_if_None – If given, remove these keys only if their value is
None(absent keys are ignored).
- Returns:
Instance converted to dictionary, see
as_dict().
- archive_file_count_threshold: int = 30#
Minimum number of files in a data directory for it to be archived
- as_dict() dict#
Convenience wrapper for dataclasses.asdict(self)
Returns all fields of the settings class. For a dictionary where certain fields may be skipped, see
get_dict().
- compress_data: bool = False#
Whether to compress measurement data
- copy() Self#
Convenience method for copy.deepcopy(self)
- data_dir: str | list[str] = '~/Desktop/PR/data'#
Output directory for data directories containing only the final important files (full-data.pkl, plots, csv). May be a list to copy to multiple directories.
- data_dir_archive: str | list[str] = '~/.cache/prsctrl/archive'#
Directory for zip archives of the entire data directory. May be a list to archive to multiple directories.
- data_dir_cache: str = '~/.cache/prsctrl/data'#
Output directory for the partial files during the measurement
- device_connection_infos_path: str = '~/.cache/prsctrl/devices.yaml'#
File storing which device type and name was last connected for each device key
- fields()#
Return a tuple describing the fields of this dataclass.
Adapted version of dataclass.fields that applies additional sorting of the fields according to the field’s metadata[“order”] parameter.
Accepts a dataclass or an instance of one. Tuple elements are of type Field.
- classmethod from_dict(data: dict, strict: bool = False) Self#
Recursively construct a
SettingsClassfrom a dictionary.If the value of a field is another SettingsClass,
from_dict()will be called for that field as well. Handled are:SettingsClass
list[SettingsClass]
dict[<any>, SettingsClass]
all of the above as Optional (Union with
None)a Union with any handled types
- Parameters:
strict – If True, raise a KeyError on keys in
datathat are not field names ofcls. Unknown keys are ignored otherwise.- Raises:
- get_dict() dict#
Return the settings as a dictionary.
as_dict()returns the settings class with all fields, whileget_dict()may be configured by subclasses to skip certain fields in the output. The default implementation returns all fields, likeas_dict(). :return: Instance converted to dictionary.
- classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
- log_dir: str = '~/.cache/prsctrl'#
- plugin_dir: str | list[str] = '~/.config/prsctrl/plugins'#
Directory user plugins are loaded from. May be a list of directories.
- power_calibration_db: str = '~/.cache/prsctrl/power-calibrations.yaml'#
Path of the pump-power calibration database
- power_calibration_laser: str | None = None#
Name of the active power calibration for the laser
- power_calibration_led: str | None = None#
Name of the active power calibration for the LED
- reference_data_dir: str | None = None#
Data directory used as reference for the absorption calculation. If None, no reference data is used.
- sample_db: str = 'sample-db.yaml'#
Path of the sample database, relative to the working directory
- save()[source]#
Write the settings to the config file. Does nothing if no config file is used, i.e. config_path is empty.
- save_yaml(yaml_path: str)#
- setup: str = 'default'#
Key of the active setup info in the setup database
- setup_info_db: str = '~/.config/prsctrl/setups.yaml'#
Path of the setup info database