Skip to content

Create a scheme for requiring one of multiple options  #7

Open

Description

@maxineofficial

Overview

Some ISTP variables, such as LABLAXIS and LABL_PTR_1, are required only if another variable is not present. We need some way of representing these variable types in the schema, and to update the code to properly handle them.

Features

  • Schema can represent multiple variables, where one of n is required
  • Code prints a warning or indicates in some way if the required variable is missing
  • CDFAttributeManager will successfully include only one of the required variables if only one is present.

Activity

  1. Alrobbertz commented on Sep 4, 2024

    @Alrobbertz
    Member

    I did some thinking on this a while ago - I'll include my notes here....

    The different types of conditional requirements fall into one of the following categories:

    • Attribute Value (attribute_value): The presence of an attribute is required based on the value of another required attribute.
      • The attribute used for the condition_key must be a required attribute.
    • Variable Name (variable_name): The presence of an attribute is required based on the name of the variable.
      • The condition_key is used as a REGEX here to match any variable names that match the given pattern.
    • Attribute Present (attribute_present): The presence of an attribute is required based on the presence of other, required or optional, attributes.
      • The condition_key can be a list of attribute names. If any of the attributes in the condition_key are present, then the required_attributes must also be present.

    <file_type>_variable_attribute_schema.yaml

    attribute_key:
      CATDESC:
        description: >
          This is a human readable description of the data variable.
        derived: false
        required: true
        overwrite: false
        valid_values: null
        alternate: null
      ...
      WCSAXES:
        description: > 
          number of axes in the associated data array.
        human_readable: WCS axes
        derived: false
        derivation_fn: _get_wcs_naxis
        required: false
        overwrite: false
        valid_values: null
        alternate: null
      ...
    conditional_requirements:
    # =======================================
    # CDF Conditions for Metadata Attributes
    # =======================================
      - condition_type: 'attribute_value'
        condition_key: 'VAR_TYPE'
        condition_value: 'data'
        required_attributes:
          - CATDESC
          - DEPEND_0
          - DISPLAY_TYPE
          - FIELDNAM
          - FILLVAL
          - FORMAT
          - LABLAXIS
          - SI_CONVERSION
          - UNITS
          - VALIDMIN
          - VALIDMAX
          - VAR_TYPE
      - condition_type: 'attribute_value'
        condition_key: 'VAR_TYPE'
        condition_value: 'support_data'
        required_attributes:
          - CATDESC
          - FIELDNAM
          - FILLVAL
          - FORMAT
          - LABLAXIS
          - SI_CONVERSION
          - UNITS
          - VALIDMIN
          - VALIDMAX
          - VAR_TYPE
      - condition_type: 'attribute_value'
        condition_key: 'VAR_TYPE'
        condition_value: 'metadata'
        required_attributes:
          - CATDESC
          - FIELDNAM
          - FILLVAL
          - FORMAT
          - VAR_TYPE
      - condition_type: 'variable_name'
        condition_key: 'EPOCH*' # Variable Attribute Names in Conditions? 
        condition_value: null
        required_attributes:
          - REFERENCE_POSITION
          - RESOLUTION
          - TIME_BASE
          - TIME_SCALE
      - condition_type: 'attribute_present'
        condition_key: 
          - WCSAXES
          - CNAME0
        condition_value: null
        required_attributes:
          - MJDREF
          - TIMEUNIT
          - TIMEDEL
          - CNAMEi # Iterable
          - CTYPEi # Iterable
          - CUNITi # Iterable
          - CRPIXi # Iterable
          - CRVALi # Iterable
          - CDELTi # Iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions