Skip to content
Merged
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
9 changes: 4 additions & 5 deletions lib/ramble/ramble/appkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
from llnl.util.filesystem import *

import ramble.language.application_language
from ramble.repository import get_base_class

ExecutableApplication = get_base_class("executable-application")
ApplicationBase = get_base_class("application-base")

from ramble.language.application_language import *
from ramble.language.shared_language import *
from ramble.repository import get_base_class
from ramble.spec import Spec
from ramble.util.command_runner import (
CommandRunner,
Expand All @@ -34,3 +30,6 @@
from ramble.util.foms import FomType
from ramble.util.logger import logger
from ramble.util.output_capture import OUTPUT_CAPTURE

ExecutableApplication = get_base_class("executable-application")
ApplicationBase = get_base_class("application-base")
2 changes: 1 addition & 1 deletion lib/ramble/ramble/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_module(cmd_name):
try:
module = spack.extensions.get_module(cmd_name)
except AttributeError:
raise RambleCommandError("Command %s does not exist." % cmd_name)
raise RambleCommandError("Command %s does not exist." % cmd_name) from None

attr_setdefault(module, SETUP_PARSER, lambda *args: None) # null-op
attr_setdefault(module, DESCRIPTION, "")
Expand Down
17 changes: 0 additions & 17 deletions lib/ramble/ramble/cmd/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ramble.cmd.common.arguments as arguments
import ramble.config
import ramble.mirror
from ramble.error import RambleError
from ramble.util.logger import logger

import spack.util.url as url_util
Expand Down Expand Up @@ -171,22 +170,6 @@ def mirror_list(args):
mirrors.display()


def _read_specs_from_file(filename):
specs = []
with open(filename) as stream:
for i, string in enumerate(stream):
try:
s = ramble.Spec(string)
s.application
specs.append(s)
except RambleError as e:
logger.debug(e)
logger.die(
"Parse error in %s, line %d:" % (filename, i + 1), ">>> " + string, str(e)
)
return specs


def mirror_destroy(args):
"""Given a url, recursively delete everything under it."""
mirror_url = None
Expand Down
14 changes: 8 additions & 6 deletions lib/ramble/ramble/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _write_section(self, section):
with open(filename, "w") as f:
syaml.dump_config(data, stream=f, default_flow_style=False)
except (yaml.YAMLError, OSError) as e:
raise ConfigFileError("Error writing to config file: '%s'" % str(e))
raise ConfigFileError("Error writing to config file") from e

def clear(self):
"""Empty cached config information."""
Expand Down Expand Up @@ -347,7 +347,7 @@ def _write_section(self, section):
rename(tmp, self.path)

except (yaml.YAMLError, OSError) as e:
raise ConfigFileError("Error writing to config file: '%s'" % str(e))
raise ConfigFileError("Error writing to config file") from e

def __repr__(self):
return f"<SingleFileScope: {self.name}: {self.path}>"
Expand Down Expand Up @@ -753,7 +753,7 @@ def print_section(self, section, blame=False):
data[section] = self.get_config(section)
syaml.dump_config(data, stream=sys.stdout, default_flow_style=False, blame=blame)
except (yaml.YAMLError, OSError):
raise ConfigError("Error reading configuration: %s" % section)
raise ConfigError("Error reading configuration: %s" % section) from None


@contextmanager
Expand Down Expand Up @@ -1033,13 +1033,15 @@ def read_config_file(filename, schema=None):
return data

except StopIteration:
raise ConfigFileError("Config file is empty or is not a valid YAML dict: %s" % filename)
raise ConfigFileError(
"Config file is empty or is not a valid YAML dict: %s" % filename
) from None

except MarkedYAMLError as e:
raise ConfigFileError(f"Error parsing yaml{str(e.context_mark)}: {e.problem}")
raise ConfigFileError(f"Error parsing yaml{str(e.context_mark)}: {e.problem}") from e

except OSError as e:
raise ConfigFileError(f"Error reading configuration file {filename}: {str(e)}")
raise ConfigFileError(f"Error reading configuration file {filename}") from e


def _override(string):
Expand Down
6 changes: 3 additions & 3 deletions lib/ramble/ramble/definitions/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.

from typing import List
from typing import List, Optional


class Families:
Expand All @@ -15,7 +15,7 @@ class Families:
def __init__(
self,
origin_type: str,
families: List[str] = [],
families: Optional[List[str]] = None,
):
"""Constructor for families object

Expand All @@ -24,7 +24,7 @@ def __init__(
families: List of families
"""
self.family_type = f"{origin_type}_family"
self.families = families
self.families = families if families is not None else []

def __iter__(self):
"""Iterate over families"""
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def expand_var(
if not passthrough_setting:
raise RambleSyntaxError(
f"Encountered a passthrough error while expanding {var}\n" f"{e}"
)
) from None

logger.debug(f"END OF EXPAND_VAR STACK {value}")
if typed:
Expand Down Expand Up @@ -849,7 +849,7 @@ def perform_math_eval(self, in_str):
logger.debug(f' Math input is: "{in_str}"')
logger.debug(e)
except RambleSyntaxError as e:
raise RambleSyntaxError(f'{str(e)} in "{in_str}"')
raise RambleSyntaxError(f'{str(e)} in "{in_str}"') from None
except SyntaxError as e:
logger.debug(f"ast.parse hit the following syntax error on input: {in_str}")
logger.debug(e)
Expand Down
12 changes: 7 additions & 5 deletions lib/ramble/ramble/experiment_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, workspace):
try:
self.keywords.check_reserved_keys(workspace_context.variables)
except ramble.keywords.RambleKeywordError as e:
raise RambleVariableDefinitionError(f"Workspace variable error: {e}")
raise RambleVariableDefinitionError(f"Workspace variable error: {e}") from None

