|
21 | 21 | from benchpark.debug import debug_print |
22 | 22 | from benchpark.runtime import RuntimeResources |
23 | 23 |
|
| 24 | +bootstrapper = RuntimeResources(benchpark.paths.benchpark_home) # noqa |
| 25 | +bootstrapper.bootstrap() # noqa |
24 | 26 |
|
25 | | -# Note: it would be nice to vendor spack.llnl.util.link_tree, but that |
26 | | -# involves pulling in most of llnl/util/ and spack/util/ |
27 | | -def symlink_tree(src, dst, include_fn=None): |
28 | | - """Like ``cp -R`` but instead of files, create symlinks""" |
29 | | - src = os.path.abspath(src) |
30 | | - dst = os.path.abspath(dst) |
31 | | - # By default, we include all filenames |
32 | | - include_fn = include_fn or (lambda f: True) |
33 | | - for x in [src, dst]: |
34 | | - if not os.path.isdir(x): |
35 | | - raise ValueError(f"Not a directory: {x}") |
36 | | - for src_subdir, directories, files in os.walk(src): |
37 | | - relative_src_dir = pathlib.Path(os.path.relpath(src_subdir, src)) |
38 | | - dst_dir = pathlib.Path(dst) / relative_src_dir |
39 | | - dst_dir.mkdir(parents=True, exist_ok=True) |
40 | | - for x in files: |
41 | | - if not include_fn(x): |
42 | | - continue |
43 | | - dst_symlink = dst_dir / x |
44 | | - src_file = os.path.join(src_subdir, x) |
45 | | - os.symlink(src_file, dst_symlink) |
| 27 | +import llnl.util.link_tree # noqa |
46 | 28 |
|
47 | 29 |
|
48 | 30 | def setup_parser(root_parser): |
@@ -183,23 +165,25 @@ def command(args): |
183 | 165 | ramble_logs_dir.mkdir(parents=True) |
184 | 166 | ramble_spack_experiment_configs_dir.mkdir(parents=True) |
185 | 167 |
|
186 | | - def include_fn(fname): |
| 168 | + def ignore_fn(fname): |
187 | 169 | # Only include .yaml files |
188 | 170 | # Always exclude files that start with "." |
189 | 171 | if fname.startswith("."): |
190 | | - return False |
191 | | - if fname.endswith(".yaml"): |
192 | 172 | return True |
193 | | - return False |
194 | | - |
195 | | - symlink_tree(configs_src_dir, ramble_configs_dir, include_fn) |
196 | | - symlink_tree(experiment_src_dir, ramble_configs_dir, include_fn) |
197 | | - symlink_tree(modifier_config_dir, ramble_configs_dir, include_fn) |
198 | | - symlink_tree( |
199 | | - source_dir / "configs" / "common", |
200 | | - ramble_spack_experiment_configs_dir, |
201 | | - include_fn, |
| 173 | + if fname.endswith(".yaml"): |
| 174 | + return False |
| 175 | + return True |
| 176 | + |
| 177 | + configs_tree = llnl.util.link_tree.LinkTree(configs_src_dir) |
| 178 | + experiment_tree = llnl.util.link_tree.LinkTree(experiments_src_dir) |
| 179 | + modifier_tree = llnl.util.link_tree.LinkTree(modifier_config_dir) |
| 180 | + for tree in (configs_tree, experiment_tree, modifier_tree): |
| 181 | + tree.merge(ramble_configs_dir, ignore=ignore_fn) |
| 182 | + |
| 183 | + common_configs_tree = llnl.util.link_tree.LinkTree( |
| 184 | + source_dir / "configs" / "common" |
202 | 185 | ) |
| 186 | + common_configs_tree.merge(ramble_spack_experiment_configs_dir, ignore=ignore_fn) |
203 | 187 |
|
204 | 188 | template_name = "execute_experiment.tpl" |
205 | 189 | experiment_template_options = [ |
|
0 commit comments