Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some .debug level messages in tasks upon no action to be pe…
Browse files Browse the repository at this point in the history
…rformed

While troubleshooting
- dandi/dandi-cli#1488

I would like to know if any of those tasks was ran at all.  That is conditioned
on correct condition to happen first, so it is valuable to add explicit debug level
log entry if condition was not met
yarikoptic committed Nov 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 81677d4 commit f1ea6e3
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dandiapi/api/doi.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
(settings.DANDI_DOI_API_PREFIX, 'DANDI_DOI_API_PREFIX'),
]

logger = logging.getLogger(__name__)


def doi_configured() -> bool:
return any(setting is not None for setting, _ in DANDI_DOI_SETTINGS)
@@ -80,3 +82,5 @@ def delete_doi(doi: str) -> None:
except requests.exceptions.HTTPError:
logging.exception('Failed to delete DOI %s', doi)
raise
else:
logger.debug('Skipping DOI deletion for %s since not configured', doi)
2 changes: 2 additions & 0 deletions dandiapi/api/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -69,6 +69,8 @@ def validate_asset_metadata_task(asset_id: int) -> None:
asset: Asset = Asset.objects.filter(id=asset_id, status=Asset.Status.PENDING).first()
if asset:
validate_asset_metadata(asset=asset)
else:
logger.debug('Asset %s not found or already validated', asset_id)


@shared_task(soft_time_limit=30)
4 changes: 4 additions & 0 deletions dandiapi/api/tasks/scheduled.py
Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ def validate_pending_asset_metadata():
logger.info('Found %s assets to validate', validatable_assets_count)
for asset_id in throttled_iterator(validatable_assets.iterator()):
validate_asset_metadata_task.delay(asset_id)
else:
logger.debug('Found no assets to validate')


@shared_task(soft_time_limit=20)
@@ -101,6 +103,8 @@ def validate_draft_version_metadata():
# Revalidation should be triggered every time a version is modified,
# so now is a good time to write out the manifests as well.
write_manifest_files.delay(draft_version_id)
else:
logger.debug('Found no versions to validate')


@shared_task(soft_time_limit=20)

0 comments on commit f1ea6e3

Please sign in to comment.