Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-591

Use schemas to define script configuration

    XMLWordPrintable

    Details

    • Type: RFC
    • Status: Implemented
    • Resolution: Done
    • Component/s: T&S
    • Labels:
      None

      Description

      The current ts_scriptqueue Script code validates configuration by parsing it as a dict and passing it as keyword arguments to the configure method. I wrote that before I knew about jsonschema. I propose overhauling this to use jsonschema as follows:

      • SAL scripts must override classmethod get_schema to return a jsonschema schema describing valid configuration.
      • BaseScript will validate configuration against that schema and, assuming it is OK, pass the resulting configuration as a types.SimpleNamespace instance (this is a standard Python class that offers struct-like attribute access to dicts) to the configure method.
      • BaseScripts's constructor will also validate the schema and raise an exception if the schema is invalid.

      A less invasive version of this proposal is to continue to pass the parsed and validated configuration as a keyword argument dict to the configure method. But I think SimpleNamespace is nicer, and this will make SAL scripts work the same way as configurable CSCs.

      If accepted I will convert all existing scripts on the develop branch of ts_standardscripts and ts_externalscripts. We don't have many yet, so this is a good time to make such a change.

        Attachments

          Issue Links

            Activity

            rowen Russell Owen created issue -
            rowen Russell Owen made changes -
            Field Original Value New Value
            Component/s DM [ 11604 ]
            Component/s LSST [ 12210 ]
            rowen Russell Owen made changes -
            Description The current ts_scriptqueue Script code validates configuration by parsing it as a dict and passing it as keyword arguments to the {{configure}} method. I wrote that before I knew about jsonschema. I propose overhauling this to use jsonschema as follows:

            * SAL scripts must override classmethod {{get_schema}} to return a jsonschema schema describing valid configuration.
            * {{BaseScript}} will validate configuration against that schema and, assuming it is OK, pass the resulting configuration as a {{types.SimpleNamespace}} instance (this is a standard Python class that offers struct-like attribute access to dicts that have valid attribute names as keys) to the {{configure}} method.
            * {{BaseScripts}}'s constructor will also validate the schema and raise an exception if the schema is invalid.

            A less invasive version of this proposal is to continue to pass the parsed and validated configuration as a keyword argument dict to the configure method. But I think SimpleNamespace is nicer, and this will make SAL scripts work the same way as configurable CSCs.

            If accepted I will convert all existing scripts on the develop branch of ts_standardscripts and ts_externalscripts. We don't have many yet, so this is a good time to make such a change.
            The current ts_scriptqueue Script code validates configuration by parsing it as a dict and passing it as keyword arguments to the {{configure}} method. I wrote that before I knew about jsonschema. I propose overhauling this to use jsonschema as follows:

            * SAL scripts must override classmethod {{get_schema}} to return a jsonschema schema describing valid configuration.
            * {{BaseScript}} will validate configuration against that schema and, assuming it is OK, pass the resulting configuration as a {{types.SimpleNamespace}} instance (this is a standard Python class that offers struct-like attribute access to dicts) to the {{configure}} method.
            * {{BaseScripts}}'s constructor will also validate the schema and raise an exception if the schema is invalid.

            A less invasive version of this proposal is to continue to pass the parsed and validated configuration as a keyword argument dict to the configure method. But I think SimpleNamespace is nicer, and this will make SAL scripts work the same way as configurable CSCs.

            If accepted I will convert all existing scripts on the develop branch of ts_standardscripts and ts_externalscripts. We don't have many yet, so this is a good time to make such a change.
            gcomoretto Gabriele Comoretto made changes -
            Remote Link This issue links to "Page (Confluence)" [ 20335 ]
            tjenness Tim Jenness made changes -
            Component/s T&S [ 17108 ]
            Component/s DM [ 11604 ]
            Hide
            rowen Russell Owen added a comment -

            Adopted as stated, including passing configuration to scripts as types.SimpleNamespace instances.

            Show
            rowen Russell Owen added a comment - Adopted as stated, including passing configuration to scripts as types.SimpleNamespace instances.
            rowen Russell Owen made changes -
            Status Proposed [ 10805 ] Adopted [ 10806 ]
            rowen Russell Owen made changes -
            Link This issue is triggering DM-19323 [ DM-19323 ]
            gcomoretto Gabriele Comoretto made changes -
            Remote Link This issue links to "Page (Confluence)" [ 20414 ]
            gcomoretto Gabriele Comoretto made changes -
            Remote Link This issue links to "Page (Confluence)" [ 20453 ]
            gcomoretto Gabriele Comoretto made changes -
            Remote Link This issue links to "Page (Confluence)" [ 20453 ]
            rowen Russell Owen made changes -
            Resolution Done [ 10000 ]
            Status Adopted [ 10806 ] Implemented [ 11105 ]
            Hide
            rowen Russell Owen added a comment -

            Implemented in DM-19323

            Show
            rowen Russell Owen added a comment - Implemented in DM-19323
            gcomoretto Gabriele Comoretto made changes -
            Remote Link This issue links to "Page (Confluence)" [ 20732 ]

              People

              Assignee:
              rowen Russell Owen
              Reporter:
              rowen Russell Owen
              Watchers:
              Russell Owen, Tiago Ribeiro
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Planned End: