Skip to content
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

Optional ID refactor: part 3 #843

Merged
merged 12 commits into from
Dec 3, 2024
Merged

Optional ID refactor: part 3 #843

merged 12 commits into from
Dec 3, 2024

Conversation

figueroa1395
Copy link
Contributor

@figueroa1395 figueroa1395 commented Nov 25, 2024

Follow-up PR after #828. Closes #806

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395 figueroa1395 added the improvement Improvement on internal implementation label Nov 25, 2024
@figueroa1395 figueroa1395 self-assigned this Nov 25, 2024
@figueroa1395 figueroa1395 changed the base branch from main to feature/optional-id-refactor-part2 November 25, 2024 11:48
This reverts commit 520c174.

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Base automatically changed from feature/optional-id-refactor-part2 to main November 25, 2024 12:30
@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo changed the title Optional ID refactor - part 3 Optional ID refactor: part 3 Nov 25, 2024
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395
Copy link
Contributor Author

figueroa1395 commented Nov 25, 2024

The remaining problem comes from the fact that assert(static_cast<ptrdiff_t>(sequence_idx.size()) == std::distance(begin, end)); in update_component within main_model_impl.hpp doesn't hold anymore for permanent updates with mixed optional ids and invalid ids. I think this can be traced to the new implementation of get_all_sequence_idx_map, as the sequence size is not the same for every case, as it was before. Hence, a suggestion that doesn't involve changing the whole update_component flow would be welcome.

Note: Only the API tests regarding what's mentioned above are failing. Every other one, including on the Python side, passes just fine.

@mgovers
Copy link
Member

mgovers commented Nov 26, 2024

The remaining problem comes from the fact that assert(static_cast<ptrdiff_t>(sequence_idx.size()) == std::distance(begin, end)); in update_component within main_model_impl.hpp doesn't hold anymore for permanent updates with mixed optional ids and invalid ids. I think this can be traced to the new implementation of get_all_sequence_idx_map, as the sequence size is not the same for every case, as it was before. Hence, a suggestion that doesn't involve changing the whole update_component flow would be welcome.

Note: Only the API tests regarding what's mentioned above are failing. Every other one, including on the Python side, passes just fine.

how doesn't it hold up anymore? is that because you have 2 steps now; one involving the globally cached components, and another involving the locally cached ones?

if so, you can maybe go with one (or a combination) of the following solutions:

  1. something along the lines of for every component type that is cached: the assertion shall hold
  2. only call the concerning function if sequence_idx.size() > 0
  3. add fallback to the concerning function if sequence_idx.empty(). I think this was the logic before the original optional ID implementation
  4. split the function up into 2 logical steps
  5. if none of these are right, feel free to remove the assert if there's a good reason to remove it. it was just a sanity check; nothing more. nothing will break when you remove an assert (the only thing that can happen is that potential future bugs will be slightly harder to detect)

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395 figueroa1395 marked this pull request as ready for review December 2, 2024 09:30
@Jerry-Jinfeng-Guo
Copy link
Contributor

Nothing major left, only minor comments like above.

Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no other comments from my end

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@Jerry-Jinfeng-Guo
Copy link
Contributor

Quality Gate Passed Quality Gate passed

Issues 2 New issues 0 Accepted issues

Measures 0 Security Hotspots 96.8% Coverage on New Code 0.0% Duplication on New Code

See analysis details on SonarQube Cloud

The two issues are actually quite trivial to fix, could you patch them? @figueroa1395

Signed-off-by: Santiago Figueroa Manrique <santiago.figueroa.manrique@alliander.com>
@figueroa1395
Copy link
Contributor Author

Quality Gate Passed Quality Gate passed

Issues 2 New issues 0 Accepted issues
Measures 0 Security Hotspots 96.8% Coverage on New Code 0.0% Duplication on New Code
See analysis details on SonarQube Cloud

The two issues are actually quite trivial to fix, could you patch them? @figueroa1395

I had completely missed them. Thanks for the reminder. They have been addressed now.

@figueroa1395 figueroa1395 added this pull request to the merge queue Dec 3, 2024
Merged via the queue into main with commit f70233b Dec 3, 2024
28 checks passed
@figueroa1395 figueroa1395 deleted the optional-id-part3 branch December 3, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement on internal implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Refactor main model to move the optional id logic
3 participants