Skip to content

Commit

Permalink
Clean up unused variables
Browse files Browse the repository at this point in the history
```
pylint --disable=all --enable=W0612 lib/ramble/ramble/*
```
  • Loading branch information
linsword13 committed Jan 30, 2025
1 parent 0d2c915 commit 5ef4ac3
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 51 deletions.
16 changes: 8 additions & 8 deletions lib/ramble/ramble/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,22 @@ def build_phase_order(self):

for mod_inst in self._modifier_instances:
# Define phase nodes
for phase, phase_node in mod_inst.all_pipeline_phases(pipeline):
for _, phase_node in mod_inst.all_pipeline_phases(pipeline):
self._pipeline_graphs[pipeline].add_node(phase_node, obj_inst=mod_inst)

# Define phase edges
for phase, phase_node in mod_inst.all_pipeline_phases(pipeline):
for _, phase_node in mod_inst.all_pipeline_phases(pipeline):
self._pipeline_graphs[pipeline].define_edges(phase_node, internal_order=True)

if self.package_manager:
# Define phase nodes
for phase, phase_node in self.package_manager.all_pipeline_phases(pipeline):
for _, phase_node in self.package_manager.all_pipeline_phases(pipeline):
self._pipeline_graphs[pipeline].add_node(
phase_node, obj_inst=self.package_manager
)

# Define phase edges
for phase, phase_node in self.package_manager.all_pipeline_phases(pipeline):
for _, phase_node in self.package_manager.all_pipeline_phases(pipeline):
self._pipeline_graphs[pipeline].define_edges(phase_node, internal_order=True)

def set_env_variable_sets(self, env_variable_sets):
Expand All @@ -369,7 +369,7 @@ def set_variables(self, variables, experiment_set):
self.no_expand_vars = set()
workload_name = self.expander.workload_name
if workload_name in self.workloads:
for name, var in self.workloads[workload_name].variables.items():
for var in self.workloads[workload_name].variables.values():
if not var.expandable:
self.no_expand_vars.add(var.name)

Expand Down Expand Up @@ -1000,7 +1000,7 @@ def _set_default_experiment_variables(self):
workload = self.workloads[self.expander.workload_name]

new_env_vars = {}
for name, env_var in workload.environment_variables.items():
for env_var in workload.environment_variables.values():
action = "set"
value = env_var.value