self._set_context(self._contexts.workspace, workspace_context)

Expand Down Expand Up @@ -125,7 +125,9 @@ def set_application_context(self, app_context):
try:
self.keywords.check_reserved_keys(app_context.variables)
except ramble.keywords.RambleKeywordError as e:
raise RambleVariableDefinitionError(f"In application {app_context.context_name}: {e}")
raise RambleVariableDefinitionError(
f"In application {app_context.context_name}: {e}"
) from None

self._set_context(self._contexts.application, app_context)

Expand All @@ -136,7 +138,7 @@ def set_workload_context(self, workload_context):
self.keywords.check_reserved_keys(workload_context.variables)
except ramble.keywords.RambleKeywordError as e:
namespace = f"{self.application_namespace}.{workload_context.context_name}"
raise RambleVariableDefinitionError(f"In workload {namespace}: {e}")
raise RambleVariableDefinitionError(f"In workload {namespace}: {e}") from None

self._set_context(self._contexts.workload, workload_context)

Expand All @@ -147,7 +149,7 @@ def set_experiment_context(self, experiment_context, die_on_validate_error=True)
self.keywords.check_reserved_keys(experiment_context.variables)
except ramble.keywords.RambleKeywordError as e:
namespace = f"{self.workload_namespace}.{experiment_context.templates}"
raise RambleVariableDefinitionError(f"In experiment {namespace}: {e}")
raise RambleVariableDefinitionError(f"In experiment {namespace}: {e}") from None

self._set_context(self._contexts.experiment, experiment_context)
self._ingest_experiments(die_on_validate_error=die_on_validate_error)
Expand Down Expand Up @@ -573,7 +575,7 @@ def _ingest_experiments(self, die_on_validate_error=True):
if die_on_validate_error:
raise RambleVariableDefinitionError(
f"In experiment {final_exp_namespace}: {e}"
)
) from None
pass

workload_names.add(app_inst.expander.workload_name)
Expand Down
8 changes: 4 additions & 4 deletions lib/ramble/ramble/fetch_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def _existing_url(self, url):
{}\n with error {}".format(
url, werr
)
raise FailedDownloadError(url, msg)
raise FailedDownloadError(url, msg) from None
return response.getcode() is None or response.getcode() == 200

def _fetch_from_url(self, url):
Expand Down Expand Up @@ -403,7 +403,7 @@ def _fetch_urllib(self, url):
if save_file and os.path.exists(save_file):
os.remove(save_file)
msg = f"urllib failed to fetch with error {e}"
raise FailedDownloadError(url, msg)
raise FailedDownloadError(url, msg) from None

with open(save_file, "wb") as _open_file:
shutil.copyfileobj(response, _open_file)
Expand Down Expand Up @@ -1402,7 +1402,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
except ValueError:
if not kwargs.get("url"):
raise ValueError("S3FetchStrategy requires a url for fetching.")
raise ValueError("S3FetchStrategy requires a url for fetching.") from None

@_needs_stage
def fetch(self):
Expand Down Expand Up @@ -1447,7 +1447,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
except ValueError:
if not kwargs.get("url"):
raise ValueError("GCSFetchStrategy requires a url for fetching.")
raise ValueError("GCSFetchStrategy requires a url for fetching.") from None

@_needs_stage
def fetch(self):
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def walk(self):
exp_name = self._obj_inst.name
raise GraphCycleError(
f"In experiment {exp_name} a cycle was detected "
f"when processing the {self.node_type} graph.\n" + str(e)
)
f"when processing the {self.node_type} graph."
) from e
self._prepared = True

