# biome.text.helpers Module

# yaml_to_dict Function


def yaml_to_dict(filepath: str) -> Dict[str, Any]

Loads a yaml file into a data dictionary

Parameters

filepath
Path to the yaml file

Returns

dict
 

# get_compatible_doc_type Function


def get_compatible_doc_type(client: elasticsearch.client.Elasticsearch) -> str

Find a compatible name for doc type by checking the cluster info

Parameters

client
The elasticsearch client

Returns

name
A compatible name for doc type in function of cluster version

# get_env_cuda_device Function


def get_env_cuda_device() -> int

Gets the cuda device from an environment variable.

This is necessary to activate a GPU if available

Returns

cuda_device
The integer number of the CUDA device

# update_method_signature Function


def update_method_signature (
  signature: inspect.Signature,
  to_method: Callable,
)  -> Callable

Updates the signature of a method

Parameters

signature
The signature with which to update the method
to_method
The method whose signature will be updated

Returns

updated_method
 

# isgeneric Function


def isgeneric(class_type: Type) -> bool

Checks if a class type is a generic type (List[str] or Union[str, int]

# is_running_on_notebook Function


def is_running_on_notebook() -> bool

Checks if code is running inside a jupyter notebook

# split_signature_params_by_predicate Function


def split_signature_params_by_predicate (
  signature_function: Callable,
  predicate: Callable,
)  -> Tuple[List[inspect.Parameter], List[inspect.Parameter]]

Splits parameters signature by defined boolean predicate function

# sanitize_metric_name Function


def sanitize_metric_name(name: str) -> str

Sanitizes the name to comply with tensorboardX conventions when logging.

Parameter

name Name of the metric

Returns

sanitized_name
 

# save_dict_as_yaml Function


def save_dict_as_yaml (
  dictionary: dict,
  path: str,
)  -> str

Save a cfg dict to path as yaml

Parameters

dictionary
Dictionary to be saved
path
Filesystem location where the yaml file will be saved

Returns

path
Location of the yaml file

# get_full_class_name Function


def get_full_class_name(the_class: Type) -> str

Given a type class return the full qualified class name

# stringify Function


def stringify(value: Any) -> Any

Creates an equivalent data structure representing data values as string

Parameters

value
Value to be stringified

Returns

stringified_value
 

# sanitize_for_params Function


def sanitize_for_params(x: Any) -> Any

Sanitizes the input for a more flexible usage with AllenNLP's .from_params() machinery.

For now it is mainly used to transform numpy numbers to python types

Parameters

x
The parameter passed on to allennlp.common.FromParams.from_params()

Returns

sanitized_x
 
Maintained by