Expand Down Expand Up @@ -1504,7 +1504,7 @@ def populate_inventory(self, workspace, force_compute=False, require_exist=False
# Build inventory of inputs
self._inputs_and_fetchers(self.expander.workload_name)

for input_file, input_conf in self._input_fetchers.items():
for input_conf in self._input_fetchers.values():
if input_conf["fetcher"].digest:
self.hash_inventory["inputs"].append(
{"name": input_conf["input_name"], "digest": input_conf["fetcher"].digest}
Expand Down Expand Up @@ -1587,7 +1587,7 @@ def _archive_experiments(self, workspace, app_inst=None):
# Copy all figure of merit files
criteria_list = workspace.success_list
analysis_files, _, _ = self._analysis_dicts(criteria_list)
for file, file_conf in analysis_files.items():
for file in analysis_files.keys():
if os.path.exists(file):
shutil.copy(file, archive_experiment_dir)

Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/cmd/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def update_completion(parser, args):
times, and to simplify completion update for developers.
"""
for shell, shell_args in update_completion_args.items():
for shell_args in update_completion_args.values():
for attr, value in shell_args.items():
setattr(args, attr, value)
_commands(parser, args)
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/cmd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def config_add(args):
setup_parser.add_parser.print_help()
exit(1)

scope, section = _get_scope_and_section(args)
scope, _ = _get_scope_and_section(args)

if args.file:
ramble.config.add_from_file(args.file, scope=scope)
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/cmd/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _all_ramble_files(root=ramble.paths.prefix, modified_only=False):
yield from _get_modified_files(root)
else:
visited = set()
for cur_root, folders, files in os.walk(root):
for cur_root, _, files in os.walk(root):
for filename in files:
path = os.path.realpath(os.path.join(cur_root, filename))

Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def push_scope(self, scope):
@_config_mutator
def pop_scope(self):
"""Remove the highest precedence scope and return it."""
name, scope = self.scopes.popitem(last=True)
_, scope = self.scopes.popitem(last=True)
return scope

@_config_mutator
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/fetch_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def _existing_url(self, url):
else:
# Telling urllib to check if url is accessible
try:
url, headers, response = ramble.util.web.read_from_url(url)
url, _, response = ramble.util.web.read_from_url(url)
except ramble.util.web.SpackWebError as werr:
msg = "Urllib fetch failed to verify url\
{}\n with error {}".format(
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def _main(argv=None):
# them, which reduces startup latency.
parser = make_argument_parser()
parser.add_argument("command", nargs=argparse.REMAINDER)
args, unknown = parser.parse_known_args(argv)
args, _ = parser.parse_known_args(argv)

# Recover stored LD_LIBRARY_PATH variables from ramble shell function
# This is necessary because MacOS System Integrity Protection clears
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def package_manager_dir(self, workspace):
def environment_required(self):
app_inst = self.app_inst
if hasattr(app_inst, "software_specs"):
for pkg, info in app_inst.software_specs.items():
for info in app_inst.software_specs.values():
if fnmatch.fnmatch(self.name, info["package_manager"]):
return True

Expand Down
14 changes: 7 additions & 7 deletions lib/ramble/ramble/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _construct_experiment_hashes(self):
Populate the workspace inventory information with experiment hash data.
"""
for exp, app_inst, _ in self._experiment_set.all_experiments():
for _, app_inst, _ in self._experiment_set.all_experiments():
app_inst.populate_inventory(
self.workspace,
force_compute=self.force_inventory,
Expand Down Expand Up @@ -378,7 +378,7 @@ def _prepare(self):
excluded_secrets.add(ramble.application.ApplicationBase.license_inc_name)

fs.mkdirp(archive_shared)
for root, dirs, files in os.walk(self.workspace.shared_dir):
for root, _, files in os.walk(self.workspace.shared_dir):
for name in files:
if name not in excluded_secrets:
src_dir = os.path.join(self.workspace.shared_dir, root)
Expand All @@ -392,7 +392,7 @@ def _prepare(self):
self.workspace.latest_archive_path, ramble.workspace.workspace_log_path
)
fs.mkdirp(archive_logs)
for root, dirs, files in os.walk(self.workspace.log_dir):
for root, _, files in os.walk(self.workspace.log_dir):
for name in files:
src_dir = os.path.join(self.workspace.log_dir, root)
src = os.path.join(src_dir, name)
Expand Down Expand Up @@ -561,7 +561,7 @@ def _execute(self):
if not self.suppress_run_header:
logger.all_msg("Running executors...")

for exp, app_inst, idx in self._experiment_set.filtered_experiments(self.filters):
for _, app_inst, _ in self._experiment_set.filtered_experiments(self.filters):
if app_inst.is_template:
logger.debug(f"{app_inst.name} is a template. Skipping execution.")
continue
Expand Down Expand Up @@ -617,7 +617,7 @@ def print_archive_files(app_inst, pattern_title, patterns):
if not self.suppress_run_header:
logger.all_msg("Finding log information...")

for exp, app_inst, idx in self._experiment_set.filtered_experiments(self.filters):
for exp, app_inst, _ in self._experiment_set.filtered_experiments(self.filters):
if app_inst.is_template:
continue
if app_inst.repeats.is_repeat_base:
Expand Down Expand Up @@ -706,7 +706,7 @@ def _execute(self):

def _deployment_files(self):
"""Yield the full path to each file in a deployment"""
for root, dirs, files in os.walk(self.workspace.named_deployment):
for root, _, files in os.walk(self.workspace.named_deployment):
for name in files:
yield os.path.join(self.workspace.named_deployment, root, name)

Expand Down Expand Up @@ -752,7 +752,7 @@ def _complete(self):

def _copy_tree(src_dir, dest_dir):
"""Copy all files in src_dir to dest_dir"""
for root, dirs, files in os.walk(src_dir):
for root, _, files in os.walk(src_dir):
for name in files:
src = os.path.join(src_dir, root, name)
dest = src.replace(src_dir, dest_dir)
Expand Down
6 changes: 3 additions & 3 deletions lib/ramble/ramble/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def draw(self, perf_measure, scale_var, series, pdf_report, y_label=None):
marker="o",
label=f"{perf_measure}",
)
ymin, ymax = ax.get_ylim()
_, ymax = ax.get_ylim()

# TODO: the plot can get very compressed for log weak scaling plots
if not self.logy:
Expand Down Expand Up @@ -812,7 +812,7 @@ def draw_multiline(self, perf_measure, scale_var, pdf_report, y_label):
alpha=0.2,
)

