diff --git a/dandischema/consts.py b/dandischema/consts.py index 802cb9f7..e6b1c9ed 100644 --- a/dandischema/consts.py +++ b/dandischema/consts.py @@ -1,4 +1,4 @@ -DANDI_SCHEMA_VERSION = "0.6.5" +DANDI_SCHEMA_VERSION = "0.7.0" ALLOWED_INPUT_SCHEMAS = [ "0.4.4", "0.5.1", @@ -8,6 +8,7 @@ "0.6.2", "0.6.3", "0.6.4", + "0.6.5", ] # ATM we allow only for a single target version which is current diff --git a/dandischema/metadata.py b/dandischema/metadata.py index 21999eae..9a8df6ce 100644 --- a/dandischema/metadata.py +++ b/dandischema/metadata.py @@ -300,6 +300,18 @@ def migrate( if "schemaKey" not in obj: obj["schemaKey"] = "Dandiset" obj["schemaVersion"] = to_version + if version2tuple(schema_version) < version2tuple("0.7.0"): + if "blobDateModified" in obj: + obj["contentDateModified"] = obj.pop("blobDateModified") + # we need to deduce what type of content we have + obj["contentType"] = ( + models.ContentType.Zarr + if ( + obj.get("encodingFormat") == "application/x-zarr" + or obj.get("path", "").endswith(".zarr") + ) + else models.ContentType.Blob + ) return obj diff --git a/dandischema/models.py b/dandischema/models.py index 7633143b..ddf0cb56 100644 --- a/dandischema/models.py +++ b/dandischema/models.py @@ -77,6 +77,16 @@ class AccessType(Enum): """ +class ContentType(Enum): + """An enumeration of types of content asset can have""" + + #: Asset contains a regular file - a data blob + Blob = "dandi:Blob" + + #: Asset contains a zarr (currently a folder) + Zarr = "dandi:Zarr" + + class DigestType(Enum): """An enumeration of checksum types""" @@ -1516,10 +1526,15 @@ class BareAsset(CommonModel): json_schema_extra={"nskey": "schema"}, title="Asset (file or metadata) modification date and time", ) - blobDateModified: Optional[datetime] = Field( + contentType: ContentType = Field( + None, + json_schema_extra={"nskey": "dandi"}, + title="Type of the content asset contains.", + ) + contentDateModified: Optional[datetime] = Field( None, json_schema_extra={"nskey": "dandi"}, - title="Asset file modification date and time.", + title="Asset content modification date and time.", ) # overload to restrict with max_items=1 access: List[AccessRequirements] = Field(