|
106 | 106 | config_file_name = "ramble.yaml" |
107 | 107 | licenses_file_name = "licenses.yaml" |
108 | 108 |
|
109 | | - |
110 | | -def default_config_yaml(): |
111 | | - """default ramble.yaml file to put in new workspaces""" |
112 | | - return """\ |
113 | | -# This is a ramble workspace config file. |
114 | | -# |
115 | | -# It describes the experiments, the software stack |
116 | | -# and all variables required for ramble to configure |
117 | | -# experiments. |
118 | | -# As an example, experiments can be defined as follows. |
119 | | -# applications: |
120 | | -# hostname: # Application name, as seen in `ramble list` |
121 | | -# variables: |
122 | | -# iterations: '5' |
123 | | -# workloads: |
124 | | -# serial: # Workload name, as seen in `ramble info <app>` |
125 | | -# variables: |
126 | | -# type: 'test' |
127 | | -# experiments: |
128 | | -# single_node: # Arbitrary experiment name |
129 | | -# variables: |
130 | | -# n_ranks: '{processes_per_node}' |
131 | | -
|
132 | | -ramble: |
133 | | - env_vars: |
134 | | - set: |
135 | | - OMP_NUM_THREADS: '{n_threads}' |
136 | | - variables: |
137 | | - mpi_command: mpirun -n {n_ranks} |
138 | | - batch_submit: '{execute_experiment}' |
139 | | - processes_per_node: 1 |
140 | | - applications: {} |
141 | | - software: |
142 | | - packages: {} |
143 | | - environments: {} |
144 | | -""" |
145 | | - |
146 | | - |
147 | 109 | workspace_all_experiments_file = "all_experiments" |
148 | 110 |
|
149 | 111 | workspace_execution_template = "execute_experiment" + workspace_template_extension |
150 | 112 |
|
151 | | -shell = ramble.config.get("config:shell") |
152 | | -shell_path = os.path.join("/bin/", shell) |
153 | | -template_execute_script = ( |
154 | | - f"#!{shell_path}\n" |
155 | | - + """\ |
156 | | -# This is a template execution script for |
157 | | -# running the execute pipeline. |
158 | | -# |
159 | | -# Variables surrounded by curly braces will be expanded |
160 | | -# when generating a specific execution script. |
161 | | -# Some example variables are: |
162 | | -# - experiment_run_dir (Will be replaced with the experiment directory) |
163 | | -# - command (Will be replaced with the command to run the experiment) |
164 | | -# - log_dir (Will be replaced with the logs directory) |
165 | | -# - experiment_name (Will be replaced with the name of the experiment) |
166 | | -# - workload_run_dir (Will be replaced with the directory of the workload |
167 | | -# - application_name (Will be repalced with the name of the application) |
168 | | -# - n_nodes (Will be replaced with the required number of nodes) |
169 | | -# Any experiment parameters will be available as variables as well. |
170 | | -
|
171 | | -cd "{experiment_run_dir}" |
172 | | -
|
173 | | -{command} |
174 | | -""" |
175 | | -) |
176 | | - |
177 | 113 | #: Name of lockfile within a workspace |
178 | 114 | lockfile_name = "ramble.lock" |
179 | 115 |
|
@@ -557,7 +493,7 @@ def _read(self): |
557 | 493 |
|
558 | 494 | read_default = not os.path.exists(self.config_file_path) |
559 | 495 | if read_default: |
560 | | - self._read_config(config_section, default_config_yaml()) |
| 496 | + self._read_config(config_section, self._default_config_yaml()) |
561 | 497 | else: |
562 | 498 | with open(self.config_file_path) as f: |
563 | 499 | self._read_config(config_section, f) |
@@ -588,7 +524,73 @@ def _read(self): |
588 | 524 |
|
589 | 525 | if read_default_script: |
590 | 526 | template_name = workspace_execution_template[0:-ext_len] |
591 | | - self._read_template(template_name, template_execute_script) |
| 527 | + self._read_template(template_name, self._template_execute_script()) |
| 528 | + |
| 529 | + @classmethod |
| 530 | + def _template_execute_script(self): |
| 531 | + shell = ramble.config.get("config:shell") |
| 532 | + shell_path = os.path.join("/bin/", shell) |
| 533 | + script = ( |
| 534 | + f"#!{shell_path}\n" |
| 535 | + + """\ |
| 536 | +# This is a template execution script for |
| 537 | +# running the execute pipeline. |
| 538 | +# |
| 539 | +# Variables surrounded by curly braces will be expanded |
| 540 | +# when generating a specific execution script. |
| 541 | +# Some example variables are: |
| 542 | +# - experiment_run_dir (Will be replaced with the experiment directory) |
| 543 | +# - command (Will be replaced with the command to run the experiment) |
| 544 | +# - log_dir (Will be replaced with the logs directory) |
| 545 | +# - experiment_name (Will be replaced with the name of the experiment) |
| 546 | +# - workload_run_dir (Will be replaced with the directory of the workload |
| 547 | +# - application_name (Will be repalced with the name of the application) |
| 548 | +# - n_nodes (Will be replaced with the required number of nodes) |
| 549 | +# Any experiment parameters will be available as variables as well. |
| 550 | +
|
| 551 | +cd "{experiment_run_dir}" |
| 552 | +
|
| 553 | +{command} |
| 554 | +""" |
| 555 | + ) |
| 556 | + |
| 557 | + return script |
| 558 | + |
| 559 | + @classmethod |
| 560 | + def _default_config_yaml(self): |
| 561 | + return """\ |
| 562 | +# This is a ramble workspace config file. |
| 563 | +# |
| 564 | +# It describes the experiments, the software stack |
| 565 | +# and all variables required for ramble to configure |
| 566 | +# experiments. |
| 567 | +# As an example, experiments can be defined as follows. |
| 568 | +# applications: |
| 569 | +# hostname: # Application name, as seen in `ramble list` |
| 570 | +# variables: |
| 571 | +# iterations: '5' |
| 572 | +# workloads: |
| 573 | +# serial: # Workload name, as seen in `ramble info <app>` |
| 574 | +# variables: |
| 575 | +# type: 'test' |
| 576 | +# experiments: |
| 577 | +# single_node: # Arbitrary experiment name |
| 578 | +# variables: |
| 579 | +# n_ranks: '{processes_per_node}' |
| 580 | +
|
| 581 | +ramble: |
| 582 | + env_vars: |
| 583 | + set: |
| 584 | + OMP_NUM_THREADS: '{n_threads}' |
| 585 | + variables: |
| 586 | + mpi_command: mpirun -n {n_ranks} |
| 587 | + batch_submit: '{execute_experiment}' |
| 588 | + processes_per_node: 1 |
| 589 | + applications: {} |
| 590 | + software: |
| 591 | + packages: {} |
| 592 | + environments: {} |
| 593 | +""" |
592 | 594 |
|
593 | 595 | def _read_application_config(self, path, f, raw_yaml=None): |
594 | 596 | """Read an application configuration file""" |
|
0 commit comments