Skip to content

Commit

Permalink
Fix non-conformant "attributes" metadata (#303)
Browse files Browse the repository at this point in the history
* Fix non-conformant "attributes" metadata

* fmt
  • Loading branch information
LDeakin authored Oct 19, 2024
1 parent aa7f8ac commit 6ef42f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from zarr.core.sync import collect_aiterator
from zarr.testing.store import StoreTests

DEFAULT_GROUP_METADATA = b'{"zarr_format":3,"node_type":"group","attributes":null}'
DEFAULT_GROUP_METADATA = b'{"zarr_format":3,"node_type":"group"}'
ARRAY_METADATA = (
b'{"zarr_format":3,"node_type":"array","attributes":{"foo":42},'
b'"shape":[2,2,2],"data_type":"int32","chunk_grid":{"name":"regular","configuration":{"chunk_shape":[1,1,1]}},'
Expand Down
6 changes: 3 additions & 3 deletions icechunk/src/zarr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ struct ArrayMetadata {
zarr_format: u8,
#[serde(deserialize_with = "validate_array_node_type")]
node_type: String,
#[serde(skip_serializing_if = "Option::is_none")]
attributes: Option<UserAttributes>,
#[serde(flatten)]
#[serde_as(as = "TryFromInto<ZarrArrayMetadataSerialzer>")]
Expand Down Expand Up @@ -1283,6 +1284,7 @@ struct GroupMetadata {
zarr_format: u8,
#[serde(deserialize_with = "validate_group_node_type")]
node_type: String,
#[serde(skip_serializing_if = "Option::is_none")]
attributes: Option<UserAttributes>,
}

Expand Down Expand Up @@ -1726,9 +1728,7 @@ mod tests {
.await?;
assert_eq!(
store.get("zarr.json", &ByteRange::ALL).await.unwrap(),
Bytes::copy_from_slice(
br#"{"zarr_format":3,"node_type":"group","attributes":null}"#
)
Bytes::copy_from_slice(br#"{"zarr_format":3,"node_type":"group"}"#)
);

store.set("a/b/zarr.json", Bytes::copy_from_slice(br#"{"zarr_format":3, "node_type":"group", "attributes": {"spam":"ham", "eggs":42}}"#)).await?;
Expand Down

0 comments on commit 6ef42f1

Please sign in to comment.