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
Field | Original Value | New Value |
---|---|---|
Component/s | DM [ 11604 ] | |
Component/s | LSST [ 12210 ] |
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. |
Remote Link | This issue links to "Page (Confluence)" [ 20335 ] |
Component/s | T&S [ 17108 ] | |
Component/s | DM [ 11604 ] |
Status | Proposed [ 10805 ] | Adopted [ 10806 ] |
Remote Link | This issue links to "Page (Confluence)" [ 20414 ] |
Remote Link | This issue links to "Page (Confluence)" [ 20453 ] |
Remote Link | This issue links to "Page (Confluence)" [ 20453 ] |
Resolution | Done [ 10000 ] | |
Status | Adopted [ 10806 ] | Implemented [ 11105 ] |
Remote Link | This issue links to "Page (Confluence)" [ 20732 ] |
Adopted as stated, including passing configuration to scripts as types.SimpleNamespace instances.