-
Notifications
You must be signed in to change notification settings - Fork 154
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
Integration of LPdiag tool #704
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #704 +/- ##
=======================================
+ Coverage 94.8% 95.2% +0.4%
=======================================
Files 43 46 +3
Lines 3797 4312 +515
=======================================
+ Hits 3600 4107 +507
- Misses 197 205 +8
|
Location: I propose to drop the MCA level from the tree, i.e., to move LPdiag dir directly below the tools. I would keep the LPdiag name unless someone will propose a better name. Alternative names for possible consideration: LPcheck, LPinfo. This was solved. The tool is called lp_diag, and it is moved to the right place: .../ tools/lp_diag |
Unfortunately, I cannot contribute to the PR review:
I will update the readme.txt files, and later write some documentation. However, I assume that pushing any changes should wait until the initial PR will be accepted and the files will be in a better place than pr/704 |
Thanks for moving the stuff. Retrieving the commit history is certainly not worth additional work. |
abfe3b3
to
0ff6ed5
Compare
Thanks for the updates :)
|
Thanks for comments and suggestions. Please see my reaction to each issue below:
I will review and implement exclusions of the files that indeed should be only local. BTW: I am indeed convinced that nobody would like to commit the
I will review and correct this.
I have already explored sphinx a little bit, and will write the *rst version after we will clarify several small issues pointed out below.
Indeed, we should wait with merging until the documentation will be in a good enough shape. Regarding the usage: I want to discuss this issue with at least Oliver as I have only the developer perspective. We also need to add the a hint on generating the MPS-format file from a message_ix generated model instance; also here I need help of Oliver.
I will keep this in mind when writing *rst. BTW: please let me know, how to locally generate (using the message_ix style/config) the resulting *html version?
I would consider: Also here Oliver, and possibly other colleagues, may have better ideas. |
Thanks, Marek, for your detailed answer. Just pinging @OFR-IIASA here to put this PR on this radar. For building the sphinx docs locally, we have this guide. Please let me know if this is not complete or needs updates. |
2268b1d
to
a0bb8f0
Compare
Dear @marek-iiasa and @measrainsey, please take a look at this PR again. While adding some tests today, I restructured some aspects of the tool, so please make sure it still behaves as intended. Among others, I renamed some functions (e.g., |
Please note: you can click on 'Show all checks', find the one called 'docs/readthedocs.com:iiasa-energy-program-message-ix' and click on 'Details' to see the docs as built from the files in this PR :) |
77fe21a
to
c0cc535
Compare
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.
Some initial clean-ups:
-
The "README" file should just be moved to doc/tools/lp_diag.rst, not
.. include::
-ed. This approach is fragile. -
The contents of the other README files should be included in the docs.
-
The .gitignore files should be integrated with the top-level .gitignore.
-
message_ix/tools/lp_diag/test_mps/… should be message_ix/tests/data/lp_diag/…
- Flatten all the files to a single directory. The ones in the …/error/… subdirectory can be renamed, for instance, error-bounds-too-short.mps.
- Add the .mps extension.
-
There are two modules introduced:
message_ix.tools.lp_diag.lp_diag
message_ix.tools.lp_diag.lpdiag
The basic principle is that (sub)module names should remind us what the (sub)modules contain. To achieve that, we should avoid (1) duplicate names in the hierarchy (What does .lp_diag.lp_diag contain that is not in .lp_diag itself?), and (2) names that differ only by an underscore.
The strategy of placing the I/O files within the code directory is also not compatible with some kinds of Python installations, and we avoid this almost always. The code should default to using the directory in which the user invokes the CLI (the CWD, or current working directory). I can investigate (separately) adding a "local data" configuration setting that can point to another path, but again this path should be outside the code tree.
I've updated the PR to comply with your suggestions, thanks @khaeru. For the last point, though, I think we will need your input, @marek-iiasa. One note about |
70dddb3
to
3339d42
Compare
Thanks for your contribution here, @ywpratama. Unfortunately, your commit broke several tests ... as does mine. I thought this might be fixed by rebasing on top of main, but apparently, that's not the case. I will have to investigate. Sorry for overwriting your commit. |
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.
In the interest of time, I'll step in here to make some of these changes myself:
- Choose module names, per the last review.
- Conform to the code style:
- Reword some commit messages.
- Fix docstrings.
- Use a fixture for the test data path.
- Integrate the CLI.
Please find the original repo at https://github.com/marek-iiasa/MCA/tree/master Note that e.g. the reading material has not yet been included here
Counter of coeffs having different magnitudes was added. Order and wordings of printouts was improved. Comments added to the code, including modified TODO comments.
Re-enable pre-commit mypy hook.
* Remove the markers: * message_ix/tools/lp_diag/data/mps/of_* * message_ix/tools/lp_diag/Bak/ * message_ix/tools/lp_diag/doc/ * message_ix/tools/lp_diag/sph/ * Use .git/info/exclude for such personal markers!
* Changing `"col":self.mat_row` to `"col":self.mat_col` when generating self.mat DataFrame to allow the tool to correctly identify columns with bad coefficients * Thanks, @ywpratama
Adjust references
Match the module name
- Integrate with top-level CLI as "message-ix lp-diag". - Use click option processing; remove read_args(). - Use click.Path and pathlib for checks. - Reflow comments and code for readability.
- Fix typos in some string literals.
- Use heading order (*, =, -) consistent with other docs. - Correct a malformed reference. - Add a `.. contents::` directive.
Also: - Replace "python lp_diag.py" with "message-ix lp-diag". - use :program: role to document CLI options; use lower case to match the actual option names. - use :file: role where appropriate - Remove comments in cli.py that duplicated docs text.
e3b4a8b
to
50dce2a
Compare
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.
Okay, I've made the changes mentioned above, so LGTM once the CI checks pass.
Some other things which could be handled in a follow-up PR:
- Copy-edit the docs page. There are several small enhancements that could be made, like using Sphinx roles instead of double-backtick in many places, and improving the clarity of text about the locations of files. In particular, the command no longer needs to be run in any particular directory as long as the user gives valid values for --wdir and --mps.
- Define, type, and comment the class attributes of LPdiag outside of the __init__() method so they appear in the docs; use that method only for setting defaults.
As discussed on Slack, this branch contains the files of the MCA tool that @marek-iiasa created. Unfortunately, I couldn't (without significantly more work) keep the commit history and move the files to their new location. Please let me know if that should still be done.
Please find the original repo at https://github.com/marek-iiasa/MCA/tree/master. Note that e.g. the reading material has not yet been included here.
How to review
PR checklist