Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulHuwe authored Dec 16, 2024
2 parents f659a7f + 8d06d03 commit 321dfce
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 22 deletions.
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/fps/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/fps/exposure_type-1.0.0
allOf:
- $ref: asdf://stsci.edu/datamodels/roman/schemas/fps/exposure_type-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/fps/guidestar-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ properties:
datatype: nvarchar(20)
destination: [WFICommon.gw_id]
gw_fgs_mode:
$ref: guidewindow_modes-1.0.0
allOf:
- $ref: guidewindow_modes-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
6 changes: 4 additions & 2 deletions src/rad/resources/schemas/fps/wfi_mode-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ properties:
datatype: nvarchar(5)
destination: [WFICommon.instrument_name]
detector:
allOf:
- $ref: wfi_detector-1.0.0
title: WFI Detector
description: |
WFI detector used to take the data.
$ref: wfi_detector-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand All @@ -33,10 +34,11 @@ properties:
datatype: nvarchar(10)
destination: [WFICommon.detector]
optical_element:
allOf:
- $ref: wfi_optical_element-1.0.0
title: WFI Optical Element
description: |
WFI optical element used to take the data.
$ref: wfi_optical_element-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
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/tvac/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/tvac/exposure_type-1.0.0
allOf:
- $ref: asdf://stsci.edu/datamodels/roman/schemas/tvac/exposure_type-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
3 changes: 2 additions & 1 deletion src/rad/resources/schemas/tvac/guidestar-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ properties:
datatype: nvarchar(20)
destination: [WFICommon.gw_id]
gw_fgs_mode:
$ref: guidewindow_modes-1.0.0
allOf:
- $ref: guidewindow_modes-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand Down
6 changes: 4 additions & 2 deletions src/rad/resources/schemas/tvac/wfi_mode-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ properties:
datatype: nvarchar(5)
destination: [WFICommon.instrument_name]
detector:
allOf:
- $ref: wfi_detector-1.0.0
title: WFI Detector
description: |
WFI detector used to take the data.
$ref: wfi_detector-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
Expand All @@ -33,10 +34,11 @@ properties:
datatype: nvarchar(10)
destination: [WFICommon.detector]
optical_element:
allOf:
- $ref: wfi_optical_element-1.0.0
title: WFI Optical Element
description: |
WFI optical element used to take the data.
$ref: wfi_optical_element-1.0.0
sdf:
special_processing: VALUE_REQUIRED
source:
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
17 changes: 17 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,20 @@ 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)


@pytest.mark.parametrize("uri", SCHEMA_URIS)
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)

0 comments on commit 321dfce

Please sign in to comment.