Repository navigation
feat(metadata): add source identifier dataset metadata item - #250
Merged
Merged
Conversation
CivicDataLab's scrapers fill "Source identifier" on every dataset they upload (dataspace-scrapers/<scraper_id>/<dataset_key>) and read it back to recognise their own datasets, so a dataset is never created twice and their upload records can be rebuilt from DataSpace. The data migration creates the item, or switches it back on if an admin switched it off; reversing it deletes nothing. Tests: tests/test_source_identifier_migration.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anantjain341
approved these changes
Oct 22, 2026
Contributor
|
@psaesha merged and deployed to dev. The Source identifier field is live and enabled, so the scrapers can use it now. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds the Source identifier dataset metadata item. CivicDataLab's scrapers fill it in automatically, naming the scraper and dataset that produced it, e.g.
dataspace-scrapers/udise-plus/enrolment. The scrapers read it back to recognise datasets they've already uploaded. That way a dataset is never created twice, and the scrapers' upload records can be rebuilt from DataSpace if they're lost. People never need to fill it in. Editing or clearing it can make a scraper create a duplicate.The item also gets filled by platform import with no extra code: the import already fills any dataset item it recognises as a source identifier, so new imports from Kaggle, Hugging Face and GitHub will store the platform's own ID here (e.g.
owner/dataset-slug). Only values starting withdataspace-scrapers/belong to a scraper.Type of Change
Changes Made
api/migrations/0054_add_source_identifier_metadata.py: a data migration that creates the item (dataset, text, optional, switched on) if it is missing, and switches it back on if an admin switched it off. Reversing it deletes nothing, since datasets may already carry values for it.tests/test_source_identifier_migration.py: covers the item being missing, being switched off, the migration running twice, and an item with the same label on resources being left alone.Testing
pytest tests/test_source_identifier_migration.py, 4 passed)Test Instructions
python manage.py migrateChecklist
black .,isort ., andflake8and fixed any issues (flake8 at the repo's 100-character line length)Additional Notes
Source identifier. The scrapers look the item up by that label, on datasets, switched on, and expect only one.dev. Thes3_migrationbranch also has a0054_file_field_storages.py; whichever merges second needs renumbering or a merge migration.BaseMetadata._validate_data_typecompares withisinstead of==, so it never fires and REQUIRED items like Source Website aren't enforced.🤖 Generated with Claude Code