ihkapy.fileio.options_io
1# utility methods for loading options from Options.toml 2import os 3import toml # Parameters/config file Options.toml 4import warnings 5 6 7def load_fio_ops_and_data_ops(options_path="./Options.toml"): 8 """Load the 'fio_ops' and 'data_ops' dictionaries from options config file 9 10 Parses the .toml config file at `options_path` into a dictionary. 11 Returns the sub-dictionaries at the files "fio" and "params.data" 12 13 Parameters 14 ---------- 15 `options_path : str` 16 Path to the config file 17 18 Returns 19 ------- 20 `dict` 21 A dictionary containing fio params, i.e. paths to data files. 22 23 `dict` 24 A dictionary containing data parameters required for data manip. 25 """ 26 27 warnings.warn("Change this relative path once package is configured properly. \nWe need a more reliable way of accessing the options.toml config file") 28 ops = load_ops_as_dict(options_path) 29 fio_ops = ops["fio"] 30 data_ops = ops["params"]["data"] 31 return fio_ops,data_ops 32 33def load_ops_as_dict(options_path="./Options.toml"): 34 """Returns the Options.toml file as a dictionary 35 36 Parses the .toml config file at `options_path` into a dictionary 37 and returns it. 38 39 Parameters 40 ---------- 41 `options_path : str` 42 Path to the config file 43 """ 44 with open(options_path,"r") as f: 45 ops_string = f.read() 46 ops = toml.loads(ops_string) 47 return ops
def
load_fio_ops_and_data_ops(options_path='./Options.toml')
8def load_fio_ops_and_data_ops(options_path="./Options.toml"): 9 """Load the 'fio_ops' and 'data_ops' dictionaries from options config file 10 11 Parses the .toml config file at `options_path` into a dictionary. 12 Returns the sub-dictionaries at the files "fio" and "params.data" 13 14 Parameters 15 ---------- 16 `options_path : str` 17 Path to the config file 18 19 Returns 20 ------- 21 `dict` 22 A dictionary containing fio params, i.e. paths to data files. 23 24 `dict` 25 A dictionary containing data parameters required for data manip. 26 """ 27 28 warnings.warn("Change this relative path once package is configured properly. \nWe need a more reliable way of accessing the options.toml config file") 29 ops = load_ops_as_dict(options_path) 30 fio_ops = ops["fio"] 31 data_ops = ops["params"]["data"] 32 return fio_ops,data_ops
Load the 'fio_ops' and 'data_ops' dictionaries from options config file
Parses the .toml config file at options_path
into a dictionary.
Returns the sub-dictionaries at the files "fio" and "params.data"
Parameters
options_path : str
Path to the config file
Returns
dict
A dictionary containing fio params, i.e. paths to data files.
dict
A dictionary containing data parameters required for data manip.
def
load_ops_as_dict(options_path='./Options.toml')
34def load_ops_as_dict(options_path="./Options.toml"): 35 """Returns the Options.toml file as a dictionary 36 37 Parses the .toml config file at `options_path` into a dictionary 38 and returns it. 39 40 Parameters 41 ---------- 42 `options_path : str` 43 Path to the config file 44 """ 45 with open(options_path,"r") as f: 46 ops_string = f.read() 47 ops = toml.loads(ops_string) 48 return ops
Returns the Options.toml file as a dictionary
Parses the .toml config file at options_path
into a dictionary
and returns it.
Parameters
options_path : str
Path to the config file