Skip to content

Nested references within a schema do not get resolved #1977

@WilliamJamieson

Description

@WilliamJamieson

In this schema https://github.com/WilliamJamieson/rad/blob/237060e373b454e0f37696adbc7bee20fc73a1f0/latest/reference_files/wfi_img_photom.yaml#L1-L182 used in spacetelescope/rad#712 is not properly resolved with asdf.schema.load_schema(<uri>, resolve_references=True).

A portion of the output from this command is:

                                                          'F146': {   'allOf': [   {   '$ref': 'asdf://stsci.edu/datamodels/roman/schemas/reference_files/wfi_img_photom-1.3.0#/definitions/basic_phot_table_entry'},
                                                                                   {   'properties': {   'collecting_area': {   'type': 'number',
                                                                                                                                'unit': 'm^2'},
                                                                                                         'effective_area': {   'datatype': 'float32',
                                                                                                                               'exact_datatype': True,
                                                                                                                               'ndim': 1,
                                                                                                                               'tag': 'tag:stsci.edu:asdf/core/ndarray-1.*',
                                                                                                                               'unit': 'm^2'},
                                                                                                         'photmjsr': {   'type': 'number',
                                                                                                                         'unit': '(MJy/sr) '
                                                                                                                                 '/ '
                                                                                                                                 '(DN/s)'},
                                                                                                         'pixelareasr': {   'type': 'number',
                                                                                                                            'unit': 'sr'},
                                                                                                         'uncertainty': {   'type': 'number',
                                                                                                                            'unit': '(MJy/sr) '
                                                                                                                                    '/ '
                                                                                                                                    '(DN/s)'},
                                                                                                         'wavelength': {   'datatype': 'float32',
                                                                                                                           'exact_datatype': True,
                                                                                                                           'ndim': 1,
                                                                                                                           'tag': 'tag:stsci.edu:asdf/core/ndarray-1.*',
                                                                                                                           'unit': 'microns'}},

This is true for each of the entries in the main object. This appears to be the result of walk_and_modify not resolving the references in the output here

return reference.resolve_fragment(subschema, suburl_fragment)
, and since that section of the tree has been visited by walk_and_modify when that new section of the tree is inserted it never gets back to resolving the references in that block. This maybe a result of the order that walk_and_modify decides to walk the tree.

Modifying the linked line with:

return walk_and_modify(reference.resolve_fragment(subschema, suburl_fragment), resolve_refs)

Fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions