From c9392ecbb3c65ebda82f039edceaea386c2b50b3 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Wed, 13 Dec 2023 23:57:31 -0500 Subject: [PATCH] Manually fix line lengths --- .../migrate_published_version_metadata.py | 3 +- dandiapi/api/models/version.py | 5 +- dandiapi/api/services/metadata/__init__.py | 7 +- dandiapi/api/tests/test_dandiset.py | 298 +++++++++--------- dandiapi/api/tests/test_tasks.py | 101 +++--- dandiapi/api/tests/test_upload.py | 6 +- dandiapi/api/tests/test_version.py | 99 +++--- dandiapi/search/migrations/0001_initial.py | 15 +- dandiapi/zarr/models.py | 10 +- 9 files changed, 274 insertions(+), 270 deletions(-) diff --git a/dandiapi/api/management/commands/migrate_published_version_metadata.py b/dandiapi/api/management/commands/migrate_published_version_metadata.py index d9884b330..df648acc4 100644 --- a/dandiapi/api/management/commands/migrate_published_version_metadata.py +++ b/dandiapi/api/management/commands/migrate_published_version_metadata.py @@ -16,7 +16,8 @@ @click.argument('to_version') def migrate_published_version_metadata(*, dandiset: str, published_version: str, to_version: str): click.echo( - f'Migrating published version {dandiset}/{published_version} metadata to version {to_version}' + f'Migrating published version {dandiset}/{published_version} ' + f'metadata to version {to_version}' ) version = Version.objects.exclude(version='draft').get( dandiset=dandiset, version=published_version diff --git a/dandiapi/api/models/version.py b/dandiapi/api/models/version.py index 42cfb83a7..cac103586 100644 --- a/dandiapi/api/models/version.py +++ b/dandiapi/api/models/version.py @@ -185,7 +185,10 @@ def _populate_metadata(self): 'version': self.version, 'id': f'DANDI:{self.dandiset.identifier}/{self.version}', 'repository': settings.DANDI_WEB_APP_URL, - 'url': f'{settings.DANDI_WEB_APP_URL}/dandiset/{self.dandiset.identifier}/{self.version}', + 'url': ( + f'{settings.DANDI_WEB_APP_URL}/dandiset/' + f'{self.dandiset.identifier}/{self.version}' + ), 'dateCreated': self.dandiset.created.isoformat(), } diff --git a/dandiapi/api/services/metadata/__init__.py b/dandiapi/api/services/metadata/__init__.py index bdd6179fd..6d9b7b626 100644 --- a/dandiapi/api/services/metadata/__init__.py +++ b/dandiapi/api/services/metadata/__init__.py @@ -117,9 +117,10 @@ def _build_validatable_version_metadata(version: Version) -> dict: metadata_for_validation[ 'id' ] = f'DANDI:{publishable_version.dandiset.identifier}/{publishable_version.version}' - metadata_for_validation[ - 'url' - ] = f'{settings.DANDI_WEB_APP_URL}/dandiset/{publishable_version.dandiset.identifier}/{publishable_version.version}' + metadata_for_validation['url'] = ( + f'{settings.DANDI_WEB_APP_URL}/dandiset/' + f'{publishable_version.dandiset.identifier}/{publishable_version.version}' + ) metadata_for_validation['doi'] = '10.80507/dandi.123456/0.123456.1234' metadata_for_validation['assetsSummary'] = { 'schemaKey': 'AssetsSummary', diff --git a/dandiapi/api/tests/test_dandiset.py b/dandiapi/api/tests/test_dandiset.py index baa36589a..5495b97d4 100644 --- a/dandiapi/api/tests/test_dandiset.py +++ b/dandiapi/api/tests/test_dandiset.py @@ -374,45 +374,42 @@ def test_dandiset_rest_create(api_client, user): # Verify that computed metadata was injected year = datetime.datetime.now(datetime.UTC).year url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{dandiset.identifier}/draft' - assert ( - dandiset.draft_version.metadata - == { - **metadata, - 'manifestLocation': [ - f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' - ], - 'name': name, - 'identifier': DANDISET_SCHEMA_ID_RE, - 'id': f'DANDI:{dandiset.identifier}/draft', - 'version': 'draft', - 'url': url, - 'dateCreated': UTC_ISO_TIMESTAMP_RE, - 'citation': ( - f'{user.last_name}, {user.first_name} ({year}) {name} ' - f'(Version draft) [Data set]. DANDI archive. {url}' - ), - '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', - 'schemaVersion': settings.DANDI_SCHEMA_VERSION, - 'schemaKey': 'Dandiset', - 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], - 'repository': settings.DANDI_WEB_APP_URL, - 'contributor': [ - { - 'name': 'Doe, John', - 'email': user.email, - 'roleName': ['dcite:ContactPerson'], - 'schemaKey': 'Person', - 'affiliation': [], - 'includeInCitation': True, - } - ], - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 0, - 'numberOfFiles': 0, - }, - } - ) + assert dandiset.draft_version.metadata == { + **metadata, + 'manifestLocation': [ + f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' + ], + 'name': name, + 'identifier': DANDISET_SCHEMA_ID_RE, + 'id': f'DANDI:{dandiset.identifier}/draft', + 'version': 'draft', + 'url': url, + 'dateCreated': UTC_ISO_TIMESTAMP_RE, + 'citation': ( + f'{user.last_name}, {user.first_name} ({year}) {name} ' + f'(Version draft) [Data set]. DANDI archive. {url}' + ), + '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', + 'schemaVersion': settings.DANDI_SCHEMA_VERSION, + 'schemaKey': 'Dandiset', + 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], + 'repository': settings.DANDI_WEB_APP_URL, + 'contributor': [ + { + 'name': 'Doe, John', + 'email': user.email, + 'roleName': ['dcite:ContactPerson'], + 'schemaKey': 'Person', + 'affiliation': [], + 'includeInCitation': True, + } + ], + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 0, + 'numberOfFiles': 0, + }, + } @pytest.mark.django_db() @@ -470,45 +467,42 @@ def test_dandiset_rest_create_with_identifier(api_client, admin_user): # Verify that computed metadata was injected year = datetime.datetime.now(datetime.UTC).year url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{dandiset.identifier}/draft' - assert ( - dandiset.draft_version.metadata - == { - **metadata, - 'manifestLocation': [ - f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' - ], - 'name': name, - 'identifier': f'DANDI:{identifier}', - 'id': f'DANDI:{dandiset.identifier}/draft', - 'version': 'draft', - 'url': url, - 'dateCreated': UTC_ISO_TIMESTAMP_RE, - 'citation': ( - f'{admin_user.last_name}, {admin_user.first_name} ({year}) {name} ' - f'(Version draft) [Data set]. DANDI archive. {url}' - ), - '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', - 'schemaVersion': settings.DANDI_SCHEMA_VERSION, - 'schemaKey': 'Dandiset', - 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], - 'repository': settings.DANDI_WEB_APP_URL, - 'contributor': [ - { - 'name': 'Doe, John', - 'email': admin_user.email, - 'roleName': ['dcite:ContactPerson'], - 'schemaKey': 'Person', - 'affiliation': [], - 'includeInCitation': True, - } - ], - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 0, - 'numberOfFiles': 0, - }, - } - ) + assert dandiset.draft_version.metadata == { + **metadata, + 'manifestLocation': [ + f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' + ], + 'name': name, + 'identifier': f'DANDI:{identifier}', + 'id': f'DANDI:{dandiset.identifier}/draft', + 'version': 'draft', + 'url': url, + 'dateCreated': UTC_ISO_TIMESTAMP_RE, + 'citation': ( + f'{admin_user.last_name}, {admin_user.first_name} ({year}) {name} ' + f'(Version draft) [Data set]. DANDI archive. {url}' + ), + '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', + 'schemaVersion': settings.DANDI_SCHEMA_VERSION, + 'schemaKey': 'Dandiset', + 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], + 'repository': settings.DANDI_WEB_APP_URL, + 'contributor': [ + { + 'name': 'Doe, John', + 'email': admin_user.email, + 'roleName': ['dcite:ContactPerson'], + 'schemaKey': 'Person', + 'affiliation': [], + 'includeInCitation': True, + } + ], + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 0, + 'numberOfFiles': 0, + }, + } @pytest.mark.django_db() @@ -580,44 +574,41 @@ def test_dandiset_rest_create_with_contributor(api_client, admin_user): # Verify that computed metadata was injected year = datetime.datetime.now(datetime.UTC).year url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{dandiset.identifier}/draft' - assert ( - dandiset.draft_version.metadata - == { - **metadata, - 'manifestLocation': [ - f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' - ], - 'name': name, - 'identifier': f'DANDI:{identifier}', - 'id': f'DANDI:{dandiset.identifier}/draft', - 'version': 'draft', - 'url': url, - 'dateCreated': UTC_ISO_TIMESTAMP_RE, - 'citation': ( - f'Jane Doe ({year}) {name} ' f'(Version draft) [Data set]. DANDI archive. {url}' - ), - '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', - 'schemaVersion': settings.DANDI_SCHEMA_VERSION, - 'schemaKey': 'Dandiset', - 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], - 'repository': settings.DANDI_WEB_APP_URL, - 'contributor': [ - { - 'name': 'Jane Doe', - 'email': 'jane.doe@kitware.com', - 'roleName': ['dcite:ContactPerson'], - 'schemaKey': 'Person', - 'affiliation': [], - 'includeInCitation': True, - } - ], - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 0, - 'numberOfFiles': 0, - }, - } - ) + assert dandiset.draft_version.metadata == { + **metadata, + 'manifestLocation': [ + f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' + ], + 'name': name, + 'identifier': f'DANDI:{identifier}', + 'id': f'DANDI:{dandiset.identifier}/draft', + 'version': 'draft', + 'url': url, + 'dateCreated': UTC_ISO_TIMESTAMP_RE, + 'citation': ( + f'Jane Doe ({year}) {name} ' f'(Version draft) [Data set]. DANDI archive. {url}' + ), + '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', + 'schemaVersion': settings.DANDI_SCHEMA_VERSION, + 'schemaKey': 'Dandiset', + 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:OpenAccess'}], + 'repository': settings.DANDI_WEB_APP_URL, + 'contributor': [ + { + 'name': 'Jane Doe', + 'email': 'jane.doe@kitware.com', + 'roleName': ['dcite:ContactPerson'], + 'schemaKey': 'Person', + 'affiliation': [], + 'includeInCitation': True, + } + ], + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 0, + 'numberOfFiles': 0, + }, + } @pytest.mark.django_db() @@ -673,45 +664,42 @@ def test_dandiset_rest_create_embargoed(api_client, user): # Verify that computed metadata was injected year = datetime.datetime.now(datetime.UTC).year url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{dandiset.identifier}/draft' - assert ( - dandiset.draft_version.metadata - == { - **metadata, - 'manifestLocation': [ - f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' - ], - 'name': name, - 'identifier': DANDISET_SCHEMA_ID_RE, - 'id': f'DANDI:{dandiset.identifier}/draft', - 'version': 'draft', - 'url': url, - 'dateCreated': UTC_ISO_TIMESTAMP_RE, - 'citation': ( - f'{user.last_name}, {user.first_name} ({year}) {name} ' - f'(Version draft) [Data set]. DANDI archive. {url}' - ), - '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', - 'schemaVersion': settings.DANDI_SCHEMA_VERSION, - 'schemaKey': 'Dandiset', - 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:EmbargoedAccess'}], - 'repository': settings.DANDI_WEB_APP_URL, - 'contributor': [ - { - 'name': 'Doe, John', - 'email': user.email, - 'roleName': ['dcite:ContactPerson'], - 'schemaKey': 'Person', - 'affiliation': [], - 'includeInCitation': True, - } - ], - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 0, - 'numberOfFiles': 0, - }, - } - ) + assert dandiset.draft_version.metadata == { + **metadata, + 'manifestLocation': [ + f'{settings.DANDI_API_URL}/api/dandisets/{dandiset.identifier}/versions/draft/assets/' + ], + 'name': name, + 'identifier': DANDISET_SCHEMA_ID_RE, + 'id': f'DANDI:{dandiset.identifier}/draft', + 'version': 'draft', + 'url': url, + 'dateCreated': UTC_ISO_TIMESTAMP_RE, + 'citation': ( + f'{user.last_name}, {user.first_name} ({year}) {name} ' + f'(Version draft) [Data set]. DANDI archive. {url}' + ), + '@context': f'https://raw.githubusercontent.com/dandi/schema/master/releases/{settings.DANDI_SCHEMA_VERSION}/context.json', + 'schemaVersion': settings.DANDI_SCHEMA_VERSION, + 'schemaKey': 'Dandiset', + 'access': [{'schemaKey': 'AccessRequirements', 'status': 'dandi:EmbargoedAccess'}], + 'repository': settings.DANDI_WEB_APP_URL, + 'contributor': [ + { + 'name': 'Doe, John', + 'email': user.email, + 'roleName': ['dcite:ContactPerson'], + 'schemaKey': 'Person', + 'affiliation': [], + 'includeInCitation': True, + } + ], + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 0, + 'numberOfFiles': 0, + }, + } @pytest.mark.django_db() diff --git a/dandiapi/api/tests/test_tasks.py b/dandiapi/api/tests/test_tasks.py index 6ac1e2cea..15cdea730 100644 --- a/dandiapi/api/tests/test_tasks.py +++ b/dandiapi/api/tests/test_tasks.py @@ -301,59 +301,56 @@ def test_publish_task( published_version = draft_version.dandiset.versions.latest('created') - assert ( - published_version.metadata - == { - **draft_version.metadata, - 'publishedBy': { - 'id': URN_RE, - 'name': 'DANDI publish', - 'startDate': UTC_ISO_TIMESTAMP_RE, - 'endDate': UTC_ISO_TIMESTAMP_RE, - 'wasAssociatedWith': [ - { - 'id': URN_RE, - 'identifier': 'RRID:SCR_017571', - 'name': 'DANDI API', - # TODO: version the API - 'version': '0.1.0', - 'schemaKey': 'Software', - } - ], - 'schemaKey': 'PublishActivity', - }, - 'datePublished': UTC_ISO_TIMESTAMP_RE, - 'manifestLocation': [ - f'http://{settings.MINIO_STORAGE_ENDPOINT}/test-dandiapi-dandisets/test-prefix/dandisets/{draft_version.dandiset.identifier}/{published_version.version}/assets.yaml', + assert published_version.metadata == { + **draft_version.metadata, + 'publishedBy': { + 'id': URN_RE, + 'name': 'DANDI publish', + 'startDate': UTC_ISO_TIMESTAMP_RE, + 'endDate': UTC_ISO_TIMESTAMP_RE, + 'wasAssociatedWith': [ + { + 'id': URN_RE, + 'identifier': 'RRID:SCR_017571', + 'name': 'DANDI API', + # TODO: version the API + 'version': '0.1.0', + 'schemaKey': 'Software', + } ], - 'identifier': f'DANDI:{draft_version.dandiset.identifier}', - 'version': published_version.version, - 'id': f'DANDI:{draft_version.dandiset.identifier}/{published_version.version}', - 'url': ( - f'{settings.DANDI_WEB_APP_URL}/dandiset/{draft_version.dandiset.identifier}' - f'/{published_version.version}' - ), - 'citation': published_version.citation(published_version.metadata), - 'doi': f'10.80507/dandi.{draft_version.dandiset.identifier}/{published_version.version}', - # Once the assets are linked, assetsSummary should be computed properly - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 200, - 'numberOfFiles': 2, - 'dataStandard': [ - { - 'schemaKey': 'StandardsType', - 'identifier': 'RRID:SCR_015242', - 'name': 'Neurodata Without Borders (NWB)', - } - ], - 'approach': [], - 'measurementTechnique': [], - 'variableMeasured': [], - 'species': [], - }, - } - ) + 'schemaKey': 'PublishActivity', + }, + 'datePublished': UTC_ISO_TIMESTAMP_RE, + 'manifestLocation': [ + f'http://{settings.MINIO_STORAGE_ENDPOINT}/test-dandiapi-dandisets/test-prefix/dandisets/{draft_version.dandiset.identifier}/{published_version.version}/assets.yaml', + ], + 'identifier': f'DANDI:{draft_version.dandiset.identifier}', + 'version': published_version.version, + 'id': f'DANDI:{draft_version.dandiset.identifier}/{published_version.version}', + 'url': ( + f'{settings.DANDI_WEB_APP_URL}/dandiset/{draft_version.dandiset.identifier}' + f'/{published_version.version}' + ), + 'citation': published_version.citation(published_version.metadata), + 'doi': f'10.80507/dandi.{draft_version.dandiset.identifier}/{published_version.version}', + # Once the assets are linked, assetsSummary should be computed properly + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 200, + 'numberOfFiles': 2, + 'dataStandard': [ + { + 'schemaKey': 'StandardsType', + 'identifier': 'RRID:SCR_015242', + 'name': 'Neurodata Without Borders (NWB)', + } + ], + 'approach': [], + 'measurementTechnique': [], + 'variableMeasured': [], + 'species': [], + }, + } assert published_version.assets.count() == 2 new_draft_asset: Asset = published_version.assets.get(asset_id=old_draft_asset.asset_id) diff --git a/dandiapi/api/tests/test_upload.py b/dandiapi/api/tests/test_upload.py index 193d6fe63..6bd3abf49 100644 --- a/dandiapi/api/tests/test_upload.py +++ b/dandiapi/api/tests/test_upload.py @@ -177,9 +177,9 @@ def test_upload_initialize_embargo(api_client, user, dandiset_factory): assert not Upload.objects.all().exists() upload = EmbargoedUpload.objects.get(upload_id=resp.data['upload_id']) upload_id = str(upload.upload_id) - assert ( - upload.blob.name - == f'test-embargo-prefix/{dandiset.identifier}/blobs/{upload_id[:3]}/{upload_id[3:6]}/{upload_id}' + assert upload.blob.name == ( + f'test-embargo-prefix/{dandiset.identifier}/blobs/' + f'{upload_id[:3]}/{upload_id[3:6]}/{upload_id}' ) diff --git a/dandiapi/api/tests/test_version.py b/dandiapi/api/tests/test_version.py index b010b868d..ca753d39f 100644 --- a/dandiapi/api/tests/test_version.py +++ b/dandiapi/api/tests/test_version.py @@ -117,7 +117,10 @@ def test_published_version_metadata_computed(published_version: Version): 'identifier': f'DANDI:{published_version.dandiset.identifier}', 'version': published_version.version, 'id': f'DANDI:{published_version.dandiset.identifier}/{published_version.version}', - 'doi': f'10.80507/dandi.{published_version.dandiset.identifier}/{published_version.version}', + 'doi': ( + f'10.80507/dandi.' + f'{published_version.dandiset.identifier}/{published_version.version}' + ), 'url': ( f'{settings.DANDI_WEB_APP_URL}/dandiset/' f'{published_version.dandiset.identifier}/{published_version.version}' @@ -140,7 +143,10 @@ def test_published_version_metadata_computed(published_version: Version): def test_version_metadata_citation_draft(draft_version): name = draft_version.metadata['name'].rstrip('.') year = datetime.datetime.now(datetime.UTC).year - url = f'{settings.DANDI_WEB_APP_URL}/dandiset/{draft_version.dandiset.identifier}/{draft_version.version}' + url = ( + f'{settings.DANDI_WEB_APP_URL}/dandiset/' + f'{draft_version.dandiset.identifier}/{draft_version.version}' + ) assert ( draft_version.metadata['citation'] == f'{name} ({year}). (Version {draft_version.version}) [Data set]. DANDI archive. {url}' @@ -152,9 +158,9 @@ def test_version_metadata_citation_published(published_version): name = published_version.metadata['name'].rstrip('.') year = datetime.datetime.now(datetime.UTC).year url = f'https://doi.org/{published_version.doi}' - assert ( - published_version.metadata['citation'] - == f'{name} ({year}). (Version {published_version.version}) [Data set]. DANDI archive. {url}' + assert published_version.metadata['citation'] == ( + f'{name} ({year}). (Version {published_version.version}) [Data set]. ' + f'DANDI archive. {url}' ) @@ -303,50 +309,47 @@ def test_version_publish_version(draft_version, asset): publish_version.save() assert publish_version.dandiset == draft_version.dandiset - assert ( - publish_version.metadata - == { - **draft_version.metadata, - 'publishedBy': { - 'id': URN_RE, - 'name': 'DANDI publish', - 'startDate': UTC_ISO_TIMESTAMP_RE, - 'endDate': UTC_ISO_TIMESTAMP_RE, - 'wasAssociatedWith': [ - { - 'id': URN_RE, - 'identifier': 'RRID:SCR_017571', - 'name': 'DANDI API', - # TODO: version the API - 'version': '0.1.0', - 'schemaKey': 'Software', - } - ], - 'schemaKey': 'PublishActivity', - }, - 'dateCreated': UTC_ISO_TIMESTAMP_RE, - 'datePublished': UTC_ISO_TIMESTAMP_RE, - 'manifestLocation': [ - f'http://{settings.MINIO_STORAGE_ENDPOINT}/test-dandiapi-dandisets/test-prefix/dandisets/{publish_version.dandiset.identifier}/{publish_version.version}/assets.yaml', + assert publish_version.metadata == { + **draft_version.metadata, + 'publishedBy': { + 'id': URN_RE, + 'name': 'DANDI publish', + 'startDate': UTC_ISO_TIMESTAMP_RE, + 'endDate': UTC_ISO_TIMESTAMP_RE, + 'wasAssociatedWith': [ + { + 'id': URN_RE, + 'identifier': 'RRID:SCR_017571', + 'name': 'DANDI API', + # TODO: version the API + 'version': '0.1.0', + 'schemaKey': 'Software', + } ], - 'identifier': f'DANDI:{publish_version.dandiset.identifier}', - 'version': publish_version.version, - 'id': f'DANDI:{publish_version.dandiset.identifier}/{publish_version.version}', - 'url': ( - f'{settings.DANDI_WEB_APP_URL}/dandiset/{publish_version.dandiset.identifier}' - f'/{publish_version.version}' - ), - 'citation': publish_version.citation(publish_version.metadata), - 'doi': fake_doi, - # The published_version cannot have a properly defined assetsSummary yet, since that would - # require having created rows the Asset-to-Version join table, which is a side affect. - 'assetsSummary': { - 'schemaKey': 'AssetsSummary', - 'numberOfBytes': 0, - 'numberOfFiles': 0, - }, - } - ) + 'schemaKey': 'PublishActivity', + }, + 'dateCreated': UTC_ISO_TIMESTAMP_RE, + 'datePublished': UTC_ISO_TIMESTAMP_RE, + 'manifestLocation': [ + f'http://{settings.MINIO_STORAGE_ENDPOINT}/test-dandiapi-dandisets/test-prefix/dandisets/{publish_version.dandiset.identifier}/{publish_version.version}/assets.yaml', + ], + 'identifier': f'DANDI:{publish_version.dandiset.identifier}', + 'version': publish_version.version, + 'id': f'DANDI:{publish_version.dandiset.identifier}/{publish_version.version}', + 'url': ( + f'{settings.DANDI_WEB_APP_URL}/dandiset/{publish_version.dandiset.identifier}' + f'/{publish_version.version}' + ), + 'citation': publish_version.citation(publish_version.metadata), + 'doi': fake_doi, + # The published_version cannot have a properly defined assetsSummary yet, since that would + # require having created rows the Asset-to-Version join table, which is a side affect. + 'assetsSummary': { + 'schemaKey': 'AssetsSummary', + 'numberOfBytes': 0, + 'numberOfFiles': 0, + }, + } @pytest.mark.django_db() diff --git a/dandiapi/search/migrations/0001_initial.py b/dandiapi/search/migrations/0001_initial.py index 8bae5cb9d..34ef2fae5 100644 --- a/dandiapi/search/migrations/0001_initial.py +++ b/dandiapi/search/migrations/0001_initial.py @@ -27,12 +27,17 @@ CREATE UNIQUE INDEX idx_asset_search_dandiset_id_asset_id ON asset_search (dandiset_id, asset_id); -CREATE INDEX idx_asset_search_asset_size ON asset_search (asset_size); -CREATE INDEX idx_asset_search_measurement_technique ON asset_search USING gin ((asset_metadata->'measurementTechnique')); -CREATE INDEX asset_search_metadata_species_name_idx ON asset_search ((asset_metadata #> '{{wasAttributedTo,0,species,name}}')); -CREATE INDEX asset_search_metadata_genotype_name_idx ON asset_search ((asset_metadata #> '{{wasAttributedTo,0,genotype,name}}')); +CREATE INDEX idx_asset_search_asset_size + ON asset_search (asset_size); +CREATE INDEX idx_asset_search_measurement_technique + ON asset_search USING gin ((asset_metadata->'measurementTechnique')); +CREATE INDEX asset_search_metadata_species_name_idx + ON asset_search ((asset_metadata #> '{{wasAttributedTo,0,species,name}}')); +CREATE INDEX asset_search_metadata_genotype_name_idx + ON asset_search ((asset_metadata #> '{{wasAttributedTo,0,genotype,name}}')); -CREATE INDEX idx_asset_search_encoding_format ON asset_search USING gin (UPPER(asset_metadata->>'encodingFormat') gin_trgm_ops); +CREATE INDEX idx_asset_search_encoding_format + ON asset_search USING gin (UPPER(asset_metadata->>'encodingFormat') gin_trgm_ops); """ # noqa: S608 diff --git a/dandiapi/zarr/models.py b/dandiapi/zarr/models.py index 2f99891bc..d558e9b92 100644 --- a/dandiapi/zarr/models.py +++ b/dandiapi/zarr/models.py @@ -105,7 +105,10 @@ class ZarrArchive(BaseZarrArchive): def s3_path(self, zarr_path: str | Path): """Generate a full S3 object path from a path in this zarr_archive.""" - return f'{settings.DANDI_DANDISETS_BUCKET_PREFIX}{settings.DANDI_ZARR_PREFIX_NAME}/{self.zarr_id}/{zarr_path}' + return ( + f'{settings.DANDI_DANDISETS_BUCKET_PREFIX}{settings.DANDI_ZARR_PREFIX_NAME}/' + f'{self.zarr_id}/{zarr_path}' + ) class EmbargoedZarrArchive(BaseZarrArchive): @@ -116,4 +119,7 @@ class EmbargoedZarrArchive(BaseZarrArchive): def s3_path(self, zarr_path: str | Path): """Generate a full S3 object path from a path in this zarr_archive.""" - return f'{settings.DANDI_DANDISETS_EMBARGO_BUCKET_PREFIX}{settings.DANDI_ZARR_PREFIX_NAME}/{self.dandiset.identifier}/{self.zarr_id}/{zarr_path}' + return ( + f'{settings.DANDI_DANDISETS_EMBARGO_BUCKET_PREFIX}{settings.DANDI_ZARR_PREFIX_NAME}/' + f'{self.dandiset.identifier}/{self.zarr_id}/{zarr_path}' + )