3.3. Configuration

All configuration files used by PyMoDAQ will be located within two folders each called .pymodaq. One is system wide and located in one of these locations:

  • Windows: ProgramData folder

  • Mac: Library/Application Support folder

  • Linux: /etc

while the other is restricted to the current user and located in the user’s home folder.

All configuration files that should be shared between users are in the system wide folder, for instance all files related to the dashboard, see Fig. Fig. 3.4:

  • preset configs: preset file defining the type and numbers of control modules for a given experiment

  • batch configs: file describing the batch of scans to do

  • layout configs: store the user interface docks arrangement

  • overshoot configs: store the files defining overshoots

  • remote configs: store the files defining the remote control actions

  • roi configs: store the overall ROI in all DAQ_Viewers on the dashboard


Fig. 3.4 Local folder to store configuration files

3.3.1. Configs from Managers

Each folder contains dedicated files: the log as text file and all module configuration files as xml files. These files are generated by dedicated managers when the user is configuring one aspect of PyMoDAQ, for instance using the Preset manager for defining Actuators and Detectors in the Dashboard. Apart the log, a user should not interact directly with those but use their respective manager user interface to create and modify them.

3.3.2. PyMoDAQ configuration for default values

The config_pymodaq.toml file is the only exception. It is there so that a particular user could enter specific personal information such as the name that will be used by default in the metadata, default preset file to load if executing directly the DAQ_Scan extension, default type of Scan and so on. The file can be directly modified but should be accessed within the Dashboard in the file menu.

The configuration file located in the system wide folder is the default one, see below, but when a user override the default values, they will be stored in another config_pymodaq.toml in the user .pymodaq folder. In this way, if the computer is shared among multiple users, each can specify their own metadata, UI feel and shape, default presets, …

Below is a non exhaustive list of configuration entries stored in the config_pymodaq.toml file:

Listing 3.1 Default Configuration file of PyMoDAQ that will be copied on the local folder where the user can modify it
     save_path = "C:\\Data"  #base path where data are automatically saved
     compression_level = 5  # for hdf5 files between 0(min) and 9 (max)

     [data_saving.hsds] #hsds connection option (https://www.hdfgroup.org/solutions/highly-scalable-data-service-hsds/)
     #to save data in pymodaq using hpyd backend towards distant server or cloud (mimicking hdf5 files)
     root_url = "http://hsds.sebastienweber.fr"
     username = "pymodaq_user"
     pwd = "pymodaq"

 debug_level = "DEBUG" #either "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
 debug_levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
 check_version = true  #automatically check version at startup

 name = "User name"  # default name used as author in the hdf5 saving files

         username = "pymodaq_user"
         pwd = "pymodaq"

         [network.logging.sql] #location of the postgresql database server and options where the DAQ_Logger will log data
         ip = ""
         port = 5432

     ip = ""
     port = 6341

 default_preset_for_scan = "preset_default"
 default_preset_for_logger = "preset_default"

3.3.3. Plugins configuration for default values

In the same way, the file config_pymodaq.toml stores (system/user wide) default configuration values, plugins benefits of the same features. The mechanism is as follow. The plugin package should contain (PyMoDAQ >= 4) a resources folder containing at least the VERSION file and a config_template.toml file, see Fig. 3.5.


Fig. 3.5 Files in the resources folder of each plugin (well that should be like this as of october 2023)

This config_template.toml file holds any mandatory config values needed from within you plugin package scripts. The first time the plugin package is imported, this config will be copied into the system wide/user folders, to be used by the plugins scripts. They can be manually amended by each user in their .pymodaq user folder.

Another file is mandatory, the utils.py at the root of the plugin package, see Fig. 3.5. In there, will be defined the particular Config object to be used with each script of the package plugin:

class Config(BaseConfig):
    """Main class to deal with configuration values for this plugin"""
    config_template_path = Path(__file__).parent.joinpath('resources/config_template.toml')
    config_name = f"config_{__package__.split('pymodaq_plugins_')[1]}"

This object will automatically be linked to the system wide/user .pymodaq folder where the template will be copied and renamed from the plugin name. For instance, the plugin package, pymodaq_plugins_optimisation will produce a configuration file called config_optimisation.toml