Skip to content

Commit

Permalink
Manually fix line lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhelba authored and mvandenburgh committed Jan 22, 2024
1 parent 08a5ded commit c9392ec
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion dandiapi/api/models/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}

Expand Down
7 changes: 4 additions & 3 deletions dandiapi/api/services/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
298 changes: 143 additions & 155 deletions dandiapi/api/tests/test_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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': '[email protected]',
'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': '[email protected]',
'roleName': ['dcite:ContactPerson'],
'schemaKey': 'Person',
'affiliation': [],
'includeInCitation': True,
}
],
'assetsSummary': {
'schemaKey': 'AssetsSummary',
'numberOfBytes': 0,
'numberOfFiles': 0,
},
}


@pytest.mark.django_db()
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit c9392ec

Please sign in to comment.