-
Notifications
You must be signed in to change notification settings - Fork 150
Refine find_nexus_module search locations and error handling #5767
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
Changes from 1 commit
0441e82
bd9bd9f
646ad70
27ea395
4ada190
c5f7527
0df99b5
437e5cc
2c45257
f509870
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #! /usr/bin/env python3 | ||
|
|
||
| def find_nexus_modules(): | ||
| import os | ||
| import sys | ||
| # Prepend the assumed path of a folder containing the closely coupled nexus module to module search path | ||
| # It points to the top Nexus directory not necessarily the top QMCPACK directory. | ||
| nexus_lib = os.path.realpath(os.path.join(__file__,'..','..')) | ||
| sys.path.insert(0,nexus_lib) | ||
|
|
||
| # check import of nexus modules | ||
| try: | ||
| import nexus | ||
| except (ImportError, ModuleNotFoundError): | ||
| raise ImportError( | ||
| "Nexus module is required but cannot be imported!" | ||
| ) | ||
| nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..')) | ||
|
|
||
| # ensure closely coupled nexus module is in use. | ||
| if nexus_lib != nexus_lib2: | ||
| exe_full_path = os.path.abspath(sys.argv[0]) | ||
| raise Exception('Broken Nexus installation! Nexus Python scripts are required to reside in the directory that contains the Nexus module.' | ||
| + '\nNexus Python script : ' + exe_full_path | ||
| + '\nNexus module root directory : ' + nexus_lib2) | ||
|
|
||
| #end def find_nexus_modules | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2178,17 +2178,7 @@ def regenerate_reference(update=False): | |
|
|
||
| #end def regenerate_reference | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| def find_nexus_modules(): | ||
| import sys | ||
| nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus')) | ||
| assert(os.path.exists(nexus_lib)) | ||
| sys.path.append(nexus_lib) | ||
| #end def find_nexus_modules | ||
|
|
||
| from nexus_modules import find_nexus_modules | ||
|
|
||
| def import_nexus_module(module_name): | ||
| import importlib | ||
|
|
@@ -2220,18 +2210,6 @@ if __name__=='__main__': | |
| from time import time # used to get user wall clock rather than cpu time | ||
| tstart_all = time() | ||
|
|
||
| testing_wrong_nexus_install = False | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this deleted?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reply. This should not be removed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The replaced find_nexus_module did the work already.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Due to the current requirement of |
||
| try: | ||
| import nexus | ||
| nexus_file = os.path.realpath(os.path.join(nexus.__file__,'../..')) | ||
| test_file = os.path.realpath(os.path.join(__file__,'../..')) | ||
| testing_wrong_nexus_install = nexus_file!=test_file | ||
| except: | ||
| pass | ||
| if testing_wrong_nexus_install: | ||
| print('\n\n\nInstalled Nexus package does not reside with this nxs-test executable.\n Currently installed nexus package: {}\n Correct Nexus package : {}\n Please install the correct Nexus package above.\n\n'.format(nexus_file,test_file)) | ||
| sys.exit(1) | ||
|
|
||
| # read command line input | ||
| regex = None | ||
| ctest = False | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the line that is probably going to continue failing if the executables get moved. The enforcement of location of the current file with the location of Nexus means that this will likely still result in a failure if the executables are moved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately that is a current requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the strict association in this PR. We can remove it in a following PR once a decision is made.