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

Attach dandiset version to validation error log messages #9

Merged
merged 1 commit into from
Oct 2, 2024
Merged
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
14 changes: 10 additions & 4 deletions src/dandisets_linkml_status_tools/cli/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ def compile_validation_report(dandiset: RemoteDandiset) -> DandisetValidationRep
dandiset_linkml_validator = DandisetLinkmlValidator()

dandiset_id = dandiset.identifier
dandiset_version = dandiset.version_id

raw_metadata = dandiset.get_raw_metadata()

# === Fetch dandiset version info ===
dandiset_version_info = dandiset.get_version(dandiset.version_id)
dandiset_version_info = dandiset.get_version(dandiset_version)
# Get dandiset version status
dandiset_version_status = dandiset_version_info.status
# Get dandiset version modified datetime
Expand All @@ -132,19 +133,24 @@ def compile_validation_report(dandiset: RemoteDandiset) -> DandisetValidationRep
pydantic_validation_errs = pydantic_validate(raw_metadata)
if pydantic_validation_errs != "[]":
logger.info(
"Captured Pydantic validation errors for dandiset %s",
"Captured Pydantic validation errors for dandiset %s @ %s",
dandiset_id,
dandiset_version,
)

# Validate the raw metadata using the LinkML schema
linkml_validation_errs = dandiset_linkml_validator.validate(raw_metadata)
if linkml_validation_errs:
logger.info("Captured LinkML validation errors for dandiset %s", dandiset_id)
logger.info(
"Captured LinkML validation errors for dandiset %s @ %s",
dandiset_id,
dandiset_version,
)

# noinspection PyTypeChecker
return DandisetValidationReport(
dandiset_identifier=dandiset_id,
dandiset_version=dandiset.version_id,
dandiset_version=dandiset_version,
dandiset_version_status=dandiset_version_status,
dandiset_version_modified=dandiset_version_modified,
dandiset_metadata=raw_metadata,
Expand Down
Loading