ymin, ymax = ax.get_ylim()
_, ymax = ax.get_ylim()

# TODO: the plot can get very compressed for log weak scaling plots
if not self.logy:
Expand All @@ -835,7 +835,7 @@ def draw_multiline(self, perf_measure, scale_var, pdf_report, y_label):
def generate_plot_data(self, pdf_report):
super().generate_plot_data(pdf_report)

perf_measure, scale_var, *additional_vars = self.spec
perf_measure, scale_var, *_ = self.spec
y_label = perf_measure

self.draw_multiline(perf_measure, scale_var, pdf_report, y_label)
Expand Down
8 changes: 4 additions & 4 deletions lib/ramble/ramble/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def find_module(self, fullname, path=None):
"""
# namespaces are added to repo, and object modules are leaves.
namespace, dot, module_name = fullname.rpartition(".")
namespace, _, module_name = fullname.rpartition(".")

# If it's a module in some repo, or if it is the repo's
# namespace, let the repo handle it.
Expand Down Expand Up @@ -1061,7 +1061,7 @@ def find_module(self, fullname, path=None):
if self.is_prefix(fullname):
return self

namespace, dot, module_name = fullname.rpartition(".")
namespace, _, module_name = fullname.rpartition(".")
if namespace == self.full_namespace:
if self.real_name(module_name):
return self
Expand All @@ -1076,7 +1076,7 @@ def load_module(self, fullname):
if fullname in sys.modules:
return sys.modules[fullname]

namespace, dot, module_name = fullname.rpartition(".")
namespace, _, module_name = fullname.rpartition(".")

if self.is_prefix(fullname):
module = ObjectNamespace(fullname)
Expand Down Expand Up @@ -1528,7 +1528,7 @@ def find_spec(self, fullname, python_path, target=None):

def compute_loader(self, fullname):
# namespaces are added to repo, and object modules are leaves.
namespace, dot, module_name = fullname.rpartition(".")
namespace, _, module_name = fullname.rpartition(".")

# If it's a module in some repo, or if it is the repo's
# namespace, let the repo handle it.
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(self, spec_like=None):
self.workloads = {}

if isinstance(spec_like, str):
namespace, dot, spec_name = spec_like.rpartition(".")
namespace, _, spec_name = spec_like.rpartition(".")
if not namespace:
namespace = None
self.name = spec_name
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/test/application_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_required_builtins(mutable_mock_apps_repo, app):
if conf[app_inst._builtin_required_key]:
required_builtins.append(builtin)

for workload, wl_conf in app_inst.workloads.items():
for workload in app_inst.workloads.keys():
exec_graph = app_inst._get_executable_graph(workload)
for builtin in required_builtins:
assert exec_graph.get_node(builtin) is not None
Expand All @@ -181,7 +181,7 @@ def test_register_builtin_app(mutable_mock_apps_repo):
else:
excluded_builtins.append(builtin)

for workload, wl_conf in app_inst.workloads.items():
for workload in app_inst.workloads.keys():
exec_graph = app_inst._get_executable_graph(workload)

for builtin in required_builtins:
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/ramble/test/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def check_basic(ws):
for workloads, application_context in ws.all_applications():
if application_context.context_name == "basic":
found_basic = True
for experiments, workload_context in ws.all_workloads(workloads):
for _, workload_context in ws.all_workloads(workloads):
if workload_context.context_name == "test_wl":
found_test_wl = True
elif workload_context.context_name == "test_wl2":
Expand All @@ -88,7 +88,7 @@ def check_no_basic(ws):
for workloads, application_context in ws.all_applications():
if application_context.context_name == "basic":
found_basic = True
for experiments, workload_context in ws.all_workloads(workloads):
for _, workload_context in ws.all_workloads(workloads):
if workload_context.context_name == "test_wl":
found_test_wl = True
elif workload_context.context_name == "test_wl2":
Expand Down
4 changes: 1 addition & 3 deletions lib/ramble/ramble/test/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,7 @@ def test_composite_stage_with_noexpand_resource(
@pytest.mark.disable_clean_stage_check
def test_composite_stage_with_expand_resource(self, composite_stage_with_expanding_resource):

composite_stage, root_stage, resource_stage, mock_resource = (
composite_stage_with_expanding_resource
)
composite_stage, root_stage, _, mock_resource = composite_stage_with_expanding_resource

composite_stage.create()
composite_stage.fetch()
Expand Down
6 changes: 3 additions & 3 deletions lib/ramble/ramble/util/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def all_msg(self, *args, **kwargs):
print). Perform this action for all logs and the default log (to
screen).
"""
for idx, log in enumerate(self.log_stack):
for idx, _ in enumerate(self.log_stack):
st_kwargs = self._stream_kwargs(default_kwargs=kwargs, index=idx)
with self.configure_colors(**st_kwargs):
tty.info(*args, **st_kwargs)
Expand Down Expand Up @@ -203,7 +203,7 @@ def error(self, *args, **kwargs):
print). Perform this action all logs, and the default stream (print to
screen).
"""
for idx, log in enumerate(self.log_stack):
for idx, _ in enumerate(self.log_stack):
st_kwargs = self._stream_kwargs(index=idx, default_kwargs=kwargs)
with self.configure_colors(**st_kwargs):
tty.error(*args, **st_kwargs)
Expand All @@ -217,7 +217,7 @@ def die(self, *args, **kwargs):
print). Perform this action all logs. After all logs are printed to,
terminate execution (and error) using tty.die.
"""
for idx, log in enumerate(self.log_stack):
for idx, _ in enumerate(self.log_stack):
st_kwargs = self._stream_kwargs(index=idx, default_kwargs=kwargs)
with self.configure_colors(**st_kwargs):
tty.error(*args, **st_kwargs)
Expand Down
10 changes: 5 additions & 5 deletions lib/ramble/ramble/util/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __init__(self, separator="."):
self._sep = separator

