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

Add API support for Embargoed Zarrs #2069

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add API support for Embargoed Zarrs #2069

wants to merge 6 commits into from

Conversation

jjnesbitt
Copy link
Member

This PR adds API support for embargoed zarrs, with the following notable changes:

  1. ZarrArchive, EmbargoedZarrArchive, and BaseZarrArchive have all been merged into one ZarrArchive model.
  2. The Asset model now has an is_embargoed property, which will account for both asset blob and zarr embargo status.
  3. The unembargo_dandiset function has been extended to include zarrs.
  4. The zarr list and retrieve endpoints have been modified to account for embargoed zarrs. If the requested zarr is embargoed, and the user is either unauthenticated or not an owner on the respective dandiset, a 404 Not Found is returned.

This does not address any changes in the GUI, as I'm unsure what exactly that entails. These changes are necessary for embargoed zarr support in any case, and so can be merged before any GUI re-work.

- Remove EmbargoedZarrArchive model
- Remove BaseZarrArchive abstract model
- Add ZarrArchive.embargoed column
- Fix imports and model usage
@@ -162,6 +162,13 @@ def is_blob(self):
def is_zarr(self):
return self.zarr is not None

@property
def is_embargoed(self):
Copy link
Member

Choose a reason for hiding this comment

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

Pylance shows the return type here as (bool | Any) for me, I assume due to it not being able to infer the type of self.zarr.embargoed.

Suggested change
def is_embargoed(self):
def is_embargoed(self) -> bool:

if (
asset_blob is not None
asset_blob
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for removing the is not None condition here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, i'll revert that.

Comment on lines +1 to +21
# Generated by Django 4.1.13 on 2024-08-21 16:06
from __future__ import annotations

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('zarr', '0003_alter_embargoedzarrarchive_options_and_more'),
]

operations = [
migrations.AddField(
model_name='zarrarchive',
name='embargoed',
field=models.BooleanField(default=False),
),
migrations.DeleteModel(
name='EmbargoedZarrArchive',
),
]
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to migrate the existing EmbargoedZarrArchive objects to the ZarrArchive table before deleting the EmbargoedZarrArchive table?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are no existing EmbargoedZarrArchives, and aren't supported in any real way even if they did exist. So I think this achieves what we want.

@@ -106,6 +106,7 @@ def create_zarr(*, dandiset: Dandiset, user: User, zarr_archive: ZarrArchive) ->
details = {
'zarr_id': str(zarr_archive.zarr_id),
'name': zarr_archive.name,
'embargoed': dandiset.embargoed,
Copy link
Member Author

Choose a reason for hiding this comment

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

@waxlamp does this make sense? I figured it's good to store this since I don't know if it's readily available on the zarr otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants