Adding Bundle Schemas#100
Conversation
Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
WalkthroughThis PR introduces nine JSON Schema files defining validation contracts for MONAI model bundle metadata across different model types and evolution periods. Schemas range from foundational 2022 formats supporting general model metadata to specialized 2024 variants for generative models, LDM architectures, and platform integrations (HuggingFace, HoverNet). ChangesMONAI Bundle Metadata Schema Catalog
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@meta_schema_20220729.json`:
- Line 253: The "latent" property line uses a tab for indentation which is
inconsistent with the file's spaces; locate the "latent" key (the JSON property
"latent" shown in the diff) and replace the leading tab characters with the same
number of spaces used elsewhere in the file so indentation style matches the
rest of meta_schema_20220729.json.
- Line 168: Line 168 contains a tab character before the "latent" property which
is inconsistent with the file's spaces-based indentation; replace the tab with
the appropriate number of spaces to match the surrounding JSON nesting (use the
same 4-space multiples used elsewhere) so the "latent" key aligns with its
sibling properties and preserves consistent formatting.
In `@meta_schema_20240725.json`:
- Line 135: Fix the typo in the JSON description value for the metadata field
whose "description" currently reads "Version of NumPy the bundlewas generated
with." — update the string to "Version of NumPy the bundle was generated with."
so there is a space between "bundle" and "was" (edit the "description" property
in the same JSON object).
In `@meta_schema_hf_20250321.json`:
- Around line 3-17: The schema is missing a top-level "type" and "properties"
definition; update the JSON object that currently contains "required" to include
"type": "object" and a "properties" object that defines each required field
(e.g., "schema", "version", "changelog", "monai_version", "pytorch_version",
"numpy_version", "required_packages_version", "name", "task", "description",
"authors", "copyright", "huggingface_url") with appropriate simple types
(string/array/object as applicable) to match the other meta_schema files and
enforce field shapes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e5b59219-c720-4102-bece-4ea18906d79e
📒 Files selected for processing (8)
meta_schema_20220324.jsonmeta_schema_20220729.jsonmeta_schema_20240725.jsonmeta_schema_generator_20220718.jsonmeta_schema_generator_ldm_20230507.jsonmeta_schema_generator_ldm_20240318.jsonmeta_schema_hf_20250321.jsonmeta_schema_hovernet_20221124.json
| "value_range" | ||
| ] | ||
| }, | ||
| "latent": { |
There was a problem hiding this comment.
Fix inconsistent indentation (tabs vs spaces).
Line 168 uses tabs for indentation while the rest of the file uses spaces. This inconsistency can cause issues with code formatters, diff tools, and may lead to subtle problems in text processing pipelines.
🔧 Suggested fix
Replace the tab characters with spaces to match the indentation style used throughout the rest of the file (appears to be using multiples of 4 spaces based on nesting level).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@meta_schema_20220729.json` at line 168, Line 168 contains a tab character
before the "latent" property which is inconsistent with the file's spaces-based
indentation; replace the tab with the appropriate number of spaces to match the
surrounding JSON nesting (use the same 4-space multiples used elsewhere) so the
"latent" key aligns with its sibling properties and preserves consistent
formatting.
| "value_range" | ||
| ] | ||
| }, | ||
| "latent": { |
There was a problem hiding this comment.
Fix inconsistent indentation (tabs vs spaces).
Line 253 uses tabs for indentation while the rest of the file uses spaces, matching the issue at line 168.
🔧 Suggested fix
Replace the tab characters with spaces to match the indentation style used throughout the rest of the file.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@meta_schema_20220729.json` at line 253, The "latent" property line uses a tab
for indentation which is inconsistent with the file's spaces; locate the
"latent" key (the JSON property "latent" shown in the diff) and replace the
leading tab characters with the same number of spaces used elsewhere in the file
so indentation style matches the rest of meta_schema_20220729.json.
| "type": "string" | ||
| }, | ||
| "numpy_version": { | ||
| "description": "Version of NumPy the bundlewas generated with.", |
There was a problem hiding this comment.
Fix typo in description.
Missing space: "the bundlewas generated" should be "the bundle was generated".
✏️ Proposed fix
- "description": "Version of NumPy the bundlewas generated with.",
+ "description": "Version of NumPy the bundle was generated with.",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "description": "Version of NumPy the bundlewas generated with.", | |
| "description": "Version of NumPy the bundle was generated with.", |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@meta_schema_20240725.json` at line 135, Fix the typo in the JSON description
value for the metadata field whose "description" currently reads "Version of
NumPy the bundlewas generated with." — update the string to "Version of NumPy
the bundle was generated with." so there is a space between "bundle" and "was"
(edit the "description" property in the same JSON object).
| "required": [ | ||
| "schema", | ||
| "version", | ||
| "changelog", | ||
| "monai_version", | ||
| "pytorch_version", | ||
| "numpy_version", | ||
| "required_packages_version", | ||
| "name", | ||
| "task", | ||
| "description", | ||
| "authors", | ||
| "copyright", | ||
| "huggingface_url" | ||
| ] |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "meta_schema_hf_20250321.json" -type fRepository: Project-MONAI/project-monai.github.io
Length of output: 112
🏁 Script executed:
cat -n ./meta_schema_hf_20250321.jsonRepository: Project-MONAI/project-monai.github.io
Length of output: 591
🏁 Script executed:
rg "meta_schema_hf_20250321" --type json --type js --type py --type yaml --type md -A 3 -B 3Repository: Project-MONAI/project-monai.github.io
Length of output: 63
🏁 Script executed:
rg "meta_schema|huggingface_url" -A 2 -B 2 --type json --type md --type pyRepository: Project-MONAI/project-monai.github.io
Length of output: 680
🏁 Script executed:
cat -n scripts/process_models.py | head -100Repository: Project-MONAI/project-monai.github.io
Length of output: 4818
🏁 Script executed:
cat -n scripts/process_models.py | sed -n '100,150p'Repository: Project-MONAI/project-monai.github.io
Length of output: 1660
🏁 Script executed:
cat -n README.md | head -50Repository: Project-MONAI/project-monai.github.io
Length of output: 1751
🏁 Script executed:
rg "json-schema|jsonschema|validate.*schema" -i --type py --type js --type json -A 3 -B 3Repository: Project-MONAI/project-monai.github.io
Length of output: 2440
🏁 Script executed:
cat -n meta_schema_hovernet_20221124.json | head -30Repository: Project-MONAI/project-monai.github.io
Length of output: 1391
🏁 Script executed:
git ls-files | grep "meta_schema.*\.json" | wc -lRepository: Project-MONAI/project-monai.github.io
Length of output: 83
Add missing type and properties to match schema consistency across the codebase.
This file is the only meta_schema in the repository without type: object and properties definitions. All seven other schemas define these, constraining field shapes and enforcing metadata contracts. Add both to align with existing patterns and strengthen validation.
Proposed minimal hardening
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
+ "type": "object",
+ "properties": {
+ "schema": { "type": "string" },
+ "version": { "type": "string" },
+ "changelog": { "type": "object" },
+ "monai_version": { "type": "string" },
+ "pytorch_version": { "type": "string" },
+ "numpy_version": { "type": "string" },
+ "required_packages_version": { "type": "object" },
+ "name": { "type": "string" },
+ "task": { "type": "string" },
+ "description": { "type": "string" },
+ "authors": { "type": "string" },
+ "copyright": { "type": "string" },
+ "huggingface_url": { "type": "string", "format": "uri" }
+ },
"required": [📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "required": [ | |
| "schema", | |
| "version", | |
| "changelog", | |
| "monai_version", | |
| "pytorch_version", | |
| "numpy_version", | |
| "required_packages_version", | |
| "name", | |
| "task", | |
| "description", | |
| "authors", | |
| "copyright", | |
| "huggingface_url" | |
| ] | |
| { | |
| "$schema": "https://json-schema.org/draft/2019-09/schema", | |
| "type": "object", | |
| "properties": { | |
| "schema": { "type": "string" }, | |
| "version": { "type": "string" }, | |
| "changelog": { "type": "object" }, | |
| "monai_version": { "type": "string" }, | |
| "pytorch_version": { "type": "string" }, | |
| "numpy_version": { "type": "string" }, | |
| "required_packages_version": { "type": "object" }, | |
| "name": { "type": "string" }, | |
| "task": { "type": "string" }, | |
| "description": { "type": "string" }, | |
| "authors": { "type": "string" }, | |
| "copyright": { "type": "string" }, | |
| "huggingface_url": { "type": "string", "format": "uri" } | |
| }, | |
| "required": [ | |
| "schema", | |
| "version", | |
| "changelog", | |
| "monai_version", | |
| "pytorch_version", | |
| "numpy_version", | |
| "required_packages_version", | |
| "name", | |
| "task", | |
| "description", | |
| "authors", | |
| "copyright", | |
| "huggingface_url" | |
| ] | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@meta_schema_hf_20250321.json` around lines 3 - 17, The schema is missing a
top-level "type" and "properties" definition; update the JSON object that
currently contains "required" to include "type": "object" and a "properties"
object that defines each required field (e.g., "schema", "version", "changelog",
"monai_version", "pytorch_version", "numpy_version",
"required_packages_version", "name", "task", "description", "authors",
"copyright", "huggingface_url") with appropriate simple types
(string/array/object as applicable) to match the other meta_schema files and
enforce field shapes.
Fixes Project-MONAI/MONAI#4048
This copies the existing schemas stored here into the website itself so these can be accessed through a shorter and permanent URL. The expectation is that the "schema" URL in
metadata.jsonfiles can use a shorter URL, eg."schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json"becomes"schema": "https://project-monai.github.io/meta_schema_20240725.json".Summary by CodeRabbit