Tree example: `examples.bogusdatasource` ModuleNotFoundError
schuderer opened this issue · 1 comments
When trying out the tree/iris example in a particular way, one is confronted with the error that the examples
module cannot be imported (ModuleNotFoundError: No module named 'examples'
). This happens on discovery/import of the datasources, when the examples.bogusdatasource
module specified in tree_cfg.yml
should be imported.
Steps to reproduce (lead to import error):
$ cd examples
$ mllaunchpad -c tree_cfg.yml -t # works despite also importing the datasources!
$ mllaunchpad -c tree_cfg.yml -p # ModuleNotFoundError
It should not be possible that modules can/cannot be imported when the same code is called from different functionalities, but all in the same environment and in the same current working directory. Might this have something to do with not having an unimportable src
directory preventing unwanted imports (https://hynek.me/articles/testing-packaging/)?
This interestingly always works:
$ cd examples
$ python -m mllaunchpad -c tree_cfg.yml -t
$ python -m mllaunchpad -c tree_cfg.yml -p # works fine!
Had a little difficulty reproducing just now in a new environment with a clean pip install .
(maybe installing in developer mode also changes things?).
There, both mllaunchpad commands failed, no matter whether using the mllaunchpad
script or the -m
call. This is actually good, as tree_cfg.yml
has an error: examples.bogusdatasource
should read just bogusdatasource
. The first should fail, as it's trying to import from examples
, which is the current working directory which doesn't have another examples
subdir.
Having changed tree_cfg.yml
to contain plugins: [bogusdatasource]
(removing examples.
), I can reproduce the error consistently: -t
and -a
work, while -p
results in
File "/.../mllaunchpad/.venv-test/lib/python3.7/site-packages/mllaunchpad/resource.py", line 189, in _get_all_classes
__import__(module)
ModuleNotFoundError: No module named 'bogusdatasource'