-
Notifications
You must be signed in to change notification settings - Fork 30
Add new tables to calculate the lowest resolution for flows that have a flows relationship #1183
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
Conversation
✅ MPS files match🤖 This was CompareMPS, we hope you have enjoyed this program. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1183 +/- ##
==========================================
+ Coverage 97.70% 97.79% +0.09%
==========================================
Files 30 31 +1
Lines 1132 1133 +1
==========================================
+ Hits 1106 1108 +2
+ Misses 26 25 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
This comment was marked as outdated.
This comment was marked as outdated.
@suvayu Inspired by our last conversation, my next step in the new feature is to be able to test the main pieces of the code without doing a full integration test. The flexible temporal resolution is key for Tulipa, so I have created a separate test to test independently the three main functions that calculate these tables. I have also added my new flexible temporal resolution function and tested it for the mock-up data. Please let me know your comments and suggestions. @gnawin, also, from the developers' maintainability perspective, please let me know if the tests make sense or if you would like to add/delete something else. |
test/test-data-preparation.jl
Outdated
|
||
DBInterface.execute( | ||
connection, | ||
"CREATE TABLE rep_periods_data |
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.
Do you need this table rep_periods_data
(because I don't see it directly in this PR)?
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.
you need it to test the create_highest_resolution_table!
, which is not part of my PR, but as @suvayu says, if you can add/fix something in your PR, just do it 😝
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.
@datejada thank you! I think you tested nicely, and you cover more than the purpose of MIMO because you tested all lowest_resolution
and highest_resolution
tables, great! I have some minor suggestions regarding the testing, to improve some consistency with other tests.
Thanks! I like the suggestions, let's see if we can make it work by registering the dataframes. So far, I failed when I tried as I commented here: #1183 (comment) |
@gnawin, thanks for the comments and discussion. I have made two main changes:
The second change is to balance between: Approach a) is 100% safe, but it is not easy to understand why you have all the rows. Approach b) is not 100% safe, but it makes the test readable by focusing on only what is happening in one asset in all the cases + as a second check, that the output tables are the correct size (one would expect these checks to be enough). I am still trying to balance both approaches, but let's discuss with @suvayu and @abelsiqueira the best way to proceed. |
Uff! I got tagged so many times :-p I'll have a look :) |
Again, I don't have the whole context. If needed, ping me again and I'll review the whole PR. expected_df = DataFrame(
... # I think you can pretty much use the same array of tuples
)
computed_df = DuckDB.query("SELECT .. WHERE asset = 'asset' SORT BY ...") |> DataFrame
@test dataframes_are_equal(expected_df, computed_df) If all expected_df = ...
@test expected_df_matches_filtered_table(expected_df, target_table) |
🤖 CompareMPS report✅ MPS files match |
@suvayu @abelsiqueira @gnawin I have included all the comments as we discussed. Please let me know if you have further suggestions. |
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.
Thanks, LGTM.
💀 ⭐
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.
Thanks. We have discussed this PR in person. For the future, it would be nice to generalize the function for creating highest/lowest resolutions, maybe changing the name from asset to something else is already good enough. Already in #1192, I'm just reiterating its usefulness.
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.
LGTM 👍
This pull request refactors the
create_merged_tables!
function to simplify its implementation, introduces a new table for flow relationships, and expands test coverage for data preparation.Refactoring and Simplification:
create_merged_tables!
with an external SQL file (create-merged-tables.sql
) for better maintainability and readability. (src/data-preparation.jl
, [1] [2] [3]New Feature: Flow Relationships:
merged_flows_relationship
, to handle flow relationships, including creating and populating aflows_relationship
column in theflows_relationships
table. (src/sql/create-merged-tables.sql
, src/sql/create-merged-tables.sqlR1-R97)create_lowest_resolution_table!
function to include the newmerged_flows_relationship
table in its processing. (src/data-preparation.jl
, src/data-preparation.jlL497-R451)Expanded Test Coverage:
test/test-data-preparation.jl
to validate the correctness of the merged tables, including the newmerged_flows_relationship
table, and the lowest and highest resolution tables. (test/test-data-preparation.jl
, test/test-data-preparation.jlR1-R234)_test_rows_exist
to verify the presence of specific rows in test tables. (test/utils.jl
, test/utils.jlR20-R33)Related issues
Closes #1182
Checklist