Proposal: use pydantic datastructure to document and validate analysis quantities of interest
Description
All analyses classes have an attribute .quantities_of_interest
(see e.g., BaseAnalysis.save_quantities_of_interest ).
This object is a dictionary containing quantities of interested determined by the analysis.
There are currently a few problems with this implementation.
- The contents of quantities of interest are not documented.
- It is possible to determine in advance (before running an analysis) which quantities will be determined by the analysis.
- Because it is not specified, the interface cannot be relied on to be stable.
- We rely on a manual JSON serialization protocol to serialize the contents of the dictionary.
I propose to adopt the Pydantic DataStructure that is currently being used in quantify scheduler to document/represent the quantities of interest.
Motivation
This would allow us to
- Specify a stable interface for the quantities of interest.
- Provide an easy to access specification of the quantities that will be determined in an analysis.
- Rely on the built-in JSON serialization of the DataStructure class.
- Rely on a tool that is already commonly used in the quantify framework
- Add validation to Analysis to detect when we are (accidentally) breaking an interface.
Path towards implementation
We should define a base class for quantities of interest (subclass of DataStructure) that is part of the base analysis, and provide a few subclasses for the individual analyses that already exist.
This would be a breaking change, but an objective improvement in my opinion.