bluesky / event-model

data model for event-based data collection and analysis
https://blueskyproject.io/event-model
BSD 3-Clause "New" or "Revised" License
13 stars 30 forks source link

235 add typing support to event model #247

Closed evalott100 closed 1 year ago

evalott100 commented 1 year ago

Closes #235

Adds TypedDicts and code to generate schemas from TypedDicts. It's necessary to merge #245 prior to this so black formatting doesn't cause problems.

evalott100 commented 1 year ago

@coretl Refactored and added comments, ready for another review!

evalott100 commented 1 year ago

Itemising the differences in the schema here

General changes

   "definitions": {
      "Calculation": {
         "title": "Calculation",
         "type": "object",
         "properties": {
            "args": {
               "title": "Args",
               "type": "array",
               "items": {}
            },

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/run_start.json#L228

         "properties": {
            "configuration": {
               "title": "Configuration",
               "description": "Static information about projection",
               "type": "object"
            },

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/datum_page.json#L18-L23

         "allOf": [
            {
               "$ref": "#/definitions/Dataframe"
            }
         ]
      },

datum_page.json changes

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/datum_page.json#L2

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/datum_page.json#L6-L11

      "datum_kwargs": {
         "title": "Datum Kwargs",
         "description": "Array of arguments to pass to the Handler to retrieve one quanta of data",
         "type": "object",
         "additionalProperties": {
            "anyOf": [
               {
                  "type": "boolean"
               },
               {
                  "type": "string"
               },
               {
                  "type": "number"
               },
               {
                  "type": "array",
                  "items": {}
               }
            ]
         }
      },

event.json changes

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/event.json#L19-L30

event_descriptor.json

and units

            "units": {
               "title": "Units",
               "description": "Engineering units of the value",
               "type": "string"
            }

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/event_descriptor.json#L84-L88

event_page.json changes

            "type": "array",
            "items": {
               "type": [
                  "boolean",
                  "string"
               ]

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/event_page.json#L20-L27

run_start.json changes

   "definitions": {
      "Calculation": {
         "title": "Calculation",
         "type": "object",
         "properties": {
            "args": {
               "title": "Args",
               "type": "array",
               "items": {}
            },

https://github.com/evalott100/event-model/blob/e91f648dc74c294a97ceac497f25cb6d6d193d87/event_model/schemas/run_start.json#L5-L6

run_stop.json changes