Skip to content

Handle deserialized number in metadata schema

Choose a tag to compare

@nvn-nil nvn-nil released this 21 Mar 12:17
· 9 commits to main since this release

Content

Feature

When using cloud storage, metadata stored on the blob is of type Dict[string, string], which means numbers are stored as strings. Retrieving metadata from the blob returns string numbers, which may fail schema validation.

This update introduces a flag for handling number types in the schema when working with cloud metadata. It casts the fields in the passed-in metadata to float before performing metadata validation.

metadata = {"location": "Point(12 13.0)", "elevation": "123", "timezone": "UTC", "file_id": str(uuid4())}
file_path, casted_validated_metadata = validate_file(file_path, metadata, definition_file_path, handle_deserialized_metadata=True)
# {'location': 'Point(12 13.0)', 'elevation': 123.0, 'timezone': 'UTC', 'file_id': 'd4591649-e619-44bd-930a-9076793fc373'}