rlmesh.sanitize_metadata

functionfrom rlmesh import sanitize_metadata[source]

Coerce an info/metadata mapping into what RLMesh metadata accepts.

sanitize_metadata(info: Mapping[str, Any]) -> dict[str, Any]

Lossy by design: simulator handles and other rich objects (for example a sapien.Pose) become their str() form rather than failing the serve path. Accepted values pass through unchanged: None, bool, int, float, str, bytes, and nested mappings/lists/tuples of them (tuples become lists, as in the codec). NumPy scalars/arrays and namedtuples are unwrapped the way the codec does (_asdict / tolist / item), enums resolve to their value with a name fallback, and non-string keys are stringified.

Parameters

NameTypeDescription
infoMapping[str, Any]The mapping to sanitize (e.g. a Gymnasium info dict).

Returns

TypeDescription
dict[str, Any]A plain dict the native metadata codec accepts verbatim.

Raises

TypeDescription
TypeErrorIf info is not a mapping.
ValueErrorIf info contains a reference cycle (the error names the key path).