rasa.utils.common
TempDirectoryPath Objects
Represents a path to an temporary directory.
When used as a context manager, it erases the contents of the directory on exit.
get_temp_dir_name
Returns the path name of a newly created temporary directory.
decode_bytes
Converts bytes object to string.
read_global_config
Read global Rasa configuration.
Arguments:
path
- Path to the configuration
Returns:
The global configuration
configure_logging_from_file
Parses YAML file content to configure logging.
Arguments:
logging_config_file
- YAML file containing logging configuration to handle custom formatting
configure_logging_and_warnings
Sets log levels of various loggers and sets up filters for warnings and logs.
Arguments:
log_level
- The log level to be used for the 'Rasa' logger. PassNone
to use either the environment variable 'LOG_LEVEL' if it is specified, or the default log level otherwise.logging_config_file
- YAML file containing logging configuration to handle custom formattingwarn_only_once
- determines whether user warnings should be filtered by thewarnings
module to appear only "once"filter_repeated_logs
- determines whetherRepeatedLogFilter
s are added to the handlers of the root logger
configure_library_logging
Configures log levels of used libraries such as kafka, matplotlib, pika.
update_apscheduler_log_level
Configures the log level of apscheduler.*
loggers.
update_socketio_log_level
Set the log level of socketio.
update_tensorflow_log_level
Sets Tensorflow log level based on env variable 'LOG_LEVEL_LIBRARIES'.
update_sanic_log_level
Set the log level to 'LOG_LEVEL_LIBRARIES' environment variable .
update_asyncio_log_level
Set the log level of asyncio to the log level.
Uses the log level specified in the environment variable 'LOG_LEVEL_LIBRARIES'.
update_matplotlib_log_level
Set the log level of matplotlib.
Uses the library specific log level or the general libraries log level.
update_kafka_log_level
Set the log level of kafka.
Uses the library specific log level or the general libraries log level.
update_rabbitmq_log_level
Set the log level of pika.
Uses the library specific log level or the general libraries log level.
sort_list_of_dicts_by_first_key
Sorts a list of dictionaries by their first key.
write_global_config_value
Read global Rasa configuration.
Arguments:
name
- Name of the configuration keyvalue
- Value the configuration key should be set to
Returns:
True
if the operation was successful.
read_global_config_value
Read a value from the global Rasa configuration.
update_existing_keys
Iterate through all the updates and update a value in the original dictionary.
If the updates contain a key that is not present in the original dict, it will be ignored.
override_defaults
Override default config with the given config.
We cannot use dict.update
method because configs contain nested dicts.
Arguments:
defaults
- default configcustom
- user config containing new parameters
Returns:
updated config
RepeatedLogFilter Objects
Filter repeated log records.
filter
Determines whether current log is different to last log.
call_potential_coroutine
Awaits coroutine or returns value directly if it's not a coroutine.
Arguments:
coroutine_or_return_value
- Either the return value of a synchronous function call or a coroutine which needs to be await first.
Returns:
The return value of the function.
directory_size_in_mb
Calculates the size of a directory.
Arguments:
path
- The path to the directory.filenames_to_exclude
- Allows excluding certain files from the calculation.
Returns:
Directory size in MiB.
copy_directory
Copies the content of one directory into another.
Arguments:
source
- The directory whose contents should be copied todestination
.destination
- The directory which should contain the contentsource
in the end.
Raises:
ValueError
- If destination is not empty.
find_unavailable_packages
Tries to import all package names and returns the packages where it failed.
Arguments:
package_names
- The package names to import.
Returns:
Package names that could not be imported.
module_path_from_class
Return the module path of an instance's class.
get_bool_env_variable
Fetch bool value stored in environment variable.
If environment variable is set but value is not of boolean nature, an exception will be raised.
Args: variable_name: Name of the environment variable. default_variable_value: Value to be returned if environment variable is not set.
Returns:
A boolean value stored in the environment variable or default value if environment variable is not set.