You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We load either a default configuration (from isoslam/default_config.yaml) or a user specified one (via isoslam --config <config_file.yaml>) but there are command line options for each sub-processor that should over-ride the
defaults.
To which end we need a function that updates the dictionary loaded from the YAML configuration with the options
specified on the command line, otherwise the command line options are ignored.
The following is just such a function which uses recursion to update dictionaries and also converts base_dir and output_dir to Path using the associated helper function.
defconvert_path(path: str|Path) ->Path:
""" Ensure path is Path object. Parameters ---------- path : str | Path Path to be converted. Returns ------- Path Pathlib object of path. """returnPath().cwd() ifpath=="./"elsePath(path).expanduser()
defupdate_config(config: dict, args: dict|Namespace) ->dict:
""" Update the configuration with any arguments. Parameters ---------- config : dict Dictionary of configuration (typically read from YAML file specified with '-c/--config <filename>'). args : Namespace Command line arguments. Returns ------- dict Dictionary updated with command arguments. """args=vars(args) ifisinstance(args, Namespace) elseargsconfig_keys=config.keys()
forarg_key, arg_valueinargs.items():
ifisinstance(arg_value, dict):
update_config(config, arg_value)
else:
ifarg_keyinconfig_keysandarg_valueisnotNone:
original_value=config[arg_key]
config[arg_key] =arg_valueLOGGER.debug(f"Updated config config[{arg_key}] : {original_value} > {arg_value} ")
if"base_dir"inconfig.keys():
config["base_dir"] =convert_path(config["base_dir"])
if"output_dir"inconfig.keys():
config["output_dir"] =convert_path(config["output_dir"])
returnconfig
The text was updated successfully, but these errors were encountered:
We load either a default configuration (from
isoslam/default_config.yaml
) or a user specified one (viaisoslam --config <config_file.yaml>
) but there are command line options for each sub-processor that should over-ride thedefaults.
To which end we need a function that updates the dictionary loaded from the YAML configuration with the options
specified on the command line, otherwise the command line options are ignored.
The following is just such a function which uses recursion to update dictionaries and also converts
base_dir
andoutput_dir
toPath
using the associated helper function.The text was updated successfully, but these errors were encountered: