class qcodes.configuration.config.Config(path: Optional[str] = None)[source]

Bases: object

QCoDeS config system

Start with sane defaults, which you can’t change, and then customize your experience using files that update the configuration.


path – Optional path to directory containing a qcodesrc.json config file

config_file_name = 'qcodesrc.json'

Name of config file

schema_file_name = 'qcodesrc_schema.json'

Name of schema file

default_file_name = '/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/qcodes/configuration/qcodesrc.json'

Filename of default config

current_config_path = '/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/qcodes/configuration/qcodesrc.json'

Path of the last loaded config file

schema_default_file_name = '/opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/qcodes/configuration/qcodesrc_schema.json'

Filename of default schema

home_file_name = '/home/runner/qcodesrc.json'

Filename of home config

schema_home_file_name = '/home/runner/qcodesrc_schema.json'

Filename of home schema

env_file_name = ''

Filename of env config

schema_env_file_name = ''

Filename of env schema

cwd_file_name = '/home/runner/work/Qcodes/Qcodes/docs/qcodesrc.json'

Filename of cwd config

schema_cwd_file_name = '/home/runner/work/Qcodes/Qcodes/docs/qcodesrc_schema.json'

Filename of cwd schema

current_schema: Optional[qcodes.configuration.config.DotDict] = None

Validators and descriptions of config values

current_config: Optional[qcodes.configuration.config.DotDict] = None

Valid config values

defaults: qcodes.configuration.config.DotDict = ()

The default configuration

defaults_schema: qcodes.configuration.config.DotDict = ()

The default schema

load_default() Tuple[qcodes.configuration.config.DotDict, qcodes.configuration.config.DotDict][source]
update_config(path: Optional[str] = None) Dict[str, Any][source]

Load defaults updates with cwd, env, home and the path specified and validates. A configuration file must be called qcodesrc.json A schema file must be called qcodesrc_schema.json Configuration files (and their schema) are loaded and updated from the directories in the following order:

  • default json config file from the repository

  • user json config in user home directory

  • user json config in $QCODES_CONFIG

  • user json config in current working directory

  • user json file in the path specified

If a key/value is not specified in the user configuration the default is used. Key/value pairs loaded later will take preference over those loaded earlier. Configs are validated after every update. Validation is also performed against a user provided schema if it’s found in the directory.


path – Optional path to directory containing a qcodesrc.json config file

validate(json_config: Optional[Dict[str, Any]] = None, schema: Optional[Dict[str, Any]] = None, extra_schema_path: Optional[str] = None) None[source]

Validate configuration; if no arguments are passed, the default validators are used.

  • json_config – json file to validate

  • schema – schema dictionary

  • extra_schema_path – schema path that contains extra validators to be added to schema dictionary

add(key: str, value: Any, value_type: Optional[str] = None, description: Optional[str] = None, default: Optional[Any] = None) None[source]

Add custom config value in place

Adds key, value with optional value_type to user config and schema. If value_type is specified then the new value is validated.

  • key – key to be added under user config

  • value – value to add to config

  • value_type – type of value, allowed are string, boolean, integer

  • description – description of key to add to schema

  • default – default value, stored only in the schema


>>> defaults.add("trace_color", "blue", "string", "description")

will update the config:

"user": { "trace_color": "blue"}

and the schema:

    "type" : "object",
    "description": "controls user settings of qcodes"
    "properties" : {
                "trace_color": {
                "description" : "description",
                "type": "string"


  • Add enum support for value_type

  • finish _diffing

static load_config(path: str) qcodes.configuration.config.DotDict[source]

Load a config JSON file


path – path to the config file


a dot accessible dictionary config object


FileNotFoundError – if config is missing

save_config(path: str) None[source]

Save current config to file at given path.


path – path of new file

save_schema(path: str) None[source]

Save current schema to file at given path.


path – path of new file

save_to_home() None[source]

Save config and schema to files in home dir

save_to_env() None[source]

Save config and schema to files in path specified in env variable

save_to_cwd() None[source]

Save config and schema to files in current working dir

describe(name: str) str[source]

Describe a configuration entry


name – name of entry to describe in ‘dotdict’ notation, e.g. name=”user.scriptfolder”

class qcodes.configuration.config.DotDict(value: Optional[Dict[str, Any]] = None)[source]

Bases: Dict[Any, Any]

Wrapper dict that allows to get dotted attributes

Requires keys to be strings.

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
__getattr__(name: str) Any[source]

Overwrite __getattr__ to provide dot access

__setattr__(key: str, value: Any) None[source]

Overwrite __setattr__ to provide dot access

qcodes.configuration.config.update(d: Dict[Any, Any], u: Mapping[Any, Any]) Dict[Any, Any][source]