Utils

unimol_tools.utils contains the utils related to the model, such as metrics and logger.

Metrics

unimol_tools.utils.metrics contains the metrics included in the model.

Logger

unimol_tools.utils.base_logger.py control the logger.

class unimol_tools.utils.base_logger.PackagePathFilter(name='')[source]

A custom logging filter for adding the relative path to the log record.

filter(record)[source]

add relative path to record

class unimol_tools.utils.base_logger.Logger(*args, **kwargs)[source]

A custom logger class that provides logging functionality to console and file.

__init__(logger_name='None')[source]
Parameters:

logger_name – (str) The name of the logger (default: ‘None’)

get_logger()[source]

Get the logger object.

Returns:

logging.Logger - a logger object.

class unimol_tools.utils.base_logger.HighlightFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]
format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

Config

unimol_tools.utils.config_handler.py manages the config input file.

class unimol_tools.utils.config_handler.YamlHandler(file_path)[source]

A class to read and write the yaml file

__init__(file_path)[source]

A custom logger class that provides logging functionality to console and file.

Parameters:

file_path – (str) The yaml file path of the config.

read_yaml(encoding='utf-8')[source]

read yaml file and convert to easydict

Parameters:

encoding – (str) encoding method uses utf-8 by default

Returns:

Dict (addict), the usage of Dict is the same as dict

write_yaml(data, out_file_path, encoding='utf-8')[source]

write dict or easydict to yaml file(auto write to self.file_path)

Parameters:

data – (dict or Dict(addict)) dict containing the contents of the yaml file

unimol_tools.utils.config_handler.addict2dict(addict_obj)[source]

convert addict to dict

Parameters:

addict_obj – (Dict(addict)) the addict obj that you want to convert to dict

Returns:

(Dict) converted result

Padding

unimol_tools.utils.util.py contain some padding methods.