Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rework of
DataRequest
This introduces new
DataRequest
,DataRequestVariable
, andDataRequestTable
classes. The old ones are copies directly from Ruby and are not very nice to work with.Here, we implement a generic abstract base class (
ABC
) forDataRequestVariable
. This allows us to define how aDataRequestVariable
should look like from thepymorize
Python side, without caring about how the information is ultimately extracted from the JSON tables.CMIP6DataRequestVariable
is the first direct implementation used for JSON tables. This has the key feature of allowing us to be flexible when new CMIP standards inevitably come out, for example with CMIP7.A
DataRequestVariable
therefore must implement certain properties and methods to be correctly recognised, otherwise you get PythonTypeError
s when subclassing.TODO List
DataRequestVariable
(and concreteCMIP6DataRequestVariable
)DataRequestTable
(and concreteCMIP6DataRequestTable
, specificallyCMIP6JSONDataRequestTable
-- yes, I want to build two subclass levels here, since it might happen in the future that the source of theDataRequestTable
isn't a JSON file. Maybe it's a HTTP request. Maybe it's a post-it note on the coffee machine. I don't know)DataRequest
(maybe namedDataRequestCollection
?) -- some gathering of variousVariable
s and/orTable
s into a bundle.Still to come
FlatTable
design (those parts that fit together with this)Copilot Summary
This pull request introduces a new abstract base class
DataRequestVariable
and its concrete implementationCMIP6DataRequestVariable
in thesrc/pymorize/data_request/variable.py
file. Additionally, it includes a unit test for theCMIP6DataRequestVariable
class intests/unit/test_drv.py
.Key changes include:
New Class Definitions:
src/pymorize/data_request/variable.py
:DataRequestVariable
abstract base class with various properties and methods to define a generic data request variable.CMIP6DataRequestVariable
class as a concrete implementation ofDataRequestVariable
for CMIP6 variables, utilizing thedataclass
decorator for automatic method generation.Unit Testing:
tests/unit/test_drv.py
:CMIP6DataRequestVariable
instance from a CMIP6 JSON table file.