Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some .debug level messages in tasks upon no action to be performed #2079

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dandiapi/api/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
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
Loading