ezpz.configs
¶
ezpz/configs.py
cmd_exists(cmd)
¶
Check whether command exists.
cmd_exists("ls") True cmd_exists("hostname") True
print_config_tree(cfg, resolve=True, save_to_file=True, verbose=True, style='tree', print_order=None, highlight=True, outfile=None)
¶
Prints the contents of a DictConfig as a tree structure using the Rich library.
- cfg: A DictConfig composed by Hydra.
- print_order: Determines in what order config components are printed.
- resolve: Whether to resolve reference fields of DictConfig.
- save_to_file: Whether to export config to the hydra output folder.
Source code in src/ezpz/configs.py
print_json(json_str=None, console=None, *, data=None, indent=2, highlight=True, skip_keys=False, ensure_ascii=False, check_circular=True, allow_nan=True, default=None, sort_keys=False)
¶
Pretty prints JSON. Output will be valid JSON.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_str
|
Optional[str]
|
A string containing JSON. |
None
|
data
|
Any
|
If json is not supplied, then encode this data. |
None
|
indent
|
Union[None, int, str]
|
Number of spaces to indent. Defaults to 2. |
2
|
highlight
|
bool
|
Enable highlighting of output: Defaults to True. |
True
|
skip_keys
|
bool
|
Skip keys not of a basic type. Defaults to False. |
False
|
ensure_ascii
|
bool
|
Escape all non-ascii characters. Defaults to False. |
False
|
check_circular
|
bool
|
Check for circular references. Defaults to True. |
True
|
allow_nan
|
bool
|
Allow NaN and Infinity values. Defaults to True. |
True
|
default
|
Callable
|
A callable that converts values that can not be encoded in to something that can be JSON encoded. Defaults to None. |
None
|
sort_keys
|
bool
|
Sort dictionary keys. Defaults to False. |
False
|