From f7fc97d8d58d5ff68fdcc4280d7e290d4a369adf Mon Sep 17 00:00:00 2001 From: Douglas Jacobsen Date: Mon, 14 Oct 2024 15:45:41 -0600 Subject: [PATCH] Remove long_print methods from base object classes --- lib/ramble/ramble/application.py | 79 ------------------- lib/ramble/ramble/modifier.py | 109 --------------------------- lib/ramble/ramble/package_manager.py | 55 -------------- 3 files changed, 243 deletions(-) diff --git a/lib/ramble/ramble/application.py b/lib/ramble/ramble/application.py index 530c48861..646e5f7e1 100644 --- a/lib/ramble/ramble/application.py +++ b/lib/ramble/ramble/application.py @@ -20,7 +20,6 @@ import llnl.util.filesystem as fs import llnl.util.tty.color as color -from llnl.util.tty.colify import colified import spack.util.executable import spack.util.spack_json @@ -304,77 +303,6 @@ def build_phase_order(self): for phase, phase_node in self.package_manager.all_pipeline_phases(pipeline): self._pipeline_graphs[pipeline].define_edges(phase_node, internal_order=True) - def _long_print(self): - out_str = "" - if hasattr(self, "maintainers"): - out_str.append("\n") - out_str.append(rucolor.section_title("Maintainers:\n")) - out_str.append(colified(self.maintainers, tty=True)) - out_str.append("\n") - - if hasattr(self, "tags"): - out_str.append("\n") - out_str.append(rucolor.section_title("Tags:\n")) - out_str.append(colified(self.tags, tty=True)) - out_str.append("\n") - - for pipeline in self._pipelines: - out_str.append("\n") - out_str.append(rucolor.section_title(f'Pipeline "{pipeline}" Phases:\n')) - out_str.append(colified(self.get_pipeline_phases(pipeline), tty=True)) - - # Print all FOMs without a context - if hasattr(self, "figures_of_merit"): - out_str.append("\n") - out_str.append(rucolor.section_title("Figure of merit contexts:\n")) - out_str.append(rucolor.nested_1(f"\t({_NULL_CONTEXT}) context (default):\n")) - for name, conf in self.figures_of_merit.items(): - if len(conf["contexts"]) == 0: - out_str.append(rucolor.nested_2(f"\t\t{name}\n")) - out_str.append(f'\t\t\tunits = {conf["units"]}\n') - out_str.append(f'\t\t\tlog file = {conf["log_file"]}\n') - - if hasattr(self, "figure_of_merit_contexts"): - for context_name, context_conf in self.figure_of_merit_contexts.items(): - out_str.append(rucolor.nested_1(f"\t{context_name} context:\n")) - for name, conf in self.figures_of_merit.items(): - if context_name in conf["contexts"]: - out_str.append(rucolor.nested_2(f"\t\t{name}\n")) - out_str.append(f'\t\t\tunits = {conf["units"]}\n') - out_str.append(f'\t\t\tlog file = {conf["log_file"]}\n') - - if hasattr(self, "workloads"): - out_str.append("\n") - for workload in self.workloads.values(): - out_str.append(workload.as_str()) - out_str.append("\n") - - if hasattr(self, "builtins"): - out_str.append(rucolor.section_title("Builtin Executables:\n")) - out_str.append("\t" + colified(self.builtins.keys(), tty=True) + "\n") - - if hasattr(self, "package_manager_configs"): - out_str.append("\n") - out_str.append(rucolor.section_title("Package Manager Configs:\n")) - for name, config in self.package_manager_configs.items(): - out_str.append(f"\t{name} = {config}\n") - - spec_groups = [ - ("compilers", "Compilers"), - ("software_specs", "Software Specs"), - ] - for group in spec_groups: - if hasattr(self, group[0]): - out_str.append("\n") - out_str.append(rucolor.section_title("%s:\n" % group[1])) - for name, info in getattr(self, group[0]).items(): - out_str.append(rucolor.nested_1(" %s:\n" % name)) - for key, val in info.items(): - if val: - out_str.append(" {} = {}\n".format(key, val.replace("@", "@@"))) - - return out_str - def set_env_variable_sets(self, env_variable_sets): """Set internal reference to environment variable sets""" @@ -491,14 +419,7 @@ def get_pipeline_phases(self, pipeline, phase_filters=["*"]): phase_order.append(node.key) return phase_order - def _short_print(self): - return [self.name] - def __str__(self): - if self._verbosity == "long": - return "".join(self._long_print()) - elif self._verbosity == "short": - return "".join(self._short_print()) return self.name def print_vars(self, header="", vars_to_print=None, indent=""): diff --git a/lib/ramble/ramble/modifier.py b/lib/ramble/ramble/modifier.py index 1a5464e8d..563f6c09f 100644 --- a/lib/ramble/ramble/modifier.py +++ b/lib/ramble/ramble/modifier.py @@ -13,12 +13,9 @@ import fnmatch from typing import List -from llnl.util.tty.colify import colified - from ramble.language.modifier_language import ModifierMeta from ramble.language.shared_language import SharedMeta from ramble.error import RambleError -import ramble.util.colors as rucolor import ramble.util.directives import ramble.util.class_attributes from ramble.util.logger import logger @@ -121,113 +118,7 @@ def modify_experiment(self, app): """ pass - def _long_print(self): - out_str = [] - out_str.append(rucolor.section_title("Modifier: ") + f"{self.name}\n") - out_str.append("\n") - - out_str.append(rucolor.section_title("Description:\n")) - if self.__doc__: - out_str.append(f"\t{self.__doc__}\n") - else: - out_str.append("\tNone\n") - - if hasattr(self, "tags"): - out_str.append("\n") - out_str.append(rucolor.section_title("Tags:\n")) - out_str.append(colified(self.tags, tty=True)) - out_str.append("\n") - - if hasattr(self, "modes"): - out_str.append("\n") - for mode_name, wl_conf in self.modes.items(): - out_str.append(rucolor.section_title("Mode:") + f" {mode_name}\n") - - if mode_name in self.modifier_variables: - out_str.append(rucolor.nested_1("\tVariables:\n")) - indent = "\t\t" - for var, conf in self.modifier_variables[mode_name].items(): - out_str.append(rucolor.nested_2(f"{indent}{var}:\n")) - out_str.append(f"{indent}\tDescription: {conf.description}\n") - out_str.append(f"{indent}\tDefault: {conf.default}\n") - if conf.values: - out_str.append(f"{indent}\tSuggested Values: {conf.values}\n") - - if mode_name in self.variable_modifications: - out_str.append(rucolor.nested_1("\tVariable Modifications:\n")) - indent = "\t\t" - for var, conf in self.variable_modifications[mode_name].items(): - out_str.append(rucolor.nested_2(f"{indent}{var}:\n")) - out_str.append(f'{indent}\tMethod: {conf["method"]}\n') - out_str.append(f'{indent}\tModification: {conf["modification"]}\n') - - out_str.append("\n") - - if hasattr(self, "builtins"): - out_str.append(rucolor.section_title("Builtin Executables:\n")) - out_str.append("\t" + colified(self.builtins.keys(), tty=True) + "\n") - - if hasattr(self, "executable_modifiers"): - out_str.append(rucolor.section_title("Executable Modifiers:\n")) - out_str.append("\t" + colified(self.executable_modifiers.keys(), tty=True) + "\n") - - if hasattr(self, "package_manager_configs"): - out_str.append(rucolor.section_title("Package Manager Configs:\n")) - for name, config in self.package_manager_configs.items(): - out_str.append(f"\t{name} = {config}\n") - out_str.append("\n") - - if hasattr(self, "compilers"): - out_str.append(rucolor.section_title("Default Compilers:\n")) - for comp_name, comp_def in self.compilers.items(): - out_str.append(rucolor.nested_2(f"\t{comp_name}:\n")) - out_str.append( - rucolor.nested_3("\t\tSpack Spec:") - + f'{comp_def["pkg_spec"].replace("@", "@@")}\n' - ) - - if "compiler_spec" in comp_def and comp_def["compiler_spec"]: - out_str.append( - rucolor.nested_3("\t\tCompiler Spec:\n") - + f'{comp_def["compiler_spec"].replace("@", "@@")}\n' - ) - - if "compiler" in comp_def and comp_def["compiler"]: - out_str.append( - rucolor.nested_3("\t\tCompiler:\n") + f'{comp_def["compiler"]}\n' - ) - out_str.append("\n") - - if hasattr(self, "software_specs"): - out_str.append(rucolor.section_title("Software Specs:\n")) - for spec_name, spec_def in self.software_specs.items(): - - out_str.append(rucolor.nested_2(f"\t{spec_name}:\n")) - out_str.append( - rucolor.nested_3("\t\tSpack Spec:") - + f'{spec_def["pkg_spec"].replace("@", "@@")}\n' - ) - - if "compiler_spec" in spec_def and spec_def["compiler_spec"]: - out_str.append( - rucolor.nested_3("\t\tCompiler Spec:") - + f'{spec_def["compiler_spec"].replace("@", "@@")}\n' - ) - - if "compiler" in spec_def and spec_def["compiler"]: - out_str.append(rucolor.nested_3("\t\tCompiler:") + f'{spec_def["compiler"]}\n') - out_str.append("\n") - - return out_str - - def _short_print(self): - return [self.name] - def __str__(self): - if self._verbosity == "long": - return "".join(self._long_print()) - elif self._verbosity == "short": - return "".join(self._short_print()) return self.name def format_doc(self, **kwargs): diff --git a/lib/ramble/ramble/package_manager.py b/lib/ramble/ramble/package_manager.py index 885c58d1a..2309f1fc1 100644 --- a/lib/ramble/ramble/package_manager.py +++ b/lib/ramble/ramble/package_manager.py @@ -13,12 +13,9 @@ import textwrap from typing import List -from llnl.util.tty.colify import colified - from ramble.language.package_manager_language import PackageManagerMeta from ramble.language.shared_language import SharedMeta from ramble.error import RambleError -import ramble.util.colors as rucolor import ramble.util.directives import ramble.util.class_attributes from ramble.util.naming import NS_SEPARATOR @@ -108,59 +105,7 @@ def spec_prefix(self): prefix = self._spec_prefix or self.name return spack.util.naming.spack_module_to_python_module(prefix) - def _long_print(self): - out_str = [] - out_str.append(rucolor.section_title("Package Manager: ") + f"{self.name}\n") - out_str.append("\n") - - simplified_name = spack.util.naming.spack_module_to_python_module(self.name) - out_str.append(rucolor.section_title("Spec prefix: ") + f"{simplified_name}\n") - out_str.append("\n") - - out_str.append(rucolor.section_title("Description:\n")) - if self.__doc__: - out_str.append(f"\t{self.__doc__}\n") - else: - out_str.append("\tNone\n") - - if hasattr(self, "tags"): - out_str.append("\n") - out_str.append(rucolor.section_title("Tags:\n")) - out_str.append(colified(self.tags, tty=True)) - out_str.append("\n") - - if hasattr(self, "builtins"): - out_str.append(rucolor.section_title("Builtin Executables:\n")) - out_str.append("\t" + colified(self.builtins.keys(), tty=True) + "\n") - - if hasattr(self, "package_manager_configs"): - out_str.append("\n") - out_str.append(rucolor.section_title("Package Manager Configs:\n")) - for name, config in self.package_manager_configs.items(): - out_str.append(f"\t{name} = {config}\n") - - for group in self._spec_groups: - if hasattr(self, group[0]): - out_str.append("\n") - out_str.append(rucolor.section_title("%s:\n" % group[1])) - for name, info in getattr(self, group[0]).items(): - out_str.append(rucolor.nested_1(" %s:\n" % name)) - for key in self._spec_keys: - if key in info and info[key]: - out_str.append( - " {} = {}\n".format(key, info[key].replace("@", "@@")) - ) - - return out_str - - def _short_print(self): - return [self.name] - def __str__(self): - if self._verbosity == "long": - return "".join(self._long_print()) - elif self._verbosity == "short": - return "".join(self._short_print()) return self.name def format_doc(self, **kwargs):