Skip to content

Commit 02068ad

Browse files
Merge pull request #1286 from linsword13/more-typing
Extend type-checking to all lib/ramble/ramble/
2 parents 12c65db + c4bd613 commit 02068ad

20 files changed

+151
-62
lines changed

lib/ramble/ramble/cmd/common/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ramble.definitions.variables import Variable
1919
from ramble.util.logger import logger
2020

21-
supported_formats = enum.Enum("formats", ["text", "lists"])
21+
supported_formats = enum.Enum("supported_formats", ["text", "lists"])
2222

2323
obj_attribute_map = {
2424
"maintainers": None,

lib/ramble/ramble/cmd/software_definitions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# except according to those terms.
88

99
import sys
10+
from typing import Dict, List
1011

1112
import llnl.util.tty.color as color
1213
from llnl.util.tty.colify import colify
@@ -22,7 +23,7 @@
2223
definitions = {}
2324
conflicts = {}
2425
used_by = {}
25-
specs = {"pkg_spec": {}, "compiler_spec": {}}
26+
specs: Dict[str, Dict[str, List[str]]] = {"pkg_spec": {}, "compiler_spec": {}}
2627
spec_headers = {
2728
"pkg_spec": "Software Packages",
2829
"compiler_spec": "Compiler Definitions",

lib/ramble/ramble/cmd/workspace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import sys
1313
import tempfile
14+
from typing import Callable, Dict
1415

1516
import llnl.util.tty as tty
1617
import llnl.util.tty.color as color
@@ -1770,7 +1771,7 @@ def workspace(parser, args, unknown_args):
17701771
action(args)
17711772

17721773

1773-
manage_subcommand_functions = {}
1774+
manage_subcommand_functions: Dict[str, Callable] = {}
17741775

17751776

17761777
def workspace_manage(args):

lib/ramble/ramble/expander.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717
import warnings
1818
from contextlib import contextmanager
19-
from typing import Dict, FrozenSet, List, Union
19+
from typing import Dict, FrozenSet, List, Optional, Union
2020

2121
import ramble.error
2222
import ramble.keywords
@@ -598,11 +598,11 @@ def expand_lists(self, var):
598598
def expand_var_name(
599599
self,
600600
var_name: str,
601-
extra_vars: Dict = None,
601+
extra_vars: Optional[Dict] = None,
602602
allow_passthrough: bool = True,
603603
typed: bool = False,
604604
merge_used_stage: bool = True,
605-
replace_escaped_braces: bool = None,
605+
replace_escaped_braces: Optional[bool] = None,
606606
):
607607
"""Convert a variable name to an expansion string, and expand it
608608
@@ -633,11 +633,11 @@ def expand_var_name(
633633
def expand_var(
634634
self,
635635
var: str,
636-
extra_vars: Dict = None,
636+
extra_vars: Optional[Dict] = None,
637637
allow_passthrough: bool = True,
638638
typed: bool = False,
639639
merge_used_stage: bool = True,
640-
replace_escaped_braces=None,
640+
replace_escaped_braces: Optional[bool] = None,
641641
):
642642
"""Perform expansion of a string
643643

lib/ramble/ramble/experiment_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ExperimentSet:
3737

3838
# In order of lowest to highest precedence
3939
_contexts = Enum(
40-
"contexts",
40+
"_contexts",
4141
["global_conf", "base", "workspace", "application", "workload", "experiment", "required"],
4242
)
4343

lib/ramble/ramble/fetch_strategy.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import shutil
3434
import sys
3535
import urllib.parse
36+
from typing import List, Optional
3637

3738
import llnl.util.tty as tty
3839
from llnl.util.filesystem import (
@@ -105,12 +106,13 @@ class FetchStrategy:
105106
#: The URL attribute must be specified either at the package class
106107
#: level, or as a keyword argument to ``version()``. It is used to
107108
#: distinguish fetchers for different versions in the package DSL.
108-
url_attr = None
109+
url_attr: Optional[str] = None
109110

110111
#: Optional attributes can be used to distinguish fetchers when :
111112
#: classes have multiple ``url_attrs`` at the top-level.
112113
# optional attributes in version() args.
113-
optional_attrs = []
114+
optional_attrs: List[str] = []
115+
url: Optional[str] = None
114116

115117
def __init__(self, **kwargs):
116118
# The stage is initialized late, so that fetch strategies can be
@@ -681,6 +683,11 @@ class VCSFetchStrategy(FetchStrategy):
681683
682684
"""
683685

686+
branch: Optional[str] = None
687+
tag: Optional[str] = None
688+
commit: Optional[str] = None
689+
revision: Optional[str] = None
690+
684691
def __init__(self, **kwargs):
685692
super().__init__(**kwargs)
686693

@@ -836,6 +843,10 @@ class GitFetchStrategy(VCSFetchStrategy):
836843

837844
git_version_re = r"git version (\S+)"
838845

846+
submodules: bool = False
847+
submodules_delete: bool = False
848+
get_full_repo: bool = False
849+
839850
def __init__(self, **kwargs):
840851
# Discards the keywords in kwargs that may conflict with the next call
841852
# to __init__

lib/ramble/ramble/graphs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import itertools
1212
import re
1313
from collections import defaultdict
14+
from typing import DefaultDict
1415

1516
import ramble.error
1617
import ramble.expander
@@ -462,7 +463,7 @@ class FormattedExecutableGraph(AttributeGraph):
462463
def __init__(self, formatted_execs: dict, obj_inst):
463464
"""Constructs a new FormattedExecutableGraph and evaluates dependencies"""
464465
super().__init__(obj_inst)
465-
self._formatted_executable_dependencies = defaultdict(list)
466+
self._formatted_executable_dependencies: DefaultDict[str, list] = defaultdict(list)
466467

467468
# Define all graph nodes
468469
for exec_name, exec_def in formatted_execs.items():

lib/ramble/ramble/keywords.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import ramble.error
1212
from ramble.util.logger import logger
1313

14-
key_type = Enum("type", ["reserved", "optional", "required"])
15-
output_level = Enum("level", ["key", "variable"])
14+
key_type = Enum("key_type", ["reserved", "optional", "required"])
15+
output_level = Enum("output_level", ["key", "variable"])
1616
default_keys = {
1717
"workspace_name": {"type": key_type.reserved, "level": output_level.variable},
1818
"workspace": {"type": key_type.reserved, "level": output_level.variable},
@@ -96,6 +96,56 @@ class Keywords:
9696
specific inputs to further configure the experiment.
9797
"""
9898

99+
workspace_name: str
100+
workspace: str
101+
workspace_root: str
102+
workspace_configs: str
103+
workspace_software: str
104+
workspace_logs: str
105+
workspace_inputs: str
106+
workspace_experiments: str
107+
workspace_shared: str
108+
workspace_archives: str
109+
workspace_deployments: str
110+
application_name: str
111+
application_run_dir: str
112+
application_input_dir: str
113+
application_namespace: str
114+
simplified_application_namespace: str
115+
workload_name: str
116+
workload_run_dir: str
117+
workload_input_dir: str
118+
workload_namespace: str
119+
simplified_workload_namespace: str
120+
license_input_dir: str
121+
experiments_file: str
122+
experiment_name: str
123+
experiment_hash: str
124+
experiment_run_dir: str
125+
experiment_status: str
126+
RAMBLE_STATUS: str
127+
experiment_index: str
128+
experiment_namespace: str
129+
simplified_experiment_namespace: str
130+
log_dir: str
131+
log_file: str
132+
err_file: str
133+
env_path: str
134+
input_name: str
135+
repeat_index: str
136+
spec_name: str
137+
env_name: str
138+
n_ranks: str
139+
n_nodes: str
140+
processes_per_node: str
141+
n_threads: str
142+
batch_submit: str
143+
mpi_command: str
144+
workload_template_name: str
145+
experiment_template_name: str
146+
unformatted_command: str
147+
unformatted_command_without_logs: str
148+
99149
def __init__(self, extra_keys=None):
100150
# Merge in additional Keys:
101151
self.keys = default_keys.copy()

lib/ramble/ramble/pipeline.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -783,14 +783,14 @@ def _upload_file(src_file, dest_file):
783783
pipelines = Enum(
784784
"pipelines",
785785
[
786-
AnalyzePipeline.name,
787-
ArchivePipeline.name,
788-
MirrorPipeline.name,
789-
SetupPipeline.name,
790-
PushToCachePipeline.name,
791-
ExecutePipeline.name,
792-
PushDeploymentPipeline.name,
793-
LogsPipeline.name,
786+
"analyze",
787+
"archive",
788+
"mirror",
789+
"setup",
790+
"pushtocache",
791+
"execute",
792+
"pushdeployment",
793+
"logs",
794794
],
795795
)
796796

lib/ramble/ramble/reports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
import re
1313
from enum import Enum
14+
from typing import List
1415

1516
import llnl.util.filesystem as fs
1617

@@ -754,7 +755,7 @@ def generate_plot_data(self, pdf_report):
754755

755756
class MultiLinePlot(ScalingPlotGenerator):
756757
plot_type = "multi_line"
757-
series_to_plot = []
758+
series_to_plot: List[str] = []
758759

759760
def default_better(self):
760761
return BetterDirection.HIGHER

0 commit comments

Comments
 (0)