notice
This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
rasa.core.utils
configure_file_logging
Configure logging to a file.
Arguments:
logger_obj- Logger object to configure.log_file- Path of log file to write to.
one_hot
Create a one-hot array.
Arguments:
hot_idx- Index of the hot element.length- Length of the array.dtype-numpy.dtypeof the array.
Returns:
One-hot array.
dump_obj_as_yaml_to_file
Writes obj to the filename in YAML repr.
Arguments:
filename- Target filename.obj- Object to dump.should_preserve_key_order- Whether to preserve key order inobj.
list_routes
List all the routes of a sanic application.
Mainly used for debugging.
extract_args
Go through the kwargs and filter out the specified keys.
Return both, the filtered kwargs as well as the remaining kwargs.
is_limit_reached
Determine whether the number of messages has reached a limit.
Arguments:
num_messages- The number of messages to check.limit- Limit on the number of messages.
Returns:
True if the limit has been reached, otherwise False.
file_as_bytes
Read in a file as a byte array.
AvailableEndpoints Objects
Collection of configured endpoints.
read_endpoints_from_path
Get AvailableEndpoints object from specified path.
Arguments:
endpoints_path- Path of the endpoints file to be read. IfNonethe default path for that file is used (endpoints.yml).
Returns:
AvailableEndpoints object read from endpoints file.
replace_floats_with_decimals
Convert all instances in obj of float to Decimal.
Arguments:
obj- Input object.round_digits- Rounding precision ofDecimalvalues.
Returns:
Input obj with all float types replaced by Decimals rounded to
round_digits decimal places.
DecimalEncoder Objects
json.JSONEncoder that dumps Decimals as floats.
default
Get serializable object for o.
Arguments:
obj- Object to serialize.
Returns:
obj converted to float if o is a Decimals, else the base class
default() method.
replace_decimals_with_floats
Convert all instances in obj of Decimal to float.
Arguments:
obj- AListorDictobject.
Returns:
Input obj with all Decimal types replaced by floats.
number_of_sanic_workers
Get the number of Sanic workers to use in app.run().
If the environment variable constants.ENV_SANIC_WORKERS is set and is not equal to
1, that value will only be permitted if the used lock store is not the
InMemoryLockStore.
