|
6 | 6 | def write(work_dir, tasks, config=None, machine=None, baseline_dir=None): |
7 | 7 | """ |
8 | 8 | Write a file with provenance, such as the git version, conda packages, |
9 | | - command, and tasks, to the work directory |
| 9 | + command, and tasks, to the work directory. |
| 10 | +
|
| 11 | + This function overwrites any existing provenance file in the work |
| 12 | + directory rather than appending, so the provenance reflects the most |
| 13 | + recent call to Polaris that used this work directory. |
10 | 14 |
|
11 | 15 | Parameters |
12 | 16 | ---------- |
@@ -56,11 +60,8 @@ def write(work_dir, tasks, config=None, machine=None, baseline_dir=None): |
56 | 60 | pass |
57 | 61 |
|
58 | 62 | provenance_path = f'{work_dir}/provenance' |
59 | | - if os.path.exists(provenance_path): |
60 | | - provenance_file = open(provenance_path, 'a') |
61 | | - provenance_file.write('\n') |
62 | | - else: |
63 | | - provenance_file = open(provenance_path, 'w') |
| 63 | + # Always overwrite to ensure provenance reflects the latest setup/suite |
| 64 | + provenance_file = open(provenance_path, 'w') |
64 | 65 |
|
65 | 66 | provenance_file.write( |
66 | 67 | '**************************************************' |
@@ -246,23 +247,4 @@ def _write_scheduler_metadata(provenance_file, config): |
246 | 247 | _write_meta(provenance_file, 'partition', partition) |
247 | 248 | _write_meta(provenance_file, 'qos', qos) |
248 | 249 | _write_meta(provenance_file, 'constraint', constraint) |
249 | | - if config.has_option('paths', 'component_path'): |
250 | | - component_path = config.get('paths', 'component_path') |
251 | | - else: |
252 | | - component_path = None |
253 | | - |
254 | | - if component_path is None or not os.path.exists(component_path): |
255 | | - return None |
256 | | - |
257 | | - cwd = os.getcwd() |
258 | | - os.chdir(component_path) |
259 | | - |
260 | | - try: |
261 | | - args = ['git', 'describe', '--tags', '--dirty', '--always'] |
262 | | - component_git_version = subprocess.check_output(args).decode('utf-8') |
263 | | - component_git_version = component_git_version.strip('\n') |
264 | | - except subprocess.CalledProcessError: |
265 | | - component_git_version = None |
266 | | - os.chdir(cwd) |
267 | | - |
268 | | - return component_git_version |
| 250 | + # No return value; this function only writes metadata lines |
0 commit comments