Skip to content

ModuleNotFoundError thrown for certain relative paths #322

@rsarm

Description

@rsarm

For instance, when running an example from the tutorial on the root folder of reframe with

reframe -r -c tutorial/example1.py

the test runs fine. But when running it inside reframe/tutorial a ModuleNotFoundError: No module named 'example1' is thrown:

$> reframe -r -c example1.py 
Command line: /home/sarafael/.local/bin/reframe --config-file /home/sarafael/git/reframe/reframe/settings.py --system generic -r -c example1.py
Reframe version: 2.13-dev1
Launched by user: sarafael
Launched on host: sarafael-thinkpad
Reframe paths
=============
    Check prefix      : 
    Check search path : 'example1.py'
    Stage dir prefix  : /home/sarafael/git/reframe/tutorial/stage/
    Output dir prefix : /home/sarafael/git/reframe/tutorial/output/
    Logging dir       : /home/sarafael/git/reframe/tutorial/logs
/home/sarafael/.local/bin/reframe: unexpected error: No module named 'example1'
Traceback (most recent call last):
  File "/home/sarafael/git/reframe/reframe/frontend/cli.py", line 327, in main
    checks_found = loader.load_all()
  File "/home/sarafael/git/reframe/reframe/frontend/loader.py", line 182, in load_all
    checks.extend(self.load_from_file(d))
  File "/home/sarafael/git/reframe/reframe/frontend/loader.py", line 151, in load_from_file
    return self.load_from_module(util.import_module_from_file(filename))
  File "/home/sarafael/git/reframe/reframe/utility/__init__.py", line 54, in import_module_from_file
    return importlib.import_module(module_name)
  File "/home/sarafael/software/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'example1'

However, it works fine if adding a path that starts with ../ before the relative path to the test. For instance, both

reframe -r -c ../../reframe/tutorial/example1.py

and

reframe -r -c ../tutorial/example1.py

work inside ~/reframe/tutorial.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions