Skip to content

Commit 87c0098

Browse files
committed
Saved the command line in a file to keep an history
1 parent 6cd35aa commit 87c0098

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scripts/smart_dispatch.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
import re
45
import os
6+
import sys
57
import argparse
68
import time as t
79
import numpy as np
@@ -102,6 +104,14 @@ def main():
102104
job_generator = job_generator_factory(queue, commands, command_params, CLUSTER_NAME, path_job)
103105
pbs_filenames = job_generator.write_pbs_files(path_job_commands)
104106

107+
# Keep an history of command lines i.e. smart_dispatch.py commands.
108+
with utils.open_with_lock(os.path.join(path_job, "command_line_history.txt"), 'a') as command_line_history_file:
109+
command_line_history_file.write(t.strftime("## %Y-%m-%d %H:%M:%S ##\n"))
110+
command_line = " ".join(sys.argv)
111+
command_line = command_line.replace('"', r'\"') # Make sure we can paste the command line as-is
112+
command_line = re.sub(r'(\[)([^\[\]]*\\ [^\[\]]*)(\])', r'"\1\2\3"', command_line) # Make sure we can paste the command line as-is
113+
command_line_history_file.write(command_line + "\n\n")
114+
105115
# Launch the jobs
106116
print "## {nb_commands} command(s) will be executed in {nb_jobs} job(s) ##".format(nb_commands=nb_commands, nb_jobs=len(pbs_filenames))
107117
print "Batch UID:\n{batch_uid}".format(batch_uid=jobname)

0 commit comments

Comments
 (0)