Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move refs under allOfs where required #525

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/525.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move schema references under allOf combiners if the schema contains other items.
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/exposure-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ title: |
type: object
properties:
type:
$ref: asdf://stsci.edu/datamodels/roman/schemas/exposure_type-1.0.0
allOf:
- $ref: asdf://stsci.edu/datamodels/roman/schemas/exposure_type-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/guidestar-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ properties:
datatype: nvarchar(20)
destination: [WFIExposure.guide_window_id, GuideWindow.guide_window_id, WFICommon.guide_window_id]
guide_mode:
$ref: guidewindow_modes-1.0.0
allOf:
- $ref: guidewindow_modes-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/guidewindow-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ properties:
datatype: nvarchar(120)
destination: [GuideWindow.gw_science_file_source]
gw_mode:
$ref: guidewindow_modes-1.0.0
allOf:
- $ref: guidewindow_modes-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/mosaic_basic-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ properties:
datatype: nvarchar(15)
destination: [WFIMosaic.survey, SourceCatalog.survey, SegmentationMap.survey]
optical_element:
$ref: wfi_optical_element-1.0.0
allOf:
- $ref: wfi_optical_element-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ properties:
type: string
enum: [WFI]
detector:
allOf:
- $ref: ../wfi_detector-1.0.0
title: Detector
description: |
The numbered WFI detector in the focal plane (e.g., WFI01 for SCA 01).
$ref: ../wfi_detector-1.0.0
required: [name, detector]
required: [reftype, author, description, pedigree, useafter, telescope, origin, instrument]
...
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ properties:
type: object
properties:
type:
allOf:
- $ref: ../exposure_type-1.0.0
title: WFI Mode
description: |
The type of data taken with the WFI. Allowed values are WFI_IMAGE for
imaging mode, WFI_GRISM and WFI_PRISM for spectral mode, WFI_DARK for
dark exposures, WFI_FLAT for flat fields, and WFI_WFSC.
$ref: ../exposure_type-1.0.0
p_exptype:
title: WFI Mode for CRDS
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ properties:
type: object
properties:
optical_element:
title: Optical Element
description: |
The optical element filter name.
$ref: ../wfi_optical_element-1.0.0
required: [optical_element]
required: [instrument]
Expand Down
3 changes: 0 additions & 3 deletions src/rad/resources/schemas/segmentation_map-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ properties:
- type: object
properties:
optical_element:
title: WFI Optical Element
description: |
WFI optical element used to take the data.
$ref: wfi_optical_element-1.0.0
program:
title: Program Information
Expand Down
6 changes: 4 additions & 2 deletions src/rad/resources/schemas/wfi_mode-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ properties:
datatype: nvarchar(5)
destination: [WFIExposure.instrument_name, GuideWindow.instrument_name, WFICommon.instrument_name]
detector:
allOf:
- $ref: wfi_detector-1.0.0
title: Wide Field Instrument (WFI) Detector Identifier
description: |
Name of the Wide Field Instrument (WFI) detector used
to take the science data in this file.
$ref: wfi_detector-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand All @@ -37,11 +38,12 @@ properties:
datatype: nvarchar(10)
destination: [WFIExposure.detector, GuideWindow.detector, WFICommon.detector]
optical_element:
allOf:
- $ref: wfi_optical_element-1.0.0
title: Wide Field Instrument (WFI) Optical Element
description: |
Name of the optical element used to take the science
data.
$ref: wfi_optical_element-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
26 changes: 26 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,29 @@ def callback(node, nvarchars=None):
assert node["maxLength"] == v, f"archive_catalog nvarchar does not match maxLength in schema {uri}"

asdf.treeutil.walk(schema, callback)


# don't test tvac or fps schemas as they are static
braingram marked this conversation as resolved.
Show resolved Hide resolved
@pytest.mark.parametrize(
"uri",
[
uri
for uri in SCHEMA_URIS
if not uri.startswith("asdf://stsci.edu/datamodels/roman/schemas/fps/")
and not uri.startswith("asdf://stsci.edu/datamodels/roman/schemas/tvac/")
],
)
def test_ref_loneliness(uri):
"""
An object with a $ref should contain no other items
"""
schema = asdf.schema.load_schema(uri)

def callback(node):
if not isinstance(node, dict):
return
if "$ref" not in node:
return
assert len(node) == 1

asdf.treeutil.walk(schema, callback)
Loading