MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

Adding metadata schema to the code base itself

Open ericspod opened this issue 1 year ago • 7 comments

Fixes #7303 #6959.

Description

This adds the schema file into the code base (but this maybe should be elsewhere). The changes implement a number of new things:

  • Moved definitions into a $defs section per the JSON schema standard
  • Permits multiple input arguments and return results from networks with arbitrary names using the patternProperties mechanism
  • Allows the types of inputs and outputs to be, additional to just tensors, numbers, booleans, or strings
  • Outputs after post processing can be specified with the post_processed_outputs section if they are significantly changed with the post-process transforms defined in scripts
  • Multiple network IO formats can be specified in addition to network_data_format, these must follow the pattern <name>_data_format
  • required_packages_version added in addition to optional_packages_version

#7253 depends on this schema change.

Types of changes

  • [x] Non-breaking change (fix or new feature that would not break existing functionality).
  • [ ] Breaking change (fix or new feature that would cause existing functionality to change).
  • [ ] New tests added to cover the changes.
  • [ ] Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • [ ] Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • [ ] In-line docstrings updated.
  • [ ] Documentation updated, tested make html command in the docs/ folder.

ericspod avatar Jan 22 '24 13:01 ericspod

Should this file exist here or put elsewhere? Currently the schema is stored in extra-test-data within a release, but it has to be somewhere accessible through a URL in the metadata.json files. #4048 references the issue of making this URL accessible.

ericspod avatar Jan 22 '24 13:01 ericspod

Should this file exist here or put elsewhere? Currently the schema is stored in extra-test-data within a release, but it has to be somewhere accessible through a URL in the metadata.json files. #4048 references the issue of making this URL accessible.

Yes, just make this draft PR to help review and leave comments. After finished we can move it in extra-test-data or somewhere else.

KumoLiu avatar Jan 22 '24 14:01 KumoLiu

Can we prepare a test case, like using 1) this schema and 2) prepare a fake metadata.json file to use verify_metadata in monai.bundle.scripts to verify that it works?

yiheng-wang-nv avatar Jan 24 '24 09:01 yiheng-wang-nv

Can we prepare a test case, like using 1) this schema and 2) prepare a fake metadata.json file to use verify_metadata in monai.bundle.scripts to verify that it works?

Yes I can put that together shortly.

ericspod avatar Jan 24 '24 15:01 ericspod

Can we prepare a test case, like using 1) this schema and 2) prepare a fake metadata.json file to use verify_metadata in monai.bundle.scripts to verify that it works?

@yiheng-wang-nv I've added a notebook demonstrating this now. We won't want to merge this into dev, it's just a demo as the schema file is.

ericspod avatar Feb 03 '24 00:02 ericspod

Outstanding discussion points:

  • Should required_packages_version and/or optional_packages_version be required at all? If required_packages_version is required then model zoo bundles will need updating.
  • Should we allow multiple network formats with added [NAME]_data_format blocks but require there to always be a network_data_format block? The diffusion models in the zoo will need fixing if so.

ericspod avatar Feb 24 '24 21:02 ericspod

I've made required_packages_version mandatory but not optional_packages_version. We'll keep the [NAME]_data_format content of the schema. I've added documentation about other details as well.

ericspod avatar Mar 25 '24 20:03 ericspod

Hi @ericspod @KumoLiu @Nic-Ma , I rechecked this draft PR's changes.

I agree to use required_packages_version and enable multiple network formats. After this PR is merged, we can start to update MONAI model zoo bundles to use this schema. Hi @ericspod , are there any other blockers for this PR? (we can remove the notebook before merge)

yiheng-wang-nv avatar Jul 23 '24 05:07 yiheng-wang-nv

@yiheng-wang-nv I don't have any blockers for this PR. The jupyter notebook and schema file should be removed and the schema file instead uploaded here where the other versions live.

ericspod avatar Jul 23 '24 15:07 ericspod

@yiheng-wang-nv I don't have any blockers for this PR. The jupyter notebook and schema file should be removed and the schema file instead uploaded here where the other versions live.

I see. Thanks for the response. Do you think we should add supported_apps into this schema directly? (sorry for mis-clicked the close button and reopen button)

yiheng-wang-nv avatar Jul 24 '24 07:07 yiheng-wang-nv

I agree we can directly add supported_apps to the schema and make it optional. In this PR, we'll only merge the rst file and add the new schema here. After that, we need to merge this PR: https://github.com/Project-MONAI/MONAI/pull/7253. Subsequently, we will update all bundles for consistency. So The first step is to add supported_apps and upload the new schema. What do you think?

KumoLiu avatar Jul 24 '24 09:07 KumoLiu

agree we can directly add supported_apps to the schema and make it optional. In this PR, we'll only merge the rst file and add the new schema here. After that, we need to merge this PR: #7253. Subsequently, we will update all bundles for consistency. So The first step is to add supported_apps and upload the new schema. What do you think?

I've added supported_apps to the schema, please check the wording of the description and documentation matches the intent.

ericspod avatar Jul 24 '24 14:07 ericspod

My comments are minor and please feel free to skip/close them as needed for merge. Thanks!

mingxin-zheng avatar Jul 25 '24 13:07 mingxin-zheng

I've addressed comments and remove the schema file now.

ericspod avatar Jul 25 '24 16:07 ericspod

The schema is now uploaded as meta_schema_20240725.json.

ericspod avatar Jul 25 '24 16:07 ericspod

/build

KumoLiu avatar Jul 25 '24 16:07 KumoLiu

Thanks @ericspod for the contribution. I will use the new schema in: https://github.com/Project-MONAI/model-zoo/pull/605

yiheng-wang-nv avatar Jul 26 '24 04:07 yiheng-wang-nv