Added __eq__ testing method. Created tests for it in test/ folder
This commit is contained in:
parent
4f21344e87
commit
29e03ac851
@ -57,10 +57,20 @@ def add_arch_strategy(self):
|
|||||||
for n in self.arch_name:
|
for n in self.arch_name:
|
||||||
if 'cray' in n.lower():
|
if 'cray' in n.lower():
|
||||||
self.arch_dict[n] = "MODULES"
|
self.arch_dict[n] = "MODULES"
|
||||||
if 'linux' in n.lower() or 'x86_64' in n.lower():
|
elif 'linux' in n.lower() or 'x86_64' in n.lower():
|
||||||
self.arch_dict[n] = "PATH"
|
self.arch_dict[n] = "PATH"
|
||||||
else:
|
else:
|
||||||
self.arch_dict[n] = None
|
self.arch_dict[n] = None
|
||||||
|
|
||||||
|
def get_arch_dict(self):
|
||||||
|
""" Grab the dictionary from the Architecture class, rather than access the internal Architecture attributes """
|
||||||
|
return self.arch_dict
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if self.arch_dict != {} and other.arch_dict != {}:
|
||||||
|
return self.arch_dict == other.arch_dict
|
||||||
|
else:
|
||||||
|
return self.arch_name == self.arch_name
|
||||||
|
|
||||||
def get_sys_type_from_spack_globals():
|
def get_sys_type_from_spack_globals():
|
||||||
"""Return the SYS_TYPE from spack globals, or None if it isn't set. Front-end"""
|
"""Return the SYS_TYPE from spack globals, or None if it isn't set. Front-end"""
|
||||||
@ -95,29 +105,43 @@ def get_sys_type_from_uname():
|
|||||||
|
|
||||||
def get_sys_type_from_config_file():
|
def get_sys_type_from_config_file():
|
||||||
""" Should read in a sys_type from the config yaml file. This should be the first thing looked at since
|
""" Should read in a sys_type from the config yaml file. This should be the first thing looked at since
|
||||||
The user can specify that the architecture is a cray-xc40
|
The user can specify that the architecture is a cray-xc40. A template yaml should be created when spack
|
||||||
|
is installed. Similar to .spackconfig
|
||||||
"""
|
"""
|
||||||
|
|
||||||
home_dir = os.environ["HOME"]
|
spack_home_dir = os.environ["HOME"] + "/.spack"
|
||||||
yaml_file = os.path.join(home_dir, ".spack/architecture.yaml")
|
yaml_file = os.path.join(spack_home_dir, "architecture.yaml")
|
||||||
if os.path.isfile(yaml_file):
|
|
||||||
with open(yaml_file) as config:
|
try:
|
||||||
config_dict = config['architecture']
|
config_dict = yaml.load(open(yaml_file)) # Fix this to have yaml.load()
|
||||||
front_end = config_dict['front']
|
arch = config_dict['architecture']
|
||||||
back_end = config_dict['back']
|
front = arch['front']
|
||||||
return Architecture(front_end)
|
back = arch['back']
|
||||||
|
|
||||||
|
except:
|
||||||
|
print "No architecture.yaml config file found"
|
||||||
|
|
||||||
|
return Architecture(front,back)
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
def sys_type():
|
def sys_type():
|
||||||
"""Returns a SysType for the current machine. Should return output to an
|
"""Priority of gathering sys-type.
|
||||||
Architecture class
|
1. YAML file that the user specifies the name of the architecture. e.g Cray-XC40 or Cray-XC30
|
||||||
|
2. UNAME
|
||||||
|
3. GLOBALS
|
||||||
|
4. MAC OSX
|
||||||
|
Yaml should be a priority here because we want the user to be able to specify the type of architecture to use.
|
||||||
|
If there is no yaml present then it should move on to the next function and stop immediately once it gets a
|
||||||
|
arch name
|
||||||
|
|
||||||
"""
|
"""
|
||||||
methods = [get_sys_type_from_spack_globals,
|
methods = [get_sys_type_from_config_file,
|
||||||
get_sys_type_from_environment,
|
get_sys_type_from_uname,
|
||||||
get_mac_sys_type]
|
get_sys_type_from_spack_globals,
|
||||||
|
get_mac_sys_type]
|
||||||
|
|
||||||
# search for a method that doesn't return None
|
# search for a method that doesn't return None
|
||||||
sys_type = (None,None)
|
sys_type = None
|
||||||
for method in methods:
|
for method in methods:
|
||||||
sys_type = method()
|
sys_type = method()
|
||||||
if sys_type: break
|
if sys_type: break
|
||||||
|
Loading…
Reference in New Issue
Block a user