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

refactor: rasa/shared/core/training_data/visualization.py #12544

Merged
merged 24 commits into from
Aug 8, 2023

Conversation

arjun-234
Copy link
Contributor

@arjun-234 arjun-234 commented Jun 23, 2023

In the refactored version, In function(_remove_auxiliary_nodes), I've replaced the conversion of graph.predecessors(i) into a list with the direct usage of the generator. Additionally, I've introduced the predecessors_seen set to efficiently keep track of seen predecessors. When a duplicated predecessor is found, we can remove the node and break out of the inner loop.
Proposed changes:

  • This optimization reduces the time complexity of checking for duplicated nodes to approximately O((TMP_NODE_ID - special_node_idx) + out_degree(node)).

Status (please check what you already did):

  • Implemented performance optimizations

In the refactored version, In function(_remove_auxiliary_nodes), I've replaced the conversion of graph.predecessors(i) into a list with the direct usage of the generator. Additionally, I've introduced the predecessors_seen set to efficiently keep track of seen predecessors. When a duplicated predecessor is found, we can remove the node and break out of the inner loop. This optimization reduces the time complexity of checking for duplicated nodes to approximately O((TMP_NODE_ID - special_node_idx) + out_degree(node)).
@arjun-234 arjun-234 requested a review from a team as a code owner June 23, 2023 07:57
@CLAassistant
Copy link

CLAassistant commented Jun 23, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@Urkem Urkem left a comment

Choose a reason for hiding this comment

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

💯 Thanks for the contribution can you also add a unit test for _remove_auxiliary_nodes here

@arjun-234
Copy link
Contributor Author

💯 Thanks for the contribution can you also add a unit test for _remove_auxiliary_nodes here

Hey @Urkem,
Thank you for acknowledging my contribution! I have implemented unit test for the function: _remove_auxiliary_nodes. Feel free to review it whenever you have a moment.
Thank you once again!

@arjun-234 arjun-234 requested a review from Urkem July 5, 2023 11:15
Copy link
Contributor

@Urkem Urkem left a comment

Choose a reason for hiding this comment

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

Thanks for adding the unit test 👍

tests/shared/core/training_data/test_visualization.py Outdated Show resolved Hide resolved
tests/shared/core/training_data/test_visualization.py Outdated Show resolved Hide resolved
In this commit, I have implemented example test cases to test method: _remove_auxiliary_nodes in @pytest.mark.parametrize. Also,fixed the import error of networkx.
Copy link
Contributor

@Urkem Urkem left a comment

Choose a reason for hiding this comment

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

💯 Thanks for the contribution just fix the the ruff errors

@arjun-234
Copy link
Contributor Author

arjun-234 commented Jul 10, 2023

💯 Thanks for the contribution just fix the the ruff errors

Hey @Urkem, Done!

@arjun-234 arjun-234 requested a review from Urkem July 10, 2023 12:41
Copy link
Contributor

@Urkem Urkem left a comment

Choose a reason for hiding this comment

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

Just one small comment :)

tests/shared/core/training_data/test_visualization.py Outdated Show resolved Hide resolved
In this version, I have removed break statement from the loop so it can remove all the predecessors nodes which are in predecessors_seen without breaking the loop.
@arjun-234 arjun-234 requested a review from Urkem July 10, 2023 13:31
@arjun-234 arjun-234 requested a review from Urkem July 11, 2023 04:04
@arjun-234
Copy link
Contributor Author

Hey @Urkem,
I've addressed all the code style issues and made necessary fixes. Could you please review it once you are available.
Thanks :)

@arjun-234
Copy link
Contributor Author

Hey @Urkem,
Please review it once you are available :)

@vcidst vcidst enabled auto-merge (squash) August 8, 2023 06:18
@vcidst
Copy link
Contributor

vcidst commented Aug 8, 2023

Hey @arjun-234 I think these changes are making a regression test fail at, tests/regressions/test_action_two_stage_fallback_11294.py::test_action_two_stage_fallback_does_not_return_key_error (see here for traceback) do you think something in the test can be changed to avoid this failure? I've enabled auto-merge for this PR so it will be merged once the tests pass

@arjun-234
Copy link
Contributor Author

Hey @vcidst,
I'm puzzled by the failures. The first occurrence failed during Run Tests (test-other-unit-tests, ubuntu-22.04, 3.8). Unfortunately, we're facing different failure now in Run Tests (test-other-unit-tests, windows-2019, 3.10) :(

@vcidst
Copy link
Contributor

vcidst commented Aug 8, 2023

@arjun-234 I see, it might be a flaky test in that case. I'll re-run the CI and see if the problem persists

@arjun-234
Copy link
Contributor Author

@arjun-234 I see, it might be a flaky test in that case. I'll re-run the CI and see if the problem persists

@vcidst Thanks :)

@vcidst vcidst merged commit 491a392 into RasaHQ:main Aug 8, 2023
93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants