Closed sbenthall closed 1 year ago
@sbenthall, this definitely seems worth doing. I think of this and the BufferStockTheory REMARK as the "marquee" illustrations of how to use HARK to make reproducible code, and if they can be substantially improved to make them better templates for other people, that would be worth doing.
It will be much easier to do this now that there is an automated test to make sure refactoring doesn't introduce errors!
First, let's work in #4 and update to 0.13.0 after the next HARK release.
OK, sounds good.
Linking to the current REMARK standard here for reference: https://github.com/econ-ark/REMARK/blob/master/STANDARD.md
So for scoping this refactor:
reproduce.sh
and reproduce_min.sh
are now favor over do_*./py
.do_all.py
looks like it's not intended to be ran, ever, and so can be removed.do_
files or defined at global scope in standalone files (in Options/
) needs to change. The standalone files can be consolidated into one file with different options
objects -- probably dicts. These can be passed through to the model code.cstwMPC_MAIN.py
, functionalize out a main()
method from the current __main__
execution mode code, as is standard. https://realpython.com/python-main-function/__main__
or... a Python import in the main method?The main problem is that current __main__
execution code, as well as the model code, depends on options being defined in global scope, which means the values aren't passed in anywhere but rather are being set through Python execution. And the execution code is contorted to make this work, at the expense of being extremely brittle.
The current code uses a somewhat convoluted method of setting global variables before running the
main()
method of the cstwMPC_main.py` script.It would be worth looking at this to try to encapsulate it a little more. It would, among other things, make error messages from within the main code more legible.