def __setitem__(self, namespace, value):
first, sep, rest = namespace.partition(self._sep)
first, _, rest = namespace.partition(self._sep)

if not first:
self._value = NamespaceTrie.Element(value)
Expand All @@ -207,7 +207,7 @@ def __setitem__(self, namespace, value):
self._subspaces[first][rest] = value

def _get_helper(self, namespace, full_name):
first, sep, rest = namespace.partition(self._sep)
first, _, rest = namespace.partition(self._sep)
if not first:
if not self._value:
raise KeyError("Can't find namespace '%s' in trie" % full_name)
Expand All @@ -223,7 +223,7 @@ def __getitem__(self, namespace):
def is_prefix(self, namespace):
"""True if the namespace has a value, or if it's the prefix of one that
does."""
first, sep, rest = namespace.partition(self._sep)
first, _, rest = namespace.partition(self._sep)
if not first:
return True
elif first not in self._subspaces:
Expand All @@ -233,7 +233,7 @@ def is_prefix(self, namespace):

def is_leaf(self, namespace):
"""True if this namespace has no children in the trie."""
first, sep, rest = namespace.partition(self._sep)
first, _, rest = namespace.partition(self._sep)
if not first:
return bool(self._subspaces)
elif first not in self._subspaces:
Expand All @@ -243,7 +243,7 @@ def is_leaf(self, namespace):

def has_value(self, namespace):
"""True if there is a value set for the given namespace."""
first, sep, rest = namespace.partition(self._sep)
first, _, rest = namespace.partition(self._sep)
if not first:
return self._value is not None
elif first not in self._subspaces:
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/util/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def find_versions_of_archive(
list_urls |= additional_list_urls

# Grab some web pages to scrape.
pages, links = spider(list_urls, depth=list_depth, concurrency=concurrency)
_, links = spider(list_urls, depth=list_depth, concurrency=concurrency)

# Scrape them for archive URLs
regexes = []
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/util/yaml_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def apply_default_config_values(config_data, app_inst, default_config_string):
workload = app_inst.workloads[app_inst.expander.workload_name]

# Set all '{default_config_value}' values to value from the base config
for var_name, var_def in workload.variables.items():
for var_name in workload.variables.keys():
if len(var_name.split(".")) > 1:
var_val = app_inst.expander.expand_var(app_inst.expander.expansion_str(var_name))

Expand Down
Loading

0 comments on commit 5ef4ac3

Please sign in to comment.