Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
load_path = path
break
if load_path is None:
LOGGER.info("Could not find 'qcengine.yaml'. Searched the following paths: {}".format(", ".join(test_paths)))
LOGGER.info("Using default options...")
else:
import yaml
LOGGER.info("Found 'qcengine.yaml' at path: {}".format(load_path))
with open(load_path, "r") as stream:
user_config = yaml.load(stream)
for k, v in user_config.items():
NODE_DESCRIPTORS[k] = NodeDescriptor(name=k, **v)
Find the correct NodeDescriptor based off current hostname
"""
if isinstance(hostname, NodeDescriptor):
return hostname
if hostname is None:
hostname = get_global("hostname")
# Find a match
for name, node in NODE_DESCRIPTORS.items():
if fnmatch.fnmatch(hostname, node.hostname_pattern):
config = node
break
else:
config = NodeDescriptor(
name="default", hostname_pattern="*", memory=get_global("memory"), ncores=get_global("ncores")
)
return config
def get_node_descriptor(hostname: Optional[str] = None) -> NodeDescriptor:
"""
Find the correct NodeDescriptor based off current hostname
"""
if isinstance(hostname, NodeDescriptor):
return hostname
if hostname is None:
hostname = get_global("hostname")
# Find a match
for name, node in NODE_DESCRIPTORS.items():
if fnmatch.fnmatch(hostname, node.hostname_pattern):
config = node
break
else:
config = NodeDescriptor(
name="default", hostname_pattern="*", memory=get_global("memory"), ncores=get_global("ncores")
)