ibllib.io.params

Functions

as_dict

from_dict

getfile

Returns full path of the param file per system convention:

read

Reads in and parse Json parameter file into dictionary.

write

Write a parameter file in Json format

as_dict(par)[source]
from_dict(par_dict)[source]
getfile(str_params)[source]
Returns full path of the param file per system convention:

linux/mac: ~/.str_params, Windows: APPDATA folder

Parameters

str_params – string that identifies parm file

Returns

string of full path

read(str_params, default=None)[source]

Reads in and parse Json parameter file into dictionary. If the parameter file doesn’t exist and no defaults are provided, a FileNotFound error is raised, otherwise any extra default parameters will be written into the file.

Examples

# Load parameters, raise error if file not found par = read(‘globus/admin’)

# Load with defaults par = read(‘globus/admin’, {‘local_endpoint’: None, ‘remote_endpoint’: None})

# Return empty dict if file not found (i.e. touch new param file) par = read(‘new_pars’, {})

Parameters
  • str_params – path to text json file

  • default – default values for missing parameters

Returns

named tuple containing parameters

write(str_params, par)[source]

Write a parameter file in Json format

Parameters
  • str_params – path to text json file

  • par – dictionary containing parameters values

Returns

None