yield from self._sorted
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def render_objects(self, render_group, exclude_where=None, ignore_used=True, fat
var = expander.expand_var(unexpanded_var)
matrix[i] = var
if zips:
for zip_group, group_def in zips.items():
for group_def in zips.values():
for i, unexpanded_var in enumerate(group_def):
group_def[i] = expander.expand_var(unexpanded_var)

Expand Down Expand Up @@ -415,7 +415,7 @@ def render_objects(self, render_group, exclude_where=None, ignore_used=True, fat
if vector_vars:
# Check that sizes are the same
length_mismatch = False
for var, val in vector_vars.items():
for val in vector_vars.values():
if len(val) != max_vector_size:
length_mismatch = True

Expand Down
10 changes: 4 additions & 6 deletions lib/ramble/ramble/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ def get(self, spec):
# handler by wrapping them
if ramble.config.get("config:debug"):
sys.excepthook(*sys.exc_info())
raise FailedConstructorError(spec.fullname, *sys.exc_info())
raise FailedConstructorError(spec.fullname, *sys.exc_info()) from e

@autospec
def dump_provenance(self, spec, path):
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def _get_obj_module(self, obj_name):
# manually construct the error message in order to give the
# user the correct .py where the syntax error is
# located
raise SyntaxError(f"invalid syntax in {file_path}, line {e.lineno}")
raise SyntaxError(f"invalid syntax in {file_path}, line {e.lineno}") from None

module.__object__ = self.full_namespace
module.__loader__ = self
Expand Down Expand Up @@ -1442,9 +1442,7 @@ def create_repo(
else:
shutil.rmtree(root, ignore_errors=True)

raise BadRepoError(
"Failed to create new repository in %s." % root, f"Caused by {type(e)}: {e}"
)
raise BadRepoError("Failed to create new repository in %s." % root) from e

return full_path, namespace

Expand Down Expand Up @@ -1490,7 +1488,7 @@ def __getattr__(self, name):
setattr(self, name, __import__(submodule))
except ImportError:
msg = "'{0}' object has no attribute {1}"
raise AttributeError(msg.format(type(self), name))
raise AttributeError(msg.format(type(self), name)) from None
return getattr(self, name)


Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/software_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def define_compiler_packages(self, environment: RenderedEnvironment, expander: E
cur_compiler = pkg.compiler
# Re-render compiler package to ensure variables are marked as used.
if cur_compiler in self._rendered_packages[pm_name]:
for template_name, template_def in self._package_templates.items():
for template_def in self._package_templates.values():
if cur_compiler in template_def._rendered_packages[pm_name]:
expander.flush_used_variable_stage()
rendered_pkg = template_def.render_package(
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def do_parse(self):
else:
self.next_token_error("Invalid token found")
except spack.parse.ParseError as e:
raise SpecParseError(e)
raise SpecParseError(e) from None

return [app_spec]

Expand Down Expand Up @@ -214,7 +214,7 @@ def write_attribute(spec, attribute, color):
parent = ".".join(parts[:idx])
m = "Attempted to format attribute %s." % attribute
m += f"Spec {parent} has no attribute {part}"
raise SpecFormatStringError(m)
raise SpecFormatStringError(m) from None

if callable(current):
raise SpecFormatStringError("Attempted to format callable object")
Expand Down
10 changes: 5 additions & 5 deletions lib/ramble/ramble/success_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ def flush_scope(self, scope):
"""
self.validate_scope(scope)

for scope in self._flush_scopes[scope]:
logger.debug(f" Flushing scope: {scope}")
for s in self._flush_scopes[scope]:
logger.debug(f" Flushing scope: {s}")
logger.debug(" It contained:")
for crit in self.criteria[scope]:
for crit in self.criteria[s]:
logger.debug(f" {crit.name}")
del self.criteria[scope]
self.criteria[scope] = []
del self.criteria[s]
self.criteria[s] = []

def passed(self):
succeed = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def test_spack_package_manager_provenance_zlib(mock_applications, workspace_name
import json

data = json.load(f)
for data in data["experiments"]:
pkg_list = data["SOFTWARE"]["spack"]
for d in data["experiments"]:
pkg_list = d["SOFTWARE"]["spack"]
names = [pkg["name"] for pkg in pkg_list]
assert "SOFTWARE" in data
assert "spack" in data["SOFTWARE"]
assert "SOFTWARE" in d
assert "spack" in d["SOFTWARE"]
assert "zlib" in names


Expand Down
Loading