Skip to content

Commit

Permalink
Merge pull request #2079 from dandi/enh-logging-msgs
Browse files Browse the repository at this point in the history
Add some .debug level messages in tasks upon no action to be performed
  • Loading branch information
waxlamp authored Dec 13, 2024
2 parents b0fa9e0 + dddec4c commit 7dd2cd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dandiapi/api/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ def delete_doi(doi: str) -> None:
except requests.exceptions.HTTPError:
logger.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
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions dandiapi/api/tasks/scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -125,6 +129,11 @@ def refresh_materialized_view_search() -> None:

def register_scheduled_tasks(sender: Celery, **kwargs):
"""Register tasks with a celery beat schedule."""
logger.info(
'Registering scheduled tasks for %s. ' 'DANDI_VALIDATION_JOB_INTERVAL is %s seconds.',
sender,
settings.DANDI_VALIDATION_JOB_INTERVAL,
)
# Check for any draft versions that need validation every minute
sender.add_periodic_task(
timedelta(seconds=settings.DANDI_VALIDATION_JOB_INTERVAL),
Expand Down

0 comments on commit 7dd2cd4

Please sign in to comment.