Skip to content

Commit

Permalink
fix: ref DataCiteRegistrationLog.http_status
Browse files Browse the repository at this point in the history
add daily backup hook to sync DOI metadata
  • Loading branch information
alee committed Dec 5, 2024
1 parent 9d96cfc commit 28f9116
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def mint_parent_codebases(interactive=True, dry_run=True):
"Unable to mint DOI for parent codebase %s of release %s: %s",
codebase.pk,
release.pk,
log.status_code,
log.http_status,
)
if interactive:
input("Press Enter to continue or CTRL+C to quit...")
Expand Down Expand Up @@ -116,7 +116,7 @@ def mint_parent_codebases(interactive=True, dry_run=True):
logger.error(
"Could not mint DOI for release %s - status code: %s.",
release.pk,
log.status_code,
log.http_status,
)
if interactive:
input("Press Enter to continue or CTRL+C to quit...")
Expand Down Expand Up @@ -148,7 +148,7 @@ def mint_parent_codebases(interactive=True, dry_run=True):
logger.error(
"Could not mint DOI for release %s - status code: %s.",
release.pk,
log.status_code,
log.http_status,
)
if interactive:
input("Press Enter to continue or CTRL+C to quit...")
Expand Down
2 changes: 1 addition & 1 deletion django/curator/management/commands/doi_reset_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def cleanup_existing_dois(interactive=True, dry_run=True):
["CodebaseRelease ID", "Status Code", "Reason", "Datacite Metadata"]
)
writer.writerow(
[release.pk, log.status_code, log.message, release.datacite.to_dict()]
[release.pk, log.http_status, log.message, release.datacite.to_dict()]
)


Expand Down
2 changes: 1 addition & 1 deletion django/curator/management/commands/doi_reset_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def reset_all_dois(interactive=True, dry_run=True):
["CodebaseRelease ID", "Status Code", "Reason", "Datacite Metadata"]
)
writer.writerow(
[release.pk, log.status_code, log.message, release.datacite.to_dict()]
[release.pk, log.http_status, log.message, release.datacite.to_dict()]
)


Expand Down
4 changes: 2 additions & 2 deletions django/curator/management/commands/doi_sync_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def sync_all_doi_metadata(interactive=True, dry_run=True):
writer = csv.writer(f)
writer.writerow(["Codebase ID", "HTTP Status Code", "Message"])
for codebase, log in invalid_codebases:
writer.writerow([codebase.pk, log.status_code, log.message])
writer.writerow([codebase.pk, log.http_status, log.message])
if invalid_releases:
with open("doi_sync_metadata_invalid_releases.csv", "w") as f:
writer = csv.writer(f)
writer.writerow(["CodebaseRelease ID", "HTTP Status Code", "Message"])
for release, log in invalid_releases:
writer.writerow([release.pk, log.status_code, log.message])
writer.writerow([release.pk, log.http_status, log.message])
logger.info("Metadata updated for all existing Codebase + CodebaseRelease DOIs.")
"""
FIXME: verify_metadata currently does not work with metadata responses from DataCite
Expand Down
11 changes: 11 additions & 0 deletions django/deploy/cron.daily/backup
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/sh
#
# Run backups over the model library filesystem and db

export DJANGO_SETTINGS_MODULE="core.settings.production"
/usr/local/bin/inv -r /code db.backup borg.backup >> /shared/logs/comses-backup.log 2>&1

# FIXME: should we synchronize DOI metadata after backups or before backups?
# Pros of after backups: DOI metadata syncing alters the DB and taking a snapshot backup before running this may protect against
# errors or bugs that happened as a result of the sync
#
# Pros of before backups: backups will be more up-to-date
#
# currently syncing after backups
./manage.py doi_sync_metadata --no-interactive --no-dry-run
4 changes: 2 additions & 2 deletions django/library/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def mint_pending_dois(self):
invalid_releases.append(
(
release,
log.status_code,
log.http_status,
f"Unable to update previous release id {previous_release.pk} metadata {log.message}",
)
)
Expand All @@ -612,7 +612,7 @@ def mint_pending_dois(self):
invalid_releases.append(
(
release,
log.status_code,
log.http_status,
f"Unable to update next release id {next_release.pk} metadata {log.message}",
)
)
Expand Down
4 changes: 2 additions & 2 deletions django/library/tests/test_datacite_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_update_metadata_for_codebase(self):
def test_mint_new_doi_for_release(self):
self.assertTrue(self.api.is_datacite_available())
release = self.codebase.releases.first()
doi, status_code = self.api.mint_public_doi(release)
self.assertEquals(status_code, 200, "should have successfully minted a DOI")
log, ok = self.api.mint_public_doi(release)
self.assertEquals(log.http_status, 200, "should have successfully minted a DOI")
self.assertTrue(self.api.doi_matches_pattern(doi))
def test_update_metadata_for_release(self):
Expand Down

0 comments on commit 28f9116

Please sign in to comment.