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

ModuleWatcher issue with import_or_reload #28

Open
philipstarkey opened this issue Dec 6, 2019 · 2 comments
Open

ModuleWatcher issue with import_or_reload #28

philipstarkey opened this issue Dec 6, 2019 · 2 comments
Labels
bug Something isn't working major

Comments

@philipstarkey
Copy link
Member

Original report (archived issue) by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Labscript compilation using import_or_reload can crash with the following after a module has been modified:

mw_bug.png

Saw this on a fresh install with Python 3.7 in miniconda, and the latest released versions of everything as of a week ago.

@philipstarkey philipstarkey added major bug Something isn't working labels Apr 5, 2020
@ispielma
Copy link

I have the same issue when I compile a shot after changing a connection table, and the only solution is to restart runmanager:

Z:\K_ML\userlib\labscriptlib\K_ML\connection_table.py modified: all non-whitelisted modules will be reloaded next run.
Traceback (most recent call last):
File "Z:\K_ML\userlib\labscriptlib\K_ML\Cell_Fluorescence.py", line 6, in
import_or_reload('labscriptlib.K_ML.connection_table')
File "c:\users\rubidium\anaconda3\lib\site-packages\labscript_utils_init_.py", line 46, in import_or_reload
module = importlib.import_module(modulename)
File "c:\users\rubidium\anaconda3\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 971, in _find_and_load_unlocked
File "", line 914, in _find_spec
File "c:\users\rubidium\anaconda3\lib\site-packages\labscript_utils\double_import_denier.py", line 52, in find_spec
dict_key = (fullname, tuple(path) if path is not None else None)
File "", line 1174, in iter
File "", line 1162, in _recalculate
File "", line 1158, in _get_parent_path
KeyError: 'labscriptlib'
Compilation aborted.

@zakv
Copy link
Contributor

zakv commented May 12, 2021

I'm pretty late to the party here, but I've seen a similar bug before. I resolved it by adding empty __init__.py files to the directories in userlib wherever modules were imported from. Those files aren't in general needed for Python 3 but I've seen that some of the import machinery that labscript uses can break without them. I'm not sure that adding those files would resolve this issue as well, but it might be worth a try. If that does work, it may be worth opening another feature request issue to make the import stuff work without __init__.py files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

3 participants