This repository provides tools for creating and managing external resource annotations for DANDI datasets, including a Flask web application with a user-friendly interface.
dandi-annotations/
├── pyproject.toml # Modern Python project configuration
├── environment.yml # Conda environment specification
└── src/ # Source code directory
└── dandiannotations/ # Main package
├── __init__.py # Package initialization
├── models/ # Pydantic models
│ └── models.py # ExternalResource and AnnotationContributor models
├── scripts/ # Command-line scripts
│ ├── create_resource_from_code.py
│ └── create_resource_from_yaml.py
├── external_resources/ # YAML data storage
│ └── external_resources.yaml
└── webapp/ # Flask web application
├── __init__.py # Webapp package initialization
├── app.py # Main Flask application
├── templates/ # HTML templates
├── static/ # CSS, JavaScript, assets
└── utils/ # Utility modules
├── schema_utils.py
└── yaml_handler.py
Option A: Update existing environment
conda activate dandi_annotations_env
pip install -e .
Option B: Create new environment from file
conda env create -f environment.yml
conda activate dandi_annotations_env
cd src/dandiannotations/webapp
python app.py
Open your web browser and navigate to: http://127.0.0.1:5000
- Submission-Focused Interface: Clean, streamlined form for submitting external resource annotations
- Professional UI: Responsive Bootstrap 5 styling with DANDI design principles
- Review Workflow Integration: Submissions are saved for review via pull request process
- Pydantic Integration: Uses existing
ExternalResource
andAnnotationContributor
models - YAML Storage: Saves data in the same format as
external_resources.yaml
- Automatic Backups: Creates timestamped backups before modifications
- Comprehensive Validation: Client-side and server-side validation with helpful error messages
- Auto-save: Preserves form data in browser localStorage
The webapp includes a streamlined submission form with the following fields:
- Identifier: Optional identifier for the resource
- Title: Name/title of the resource (required)
- URL: Web address of the resource (required)
- Repository: Name of the hosting repository (required)
- Resource Relation: Relationship to the dataset (dropdown, required)
- Resource Type: Type of resource (dropdown, required)
- Name: Contributor's full name (required)
- Email: Contributor's email address (required)
- ORCID: Optional ORCID identifier (auto-formatted)
- URL: Optional contributor website
- Form Submission: User fills out and submits the form for review
- Validation: Data is validated using Pydantic models
- Backup: Current YAML file is backed up with timestamp
- Storage: New resource is appended to
external_resources.yaml
- Review Process: Submission goes through pull request review before official integration
- Confirmation: Success page confirms submission and explains review process
- Email Format: Validates proper email structure
- URL Format: Ensures valid HTTP/HTTPS URLs
- ORCID Format: Validates ORCID identifier format
- Required Fields: Enforces required field completion
- Pydantic Integration: Uses existing models for comprehensive validation
The project uses modern Python development practices:
- pyproject.toml: Modern dependency management and project configuration
- Conda Integration: Works with existing
dandi_annotations_env
environment - Code Quality Tools: Pre-configured black, isort, mypy, and pytest
- Type Hints: Full type annotation support
- Update the form template (
src/dandiannotations/webapp/templates/form.html
) - Add validation in
src/dandiannotations/webapp/app.py
- Update the Pydantic models if needed
- Add any new schema options to
src/dandiannotations/webapp/utils/schema_utils.py
Edit src/dandiannotations/webapp/static/css/style.css
to modify the appearance. The design uses Bootstrap 5 with custom overrides.
This webapp seamlessly integrates with your existing DANDI annotation workflow:
- Model Compatibility: Uses existing
ExternalResource
andAnnotationContributor
models - YAML Format: Outputs data compatible with existing
external_resources.yaml
- Safe Operations: Creates automatic backups before file modifications
- Schema Compliance: Ensures all data meets DANDI schema requirements
- Import Errors: Ensure the virtual environment is activated
- YAML File Not Found: The app will create the file on first use
- Validation Errors: Check that your Pydantic models are compatible
- Port Already in Use: Change the port in
src/dandiannotations/webapp/app.py
or stop other Flask apps
The app runs in debug mode by default for development. To disable:
app.run(debug=False, host='127.0.0.1', port=5000)
- Change the secret key in
src/dandiannotations/webapp/app.py
for production use - Consider adding authentication for production deployment
- Validate all user inputs (already implemented)
- Use HTTPS in production environments
The repository also includes command-line tools for working with external resources:
src/dandiannotations/scripts/create_resource_from_code.py
: Create resources programmaticallysrc/dandiannotations/scripts/create_resource_from_yaml.py
: Create resources from YAML files
# Create a resource programmatically
python src/dandiannotations/scripts/create_resource_from_code.py
# Create resources from YAML file
python src/dandiannotations/scripts/create_resource_from_yaml.py
See LICENSE file for details.