Skip to content

unienv_interface.utils.symbol_util

REMAP module-attribute

REMAP = {'unienv_data.storages.common.FlattenedStorage': 'unienv_data.storages.flattened.FlattenedStorage'}

get_full_class_name

get_full_class_name(cls: Type) -> str

get_class_from_full_name

get_class_from_full_name(full_name: str) -> Type

get_full_function_name

get_full_function_name(fn: Callable) -> str

Get the full name of a function for serialization.

get_function_from_full_name

get_function_from_full_name(full_name: str) -> Callable

Get a function from its full name.

serialize_function

serialize_function(fn: Callable) -> Dict[str, Any]

Serialize a function to a JSON-compatible dictionary.

Tries to serialize by full name first. If the function doesn't have a proper module name (e.g., lambda, local function), uses cloudpickle + base64.

Returns:

Name Type Description
dict Dict[str, Any]

Contains either: - {"mode": "name", "value": "full.module.name"} - {"mode": "pickle", "value": "base64_encoded_pickle"}

deserialize_function

deserialize_function(data: Mapping[str, Any]) -> Callable

Deserialize a function from a JSON-compatible dictionary.

Parameters:

Name Type Description Default
data Mapping[str, Any]

Mapping containing the serialized function with "mode" and "value" keys.

required

Returns:

Name Type Description
Callable Callable

The deserialized function.