Skip to content

Fix OrderedDict mutation while iteration in prepare_data.py - #6

Open
0mil wants to merge 1 commit into
KeyuWu-CS:masterfrom
0mil:fix-ordered-dict-mutation
Open

Fix OrderedDict mutation while iteration in prepare_data.py#6
0mil wants to merge 1 commit into
KeyuWu-CS:masterfrom
0mil:fix-ordered-dict-mutation

Conversation

@0mil

@0mil 0mil commented Jul 25, 2024

Copy link
Copy Markdown

This PR fixes a RuntimeError: OrderedDict mutated during iteration error
This code worked in Python 3.9.16.
I guess that the error occurs when using Python 3.10.12.
The error is caused by modifying an OrderedDict during iteration, which is prohibited in Python 3.10.12.

Changes:

  • Created an temporary dictionary updated_state_dict to store modifications and update the original state_dict after the iteration.

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.

1 participant