AllenNeuralDynamics / aind-metadata-entry-js

Metadata entry using javascript
https://metadata-entry.allenneuraldynamics.org
MIT License
1 stars 1 forks source link

Camera assemblies and stick microscopes cannot be added to Rig form #160

Closed helen-m-lin closed 5 months ago

helen-m-lin commented 5 months ago

Describe the bug When I try to add a Camera assembly or Stick microscope to the Rig form, nothing happens. This is observed for Rig versions >0.2.10. The older versions work though it takes a few seconds to load.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://metadata-entry.allenneuraldynamics.org/
  2. Select 'Rig' from the Schema dropdown.
  3. [Optional] Select any version later than 0.2.10
  4. Scroll down to 'Camera assemblies' or 'Stick microscopes' and click the + button to try to add it.
  5. Observe that Camera assemblies and stick microscopes cannot be added. Note that for rig versions <=0.2.10, it works.

Expected behavior Users should be able to add Camera assembly or stick microscope.

Desktop (please complete the following information):

helen-m-lin commented 5 months ago

The JSON Schema for CameraAssembly uses allOf: https://github.com/AllenNeuralDynamics/aind-data-schema/blob/29ced29a1be6229097bf1385a7b39ffb1dcf585e/schemas/rig_schema.json#L1021C13-L1036C15

Rather than:

"camera": {
    "$ref": "#/$defs/Camera"
},
"lens": {
    "$ref": "#/$defs/Lens"
 },

This may be due to how defaults are being set in pydantic/when the json schema is created. As a result, null consts from allOf are not set correctly when the form is rendered using rjsf.

Fix in #161 is a workaround to be able to render allOf defaults by adding null consts as nullable strings.