Config

Provide an easy way to set things like gadgetron host, port, etc.

The ProfileConfig object will create (if it’s not already created) a file called ‘profiles.config’ in the top level of the project (same directory as setup.py). This file contains one or more profiles, one and only one of which must be set as active. A profile contains ports and hostnames and other parameters to use for the gadgetron, MATLAB, siemens_to_ismrmrd, etc. clients.

The config files use python’s configparser format. See implementation for details.

Examples

A sample profiles.config file might look like:

[default]
gadgetron.host = localhost
gadgetron.port = 9002

[workcomp]
gadgetron.host = 10.8.1.12
gadgetron.port = 9002
matlab.host = 10.8.1.12
matlab.port = 9999
matlab.bufsize = 1024

[config]
active = workcomp
class mr_utils.config.config.ProfileConfig(filename=None)[source]

ProfileConfig allows object oriented interaction with profiles.config.

activate_profile(profile)[source]

Assign a profile to be active.

Parameters:profile (str) – Profile label to make active.

Notes

All other profiles will still persist, but will not be used. Only one profile may be active at a time.

create_profile(profile_name, args=None)[source]

Create a new profile.

Parameters:
  • profile_name (str) – New profile’s label.
  • args (dict) – key, value pairs of profile’s attributes.
get_config_val(key)[source]

Retrieve a config value.

Parameters:key (str) – Key of the (key, value) pair of the value to be looked up.
Returns:Value associated with key
Return type:value
set_config(args, profile=None)[source]

Update profile configuration files.

Parameters:
  • profile (str) – The profile to update.
  • args (dict) – Dictionary of key, value updates.

Notes

Keys -> Values:
'gadgetron.host' -> (string) ip-address/hostname/etc
'gadgetron.port' -> (int) port number
update_file()[source]

Update profiles.config by overwriting contents.