Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ContentType as Blob vs Zarr and rename blobDateModified to contentDateModified #220

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dandischema/consts.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions dandischema/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@
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")

Check warning on line 305 in dandischema/metadata.py

View check run for this annotation

Codecov / codecov/patch

dandischema/metadata.py#L305

Added line #L305 was not covered by tests
# 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


Expand Down
19 changes: 17 additions & 2 deletions dandischema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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(
Expand Down
Loading