-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restructure CHILLED code to be more trackable and customizable #18
Conversation
Co-authored-by: Fridolin Glatter <[email protected]>
* Address linting issues
Quickly jumped in here to understand what's going on with the docs: overall, you were moving in the right direction.
With just these two changes, the docs now built successfully for me, including the code reference part. To replicate (in your venv on a command line of your choice):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now looks good from my side.
Code could still be cleaned up (e.g. by adding mypy and ruff like we have them in message_ix and addressing linting/formatting errors or by cleaning up comments and type: ignore
statements), but this could also happen in a later PR. If saved for later, please open an issue to not forget about this.
Now for @amastrucci, @byersiiasa, or probably @Zh-xy: please review and approve the content-side of the changes :)
Thanks @glatterf42 for your review and edits! A follow-up:
Using the absolute paths is giving me an issue now when trying to run the python scripts from the command line/terminal. For example, with using absolute paths, I am now receiving the error:
Within
I figure I needed to move the relative path to the directory before the
Do you have any suggestions on how to proceed? The only import line that seems to work in order to run the script in command line is Thanks! |
Huh, that sounds odd. My first thought was that this might be dependent on where you are when you execute the scripts, but this would rather be an issue with relative imports than with the absolute paths we have now. fridolin@fridolin-Latitude-5520 ~> (buildings) cd message-ix-buildings/
fridolin@fridolin-Latitude-5520 ~/message-ix-buildings (chilled/restruct)> (buildings) python
Python 3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from message_ix_buildings.chilled.util.config import Config
>>>
fridolin@fridolin-Latitude-5520 ~/message-ix-buildings (chilled/restruct)> (buildings) cd message_ix_buildings
fridolin@fridolin-Latitude-5520 ~/m/message_ix_buildings (chilled/restruct)> (buildings) python
Python 3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from message_ix_buildings.chilled.util.config import Config
>>>
fridolin@fridolin-Latitude-5520 ~/m/message_ix_buildings (chilled/restruct)> (buildings) cd chilled
fridolin@fridolin-Latitude-5520 ~/m/m/chilled (chilled/restruct)> (buildings) python
Python 3.12.4 (main, Jun 8 2024, 18:29:57) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from message_ix_buildings.chilled.util.config import Config
>>>
fridolin@fridolin-Latitude-5520 ~/m/m/chilled (chilled/restruct)> (buildings) python preprocess/message_raster.py
fridolin@fridolin-Latitude-5520 ~/m/m/chilled (chilled/restruct)> (buildings) git status
On branch chilled/restruct
Your branch is up to date with 'origin/chilled/restruct'.
nothing to commit, working tree clean
fridolin@fridolin-Latitude-5520 ~/m/m/chilled (chilled/restruct)> (buildings) cd ../..
fridolin@fridolin-Latitude-5520 ~/message-ix-buildings (chilled/restruct)> (buildings) python message_ix_buildings/chilled/preprocess/message_raster.py
fridolin@fridolin-Latitude-5520 ~/message-ix-buildings (chilled/restruct)> (buildings) In other words: wherever I am on my system, I can import from message_ix_buildings as from any other package and I can execute So just to clarify: you pulled the latest changes from here (especially including new |
Hi all, thanks for this, looks very good. |
Thanks Ed! If it's alright, my preference at the moment would be to get this PR merged and then add the documentation in another PR (so that this one does not get too large). 🙂 I have created an issue for the documentation: #21 If all else looks good, could you submit an approval? Otherwise, feel free to note other changes you would like made! |
As a note, I just created an issue for this: #22 |
Its only for Fridolin to approve ;) |
@glatterf42 If it's okay could I go ahead and merge? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost, yeah, that's why I approved this PR before :)
Since you asked for a new review, I've looked again at the files your recent commits changed and found some hints and questions that I hope are useful. I trust you will handle them well, so I will approve this PR again and once you're satisfied with your actions responding to the new comments, please feel free to merge :)
Reorganize CHILLED code to be more package-friendly
Main changes are:
Changes to inputs and parameters
utils.config
) that has the default parameters that should be consistently used in the model, but now we can easily change each parameter via the Config object instead of looking for it in places across different scripts.data/chilled/version
with the following filesChanges to usage
Instead of modifying scripts that has parameters set in the script, now the parameters can be set via the Config object and modified via arguments. Currently, using the run scripts, these are the arguments that be given from the command line:
Preprocessing of rasters can be done first without considering GCM and RCP. This can be accomplished by running the script (in
/chilled/
):The part of the model that collects and processes the climate data to derive energy intensities can be run using:
Note that the code is now also easily runnable on the UniCC server, which is nice for setting off multiple GCM-RCP runs at once.
How to review
For @amastrucci or @byersiiasa: please let me know if the code does not make sense now or if the usage is not intuitive/efficient.
Perhaps @glatterf42 can also review if the code structure and docs are okay.
Thank you!