Skip to content
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 @@ def migrate(
if "schemaKey" not in obj:
obj["schemaKey"] = "Dandiset"
obj["schemaVersion"] = to_version
if version2tuple(schema_version) < version2tuple("0.7.0"):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here will need to become some future version now that 0.7.0 is out... we might want to introduce next branch alike to next in linux development, or more specifically next-0.8.0 and position this PR against it so we could absorb meanwhile non-breaking changes

Suggested change
if version2tuple(schema_version) < version2tuple("0.7.0"):
if version2tuple(schema_version) < version2tuple("0.8.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
)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not yet 100% certain since we have only 2 cases -- it is either zarr or not (blob), but this field and code would be the "centralization" of the logic for DANDI-specific behavior of zarr-vs-blob. Otherwise, if we add some other "contentType" later on (e.g. remoteLink 🤷) such comparisons would need to be duplicated in every piece of code... we would need likely to add validation for that logic also at pydantic or linkml level.

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