hypernets.utils package¶
Submodules¶
hypernets.utils.common module¶
-
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.
isnotebook
()[source]¶ code from https://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook :return:
hypernets.utils.const module¶
hypernets.utils.df_utils module¶
hypernets.utils.logging module¶
Logging utilities, adapted from tf_logging
-
class
hypernets.utils.logging.
CustomizedLogFormatter
(fmt=None, datefmt=None, style='%')[source]¶ Bases:
logging.Formatter
-
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)
-
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.
-
-
hypernets.utils.logging.
get_level
()[source]¶ Return how much logging output will be produced for newer logger.
hypernets.utils.param_tuning module¶
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.
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: