Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions nexus/bin/eshdf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,32 @@ from optparse import OptionParser
# Non-standard Python library imports
import numpy as np


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib

# 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

# Load Nexus modules
Expand Down
27 changes: 21 additions & 6 deletions nexus/bin/nxs-redo
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
import os
from optparse import OptionParser


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib
#end def find_nexus_modules

# 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

# Get Nexus version
find_nexus_modules()
Expand Down
28 changes: 21 additions & 7 deletions nexus/bin/nxs-sim
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,40 @@
import os
from optparse import OptionParser


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib
#end def find_nexus_modules

# 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

# Load Nexus modules
find_nexus_modules()
from nexus.nexus_version import nexus_version
from nexus.developer import obj



class SimTool(obj):

indicators = ['setup','sent_files','submitted','finished','failed','got_output','analyzed']
Expand Down
42 changes: 23 additions & 19 deletions nexus/bin/nxs-test
Original file line number Diff line number Diff line change
Expand Up @@ -2178,18 +2178,34 @@ def regenerate_reference(update=False):

#end def regenerate_reference

# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
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! Make sure Nexus module available under " + nexus_lib
)
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)


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


def import_nexus_module(module_name):
import importlib
return importlib.import_module(module_name)
Expand Down Expand Up @@ -2220,18 +2236,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
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this deleted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please reply. This should not be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The replaced find_nexus_module did the work already.

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
Expand Down
28 changes: 22 additions & 6 deletions nexus/bin/qdens
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@
import gc
import os
from optparse import OptionParser
import nexus.numpy_extensions as npe

# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib
#end def find_nexus_modules

# 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

# Load Nexus modules
find_nexus_modules()
import nexus.numpy_extensions as npe
from nexus.nexus_version import nexus_version
from nexus.developer import DevBase,obj,error,ci,unavailable
import nexus.memory as memory
Expand Down
27 changes: 21 additions & 6 deletions nexus/bin/qdens-radial
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,33 @@

from optparse import OptionParser


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib
#end def find_nexus_modules

# 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

# Load Nexus modules
find_nexus_modules()
Expand Down
26 changes: 21 additions & 5 deletions nexus/bin/qmc-fit
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,32 @@ except (ImportError,RuntimeError):
plots_available = False
#end try


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib

# 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

# Load Nexus modules
Expand Down
27 changes: 21 additions & 6 deletions nexus/bin/qmca
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@ import os
import sys
from optparse import OptionParser


# Copied from verify_nexus_installation. Modification must done on verify_nexus_installation first
# Locate and import the closely coupled Nexus module
def find_nexus_modules():
import os
import sys
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..','nexus'))
assert(os.path.exists(nexus_lib))
# 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)
import nexus

# check import of nexus modules
try:
import nexus
except (ImportError, ModuleNotFoundError):
raise ImportError(
"Nexus module is required but cannot be imported! Make sure Nexus module available under " + nexus_lib
)
nexus_lib2 = os.path.realpath(os.path.join(nexus.__file__,'..','..'))
assert nexus_lib2==nexus_lib
#end def find_nexus_modules

# 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

# Load Nexus modules
find_nexus_modules()
Expand Down
38 changes: 38 additions & 0 deletions nexus/bin/verify_nexus_installation
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be removed. See comment in the conversation/chat.


# Gold implementation. All the Nexus scripts need to be updated once modified.
# <nexus_root>/bin # contains nexus exectuables
# <nexus_root>/nexus #contains nexus module files
# Locate and import the closely coupled Nexus module
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! Make sure Nexus module available under " + nexus_lib
)
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


if __name__=='__main__':
# Load Nexus modules
find_nexus_modules()
print('Success')
#end if
Loading