alib.util¶
-
exception
alib.util.AlibPathError¶
-
exception
alib.util.DeploymentError¶
-
class
alib.util.ExperimentPathHandler¶ This class handles the paths related to the execution of experiments or the generation of scenarios using alib.
To use it, run ExperimentPathHandler.initialize() to initialize the variables described below:
- ALIB_DIR:
This is the parent folder for any experiments to be run on the server.
It is equal to the environment variable ALIB_EXPERIMENT_HOME if it is set.
Otherwise the code traverses up through the file system starting at this file’s location (paths.py) until it finds a path containing the subfolders “input”, “output”, “log”, indicating that this is the root folder of the experiment. ALIB_DIR is then set to the parent of this directory.
- INPUT_DIR:
- This is the path containing any configuration files, scenario pickle files and similar files, as provided in the optional “extras” argument in deployment.
- LOG_DIR:
- This is the path, where log files related to the experiment should be stored.
- OUTPUT_DIR:
- This is the path where the results of this execution should be stored results.
LOG_DIR and OUTPUT_DIR are required to be empty to avoid accidental overwriting of previous results.
-
ALIB_DIR= None¶
-
INPUT_DIR= None¶
-
LOG_DIR= './log'¶
-
OUTPUT_DIR= None¶
-
static
initialize(check_emptiness_output=True, check_emptiness_log=True)¶
-
class
alib.util.PrettyPrinter(indent_offset=0, indent_step=1, whitelist=None, max_depth=10000)¶ Custom implementation of a pretty printer to output classes nicely.
-
pprint(obj, col_output_limit=None)¶ Generate a string representation of the object and its attributes.
Parameters: - obj – A python object
- col_output_limit – maximum collection limit
Returns: pretty printed string
-
-
class
alib.util.PrintLogger¶ -
static
critical(message, *args, **kwargs)¶
-
static
debug(message, *args, **kwargs)¶
-
static
error(message, *args, **kwargs)¶
-
static
info(message, *args, **kwargs)¶
-
static
log(message, *args, **kwargs)¶
-
static
warning(message, *args, **kwargs)¶
-
static
-
exception
alib.util.RangeError¶
-
alib.util.approx_equal(x, y, accuracy=0.0001)¶
-
alib.util.check_bool(value, none_allowed=True)¶
-
alib.util.check_int(value, none_allowed=True)¶
-
alib.util.check_percentage(value, none_allowed=True)¶
-
alib.util.check_positive(value, none_allowed=True)¶
-
alib.util.check_within_range(value, min, max, none_allowed=True)¶
-
alib.util.get_graph_viz_string(graph, directed=True, get_edge_style=<function <lambda>>)¶
-
alib.util.get_logger(logger_name, make_file=True, make_stream=False, print_level=20, file_level=10, propagate=True, allow_override=False)¶
-
alib.util.get_logger_filename(logger_name)¶
-
alib.util.get_obj_gap(objective, bound)¶
-
alib.util.graph_viz_edge_color_according_to_request_list(edge_set_list, colors=None)¶
-
alib.util.initialize_root_logger(filename, print_level=20, file_level=10, allow_override=False)¶
-
alib.util.log_start_and_end_of_function(logger=<class 'alib.util.PrintLogger'>, start_message='Start: {f}({args})', end_message='End: {f}({args}) after {t} s.')¶
-
alib.util.pretty_print(obj, indentOffset=0, indentStep=2, whitelist=None, max_depth=10000)¶