C-Star is a python package for setting up and running ocean model simulations, with a particular focus on marine carbon dioxide removal (mCDR) applications.
Currently, Case.from_blueprint constructs a Case by first constructing every Component, by first constructing every fundamental object. This leads to a lot of ugly logic for deciding what to do, like:
Instead, Component should have a from_dict method that is called from Case.from_blueprint, removing the need for most of this sort of code. Following #102 , Case can simply choose the Component subclass from component_type, then hand-off all future work to that Component subclass.
This also applies to Case.persist / Component.to_dict, though that example is mercifully less messy.
Currently,
Case.from_blueprint
constructs a Case by first constructing every Component, by first constructing every fundamental object. This leads to a lot of ugly logic for deciding what to do, like:https://github.com/CWorthy-ocean/C-Star/blob/bfac303efa5ff76f98f76c61f42245b6d4e00004/cstar/case.py#L437-L458
Instead,
Component
should have afrom_dict
method that is called fromCase.from_blueprint
, removing the need for most of this sort of code. Following #102 , Case can simply choose the Component subclass fromcomponent_type
, then hand-off all future work to that Component subclass.This also applies to
Case.persist
/Component.to_dict
, though that example is mercifully less messy.