Skip to content

Commit f76728a

Browse files
committed
Overwrite rather than append provenance
1 parent eb3029a commit f76728a

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

polaris/provenance.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
def write(work_dir, tasks, config=None, machine=None, baseline_dir=None):
77
"""
88
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.
1014
1115
Parameters
1216
----------
@@ -56,11 +60,8 @@ def write(work_dir, tasks, config=None, machine=None, baseline_dir=None):
5660
pass
5761

5862
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')
6465

6566
provenance_file.write(
6667
'**************************************************'
@@ -246,23 +247,4 @@ def _write_scheduler_metadata(provenance_file, config):
246247
_write_meta(provenance_file, 'partition', partition)
247248
_write_meta(provenance_file, 'qos', qos)
248249
_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

Comments
 (0)