Skip to content

Conversation

@teojgo
Copy link
Contributor

@teojgo teojgo commented Jun 8, 2018

Fixes #322

@teojgo
Copy link
Contributor Author

teojgo commented Jun 8, 2018

@rsarm can you running try with this branch?

filename = os.path.join(filename, '__init__.py')

if filename.startswith('..'):
if filename.startswith('..') or os.path.isfile(filename):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a sec. Is this not always true??

Copy link
Contributor Author

@teojgo teojgo Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the filename is a directory no

@codecov-io
Copy link

codecov-io commented Jun 8, 2018

Codecov Report

Merging #323 into master will decrease coverage by 0.05%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
- Coverage   91.24%   91.18%   -0.06%     
==========================================
  Files          67       67              
  Lines        7935     7941       +6     
==========================================
+ Hits         7240     7241       +1     
- Misses        695      700       +5
Impacted Files Coverage Δ
unittests/test_utility.py 98.74% <100%> (+0.01%) ⬆️
reframe/utility/__init__.py 92.56% <87.5%> (-4.14%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9e6692...c87330b. Read the comment docs.

Theofilos Manitaras and others added 3 commits June 8, 2018 13:35
The current implementation first resolves the module file relative to
ReFrame. If it is inside ReFrame's top-level dir, it uses the standard
Python mechanism (from importlib) to import the module. If not it loads
it directly from the file assigning it a module name derived from the
file's basename.

module_name = _get_module_name(filename)
if os.path.isabs(filename):
if os.path.isabs(filename) or os.path.basename(filename) == filename:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix does not work. Try running reframe from a directory up:

./reframe/bin/reframe --system=generic -c reframe/tutorial/example1.py -l

The whole problem comes from how the sys.path is defined (check this). Actually, for our case, the first element is the path where the reframe.py or test_reframe.py exists. That's why these relative imports work fine when we we invoke ReFrame from the same directory. I've done a PR into your branch with the correct implementation.

@vkarak vkarak merged commit 5ee6f15 into master Jun 11, 2018
@vkarak vkarak deleted the bugfix/load_module_python_file branch June 11, 2018 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants