diff --git a/lib/ramble/ramble/keywords.py b/lib/ramble/ramble/keywords.py index 2b86437ce..0eb7bcb5e 100644 --- a/lib/ramble/ramble/keywords.py +++ b/lib/ramble/ramble/keywords.py @@ -7,14 +7,24 @@ # except according to those terms. import re -from enum import Enum +from enum import Enum, auto import ramble.error from ramble.repository import type_definitions from ramble.util.logger import logger -key_type = Enum("key_type", ["reserved", "optional", "required"]) -output_level = Enum("output_level", ["key", "variable"]) + +class key_type(Enum): + reserved = auto() + optional = auto() + required = auto() + + +class output_level(Enum): + key = auto() + variable = auto() + + default_keys = { "workspace_name": {"type": key_type.reserved, "level": output_level.variable}, "workspace": {"type": key_type.reserved, "level": output_level.variable}, @@ -105,58 +115,10 @@ class Keywords: specific inputs to further configure the experiment. """ - workspace_name: str - workspace: str - workspace_root: str - workspace_configs: str - workspace_software: str - workspace_logs: str - workspace_inputs: str - workspace_experiments: str - workspace_shared: str - workspace_archives: str - workspace_deployments: str - application_name: str - application_spec: str - application_run_dir: str - application_input_dir: str - application_namespace: str - application_version: str - simplified_application_namespace: str - workload_name: str - workload_run_dir: str - workload_input_dir: str - workload_namespace: str - simplified_workload_namespace: str - workload_group: str - license_input_dir: str - experiments_file: str - experiment_name: str - experiment_hash: str - experiment_run_dir: str - experiment_status: str - RAMBLE_STATUS: str - experiment_index: str - experiment_namespace: str - simplified_experiment_namespace: str - log_dir: str - log_file: str - err_file: str - env_path: str - input_name: str - repeat_index: str - spec_name: str - env_name: str - n_ranks: str - n_nodes: str - processes_per_node: str - n_threads: str - batch_submit: str - mpi_command: str - workload_template_name: str - experiment_template_name: str - unformatted_command: str - unformatted_command_without_logs: str + # Keyword attributes are set dynamically in update_keys(). This is only + # reached for unknown attributes, and tells type checkers keywords are str. + def __getattr__(self, name: str) -> str: + raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") def __init__(self, extra_keys=None): # Merge in additional Keys: diff --git a/lib/ramble/ramble/results_table.py b/lib/ramble/ramble/results_table.py index 1be0877a4..8c6320c2b 100644 --- a/lib/ramble/ramble/results_table.py +++ b/lib/ramble/ramble/results_table.py @@ -9,6 +9,7 @@ import copy import os +from ramble.namespace import namespace from ramble.util.file_util import create_symlink from ramble.util.logger import logger from ramble.util.module_utils import import_pandas @@ -18,7 +19,7 @@ class ResultsColumn: """Class representing a single column in a results table""" - _where_name = "where" + _where_name = namespace.where _column_attrs = [ "name", "expression", diff --git a/lib/ramble/ramble/variants.py b/lib/ramble/ramble/variants.py index 76b95bf05..f80c20e67 100644 --- a/lib/ramble/ramble/variants.py +++ b/lib/ramble/ramble/variants.py @@ -8,38 +8,44 @@ import functools from collections.abc import Sequence -from enum import Enum +from enum import Enum, auto from typing import Any, Callable, Dict, Optional, Union import ramble.error import ramble.util.colors as color from ramble.expander import Expander +from ramble.keywords import keywords +from ramble.namespace import namespace from spack.util.spack_yaml import syaml_bool reserved_variants = { "modifier", - "package_manager", + namespace.package_manager, "package_manager_prefix", - "system", - "platform", - "version", - "workflow_manager", - "workload_group", - "is_repeat_child", - "is_repeat_parent", - "repeat_index", + namespace.system, + namespace.platform, + namespace.version, + namespace.workflow_manager, + keywords.workload_group, + keywords.is_repeat_child, + keywords.is_repeat_parent, + keywords.repeat_index, } standard_variants: Dict[str, Dict[str, Any]] = { - "containerized": { + namespace.containerized: { "default": False, "values": (True, False), "description": "Whether this experiment is run inside a container", }, } -variant_types = Enum("variant_types", ["default", "experiment", "version"]) + +class variant_types(Enum): + default = auto() + experiment = auto() + version = auto() def invalidates_cache(func):