-
Notifications
You must be signed in to change notification settings - Fork 35
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
Update the nexus module #106
Conversation
Currently, the linting test is failing (among others). Please see our guide for contributing code to see what code style we expect. Please also note that black, flake8, mypy, and isort can all be configured to be applied automatically whenever you save your code (the details of which can vary, but we can work it out together if you want to). This helps passing theses tests tremendously. |
The current issue with the other tests seems to be that they still rely on code in message_data (which they shouldn't, as explained before, since all code here should be open source):
|
Also to make sure: how large are these data files that you are updating here? If they are too large (and there are lots of them), it might be better to upload them to Zenodo or so (see the second point in the comment by @khaeru). |
|
43ce2a9
to
21daf50
Compare
The tests are mostly working, despite what it looks like here. There are some general issues however that we need to address to fully see their potential:
ERROR message_ix_models/tests/model/water/test_cooling.py
ERROR message_ix_models/tests/model/water/test_utils.py
FAILED message_ix_models/tests/model/water/test_irrigation.py::test_add_irr_structure - AttributeError: 'dict' object has no attribute 'regions'
FAILED message_ix_models/tests/model/water/test_water_supply.py::test_map_basin_region_wat - AttributeError: 'dict' object has no attribute 'time'
FAILED message_ix_models/tests/model/water/test_water_supply.py::test_add_water_supply - ModuleNotFoundError: No module named 'your_module'
FAILED message_ix_models/tests/model/water/test_water_supply.py::test_add_e_flow - ModuleNotFoundError: No module named 'your_module'
info = context["water build info"]
if "year" in context.time: Are the lines from the actual code. I don't know if this should work, but it's treating
|
@awais307 can you please update on what your commits did, if anything is still missing and how you expect others to review? thanks |
a1877f4
to
cc95334
Compare
@awais307, @adrivinca: the tests are almost working, you're on a good path there! Almost all errors seem to originate from the same problem: that you are not using a 'real' One test error might remain, though, and that is this one: ___________________________________________ test_map_yv_ya_lt ___________________________________________
def test_map_yv_ya_lt():
periods = (2010, 2020, 2030, 2040)
lt = 20
ya = 2020
expected = pd.DataFrame(
{"year_vtg": [2010, 2020, 2020, 2030], "year_act": [2020, 2020, 2030, 2040]}
)
result = map_yv_ya_lt(periods, lt, ya)
> pd.testing.assert_frame_equal(result, expected)
E AssertionError: DataFrame are different
E
E DataFrame shape mismatch
E [left]: (8, 2)
E [right]: (4, 2)
message_ix_models/tests/model/water/test_utils.py:124: AssertionError The shape of the compared DataFrames won't be fixed by the different context, I assume. Please check that One final note: I removed a few markers that told rust to ignore functions being too complex. Please take another look at those and try to reduce their complexity! In most cases, it is enough to take a part of the function that includes a lot of Please let me know if you need help with any of the above :) |
63aad7c
to
dbc9e6c
Compare
Hi @adrivinca and @awais307, I've taken another look at this PR. I started by addressing all code quality issues: applying some formatting and reducing code complexity. The latter worked quite well in parts because you already had all the puzzle pieces present: e.g. in Next, I took a look at the failing tests. For some of them, I was able to fix them myself, though even in those cases, there are some open questions. Please check e.g. the Finally, your message-ix-models/message_ix_models/model/water/reporting.py Lines 14 to 36 in abcd614
run_old_reporting() is part of your main workflow (via report_full() ), so legacy_reporting is actually required to be there. My version of mypy is already marking this as an error because legacy_reporting really cannot be None , so your code still requires message_data to be present, although no code in this repo should. Please find a solution for that, e.g. by not using the legacy_reporting at all and instead using the reporting system that message_ix_models provides. At the very least, you should add a clause/flag to report_full so that run_old_reporting() is only run if message_data is present. For this, you could reuse the HAS_MESSAGE_DATA flag that already exists in the code:
|
Thanks a lot @glatterf42 for spending time on this and for the thorough overview.
Some FIXME are related to making a more general configuration for the module, and also maybe a testing config. Other points are also open questions to me and I would like @awais307 to please intervene and fix.
currently, the function is checking to match this df
and df_sw in the function read_water_availability() before it breaks
I think these functions need to be tested with actual existing data
unfortunately I am not familiar with the |
@awais307 I rebased this PR on top of the latest main branch to keep the linear commit history and used this opportunity to make two functions less complex. You should now be able to use the latest commit here, make changes and merge to main without 'out-of-date' issues; please let me know if you can't. |
18b3648
to
c3701f5
Compare
@awais307, I'm trying to keep the commit history linear by using |
okay, for some reason, my local tries to merge it whenever I fetch the changes. |
Could you please try to configure your local git interaction not to do that, then? If you tell me how you interact with git locally, I might be able to help you. Do you use Github Desktop? GitKraken? The command line? To get the changes from up here to your system and overwrite the changes you have locally, you might need to perform something like a "force pull", which you can do following these instructions. Please let me know if you need any help with that :) |
806adc2
to
a8d9136
Compare
This PR addresses issue#93 and updates data to the nexus module, addresses the tests issue
The code has been restructured to be more test-friendly
two tests has been marked with
@pytest.mark.xfail(reason="Temporary, for #106")
, namelytest_report_full
in test_report.pyand
test_build
in test_build.pyas they both require a fully parametrized scenario as a starting point, which is not the case for the "bare" scenario for tests.
Since we are about to do major revision and update to the module, we decided to postpone investing further time in those tests.
all tests seem to pass for py3.12, not for py3.11
How to review
PR checklist