hypernets.utils package

Submodules

hypernets.utils.common module

class hypernets.utils.common.Counter[source]

Bases: object

inc(step=1)[source]
reset()[source]
value
hypernets.utils.common.camel_keys_to_snake(d: dict)[source]

Example

Convert dict:
{
‘datasetConf’: {
‘trainData’: [‘./train.csv’]

}

}

to:
{
‘dataset_conf’: {
‘train_data’: [‘./train.csv’]

}

}

hypernets.utils.common.camel_to_snake(camel_str)[source]

Example

Convert ‘camelToSnake’ to ‘camel_to_snake’

hypernets.utils.common.combinations(n, m_max, m_min=1)[source]
hypernets.utils.common.context(msg)[source]
hypernets.utils.common.generate_id()[source]
hypernets.utils.common.generate_short_id()[source]
hypernets.utils.common.get_params(obj, include_default=False)[source]
hypernets.utils.common.get_temp_dir_path(prefix=None, suffix=None, create=True)[source]
hypernets.utils.common.get_temp_file_path(prefix=None, suffix=None)[source]
hypernets.utils.common.human_data_size(value)[source]
hypernets.utils.common.isnotebook()[source]

code from https://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook :return:

hypernets.utils.common.load_module(mod_name)[source]
hypernets.utils.common.profile(fn, sort_by='cumtime')[source]
hypernets.utils.common.to_repr(obj, excludes=None)[source]

hypernets.utils.const module

hypernets.utils.df_utils module

hypernets.utils.df_utils.as_array(array_data)[source]
hypernets.utils.df_utils.get_data_character(hyper_model, X_train, y_train, X_eval=None, y_eval=None, X_test=None, task=None)[source]
hypernets.utils.df_utils.get_x_data_character(X_train, get_step)[source]

hypernets.utils.logging module

Logging utilities, adapted from tf_logging

class hypernets.utils.logging.CustomizedLogFormatter(fmt=None, datefmt=None, style='%')[source]

Bases: logging.Formatter

formatMessage(record)[source]
static get_simple_name(name)[source]
class hypernets.utils.logging.CustomizedLogger(name, level=20)[source]

Bases: logging.Logger

DEBUG = 10
ERROR = 40
FATAL = 50
INFO = 20
WARN = 30
debug(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘DEBUG’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)

error(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘ERROR’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)

fatal(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘CRITICAL’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)

getEffectiveLevel()[source]

Get the effective level for this logger.

Loop through this logger and its parents in the logger hierarchy, looking for a non-zero logging level. Return the first one found.

info(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘INFO’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)

isEnabledFor(level)[source]

Is this logger enabled for level ‘level’?

is_debug_enabled()[source]
is_enabled_for(level)[source]
is_info_enabled()[source]
is_warning_enabled()[source]
log(level, msg, *args, **kwargs)[source]

Log ‘msg % args’ with the integer severity ‘level’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.log(level, “We have a %s”, “mysterious problem”, exc_info=1)

log_every_n(level, msg, n, *args)[source]

Log ‘msg % args’ at level ‘level’ once per ‘n’ times.

Logs the 1st call, (N+1)st call, (2N+1)st call, etc. Not threadsafe.

Parameters:
  • level – The level at which to log.
  • msg – The message to be logged.
  • n – The number of times this should be called before it is logged.
  • *args – The args to be substituted into the msg.
log_first_n(level, msg, n, *args)[source]

Log ‘msg % args’ at level ‘level’ only first ‘n’ times.

Not threadsafe.

Parameters:
  • level – The level at which to log.
  • msg – The message to be logged.
  • n – The number of times this should be called before it is logged.
  • *args – The args to be substituted into the msg.
log_if(level, msg, condition, *args)[source]

Log ‘msg % args’ at level ‘level’ only if condition is fulfilled.

warn(msg, *args, **kwargs)[source]
warning(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘WARNING’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.warning(“Houston, we have a %s”, “bit of a problem”, exc_info=1)

hypernets.utils.logging.getLogger(name)[source]
hypernets.utils.logging.get_level()[source]

Return how much logging output will be produced for newer logger.

hypernets.utils.logging.get_logger(name)[source]
hypernets.utils.logging.set_level(v)[source]

Sets newer logger threshold for what messages will be logged.

hypernets.utils.logging.to_level(v)[source]

hypernets.utils.param_tuning module

hypernets.utils.param_tuning.build_searcher(cls, func, optimize_direction='min')[source]
hypernets.utils.param_tuning.func_space(func)[source]
hypernets.utils.param_tuning.search_params(func, searcher='Grid', max_trials=100, optimize_direction='min', history=None, callbacks=None, **func_kwargs)[source]

hypernets.utils.ssh_utils module

hypernets.utils.ssh_utils.create_ssh_client(hostname, username, port=22, password=None, ssh_rsa_file=None, passphrase=None) → paramiko.client.SSHClient[source]
hypernets.utils.ssh_utils.exists(sftp: paramiko.sftp_client.SFTPClient, remote_path)[source]
hypernets.utils.ssh_utils.makedirs(sftp: paramiko.sftp_client.SFTPClient, remote_dir)[source]
hypernets.utils.ssh_utils.sftp_client(*args, **kwargs)[source]
hypernets.utils.ssh_utils.ssh_client(*args, **kwargs)[source]
hypernets.utils.ssh_utils.upload_dir(sftp: paramiko.sftp_client.SFTPClient, local_dir, remote_dir)[source]

Recursive upload local dir to remote :param sftp: :param local_dir: a local dir :param remote_dir: a not exists path in remote server :return:

hypernets.utils.ssh_utils.upload_file(sftp: paramiko.sftp_client.SFTPClient, local_path, remote_path)[source]

Copy local file to remote. if remote dir is not exists should create it. :param sftp: :param local_path: a file :param remote_path: a file path, is not exists and included file name :return:

hypernets.utils.ssh_utils.upload_file_obj(sftp: paramiko.sftp_client.SFTPClient, fo, remote_path)[source]

Upload file object to remote. if remote dir is not exists should create it. :param sftp: :param fo: file obj :param remote_path: a file path, is not exists and included file name :return:

Module contents