PyPads Class

To start and activate the tracking of your modules, classes and functions, An instantiation of the base class has to be done.

It is recommended to initialize the tracking before importing the modules to be tracked.

class pypads.base.PyPads(uri=None, folder=None, name=None, mapping_paths=None, mapping=None, init_run_fns=None, include_default_mappings=True, logging_fns=None, config=None, reload_modules=False, reload_warnings=True, clear_imports=False, affected_modules=None, pre_initialized_cache=None, disable_run_init=True)[source]

PyPads app and base class. It enable automatic logging for all libraries included in the mapping files. Serves as the main entrypoint to PyPads. After constructing this app tracking is activated.

param uri:string, optional (default=None) Address of local or remote tracking server that MLflow uses to record runs. If None, then it tries to get the environment variable ‘MLFLOW_PATH’ or the ‘HOMEPATH’ of the user.
param name:string, optional (default=None) Name of the MLflow experiment to track.
param mapping_paths:
 list, optional (default=None) Absolute paths to additional mapping files.
param mapping:dict, optional (default=None) Mapping to the logging functions to use for the tracking of the events. If None, then a DEFAULT_MAPPING is used which allow to log parameters, outputs or inputs.
param init_run_fns:
 list, optional (default=None) Logging function to execute on tracking initialization.
param include_default_mappings:
 boolean, optional (default=True) A flag whether to use the default provided mappings or not.
param logging_fns:
 dict, optional (default=None) User defined logging functions to use where each dict item has to be ‘ “event”: fn’ or ‘ “event”: {fn1,fn2,…}’.
param config:dict, optional (default=None) A dictionary that maps the events defined in PyPads mapping files with the logging functions.
param reload_modules:
 boolean, optional (default=False) Reload and duck punch already loaded modules before the tracking activation if set to True.
param clear_imports:
 boolean, optional (default=False) Delete alredy loaded modules for sys.modules() if set to True.
activate_tracking(reload_modules=False, reload_warnings=True, clear_imports=False, affected_modules=None)[source]

Function to duck punch all objects defined in the mapping files. This should at best be called before importing any libraries. :param mod_globals: globals() object used to duckpunch already loaded classes :return:

add_atexit_fn(fn)[source]

Add function to be executed before stopping your process.

Default settings

The default configuration of events/hooks:

DEFAULT_CONFIG = {"events": {
"init": {"on": ["pypads_init"]},
"parameters": {"on": ["pypads_fit"]},
"hardware": {"on": ["pypads_fit"]},
"output": {"on": ["pypads_fit", "pypads_predict"]},
"input": {"on": ["pypads_fit"], "with": {"_pypads_write_format": WriteFormats.text.name}},
"metric": {"on": ["pypads_metric"]},
"pipeline": {"on": ["pypads_fit", "pypads_predict", "pypads_transform", "pypads_metric"]},
"log": {"on": ["pypads_log"]}
},
    "recursion_identity": False,
    "recursion_depth": -1,
    "log_on_failure": True}

The default mapping of events/loggers:

DEFAULT_LOGGING_FNS = {
"parameters": Parameters(),
"output": Output(_pypads_write_format=WriteFormats.text.name),
"input": Input(_pypads_write_format=WriteFormats.text.name),
"hardware": {Cpu(), Ram(), Disk()},
"metric": Metric(),
"autolog": MlflowAutologger(),
"pipeline": PipelineTracker(_pypads_pipeline_type="normal", _pypads_pipeline_args=False),
"log": Log(),
"init": LogInit()