Skip to content
Snippets Groups Projects

utils.py: explicitly convert module keys to a list

Merged Matthew David Pitkin requested to merge matthew-pitkin/bilby:loadedmodules into master

For some reason when I locally run my test suite for CWInPy it fails when using the loaded_modules_dict function in utils.py. The error given is:

cwinpy/hierarchical.py:1428: in sample
    self._result = bilby.run_sampler(
../../miniconda3/envs/cwinpy/lib/python3.8/site-packages/bilby/core/sampler/__init__.py:145: in run_sampler
    meta_data["loaded_modules"] = loaded_modules_dict()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def loaded_modules_dict():
        module_names = sys.modules.keys()
        vdict = {}
        print(module_names)
>       for key in module_names:
E       RuntimeError: dictionary changed size during iteration

../../miniconda3/envs/cwinpy/lib/python3.8/site-packages/bilby/core/utils.py:1277: RuntimeError

so it's complaining about a dictionary size changing during the loop.

I seem to be able to fix this by explicitly setting:

module_names = list(sys.modules.keys())

I'm not sure why I'm seeing the error, but this fix seems to be otherwise harmless.

Merge request reports

Pipeline #192644 passed

Pipeline passed for 5f5cbbd5 on matthew-pitkin:loadedmodules

Approved by

Merged by Moritz HuebnerMoritz Huebner 4 years ago (Feb 22, 2021 12:44am UTC)

Merge details

  • Changes merged into master with 52ceb4a7.
  • Deleted the source branch.

Pipeline #193151 failed

Pipeline failed for 52ceb4a7 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading