@@ -42,10 +42,12 @@ def main():
4242 commands = smartdispatch .unfold_command (command )
4343
4444 commands = smartdispatch .replace_uid_tag (commands )
45+ nb_commands = len (commands ) # For print at the end
4546
46- path_job_logs , path_job_commands = create_job_folders (jobname )
47+ path_job , path_job_logs , path_job_commands = create_job_folders (jobname )
4748 elif args .mode == "resume" :
48- path_job_logs , path_job_commands = get_job_folders (args .batch_uid )
49+ jobname = args .batch_uid
50+ path_job , path_job_logs , path_job_commands = get_job_folders (args .batch_uid )
4951 else :
5052 raise ValueError ("Unknown subcommand!" )
5153
@@ -58,6 +60,7 @@ def main():
5860 command_manager .set_commands_to_run (commands )
5961 else :
6062 command_manager .reset_running_commands ()
63+ nb_commands = command_manager .get_nb_commands_to_run ()
6164
6265 worker_command = 'smart_worker.py "{0}" "{1}"' .format (command_manager ._commands_filename , path_job_logs )
6366 # Replace commands with `args.pool` workers
@@ -83,11 +86,19 @@ def main():
8386 job_generator = job_generator_factory (queue , commands , command_params , CLUSTER_NAME )
8487 pbs_filenames = job_generator .write_pbs_files (path_job_commands )
8588
86- # Launch the jobs with QSUB
89+ # Launch the jobs
90+ print "## {nb_commands} command(s) will be executed in {nb_jobs} job(s) ##" .format (nb_commands = nb_commands , nb_jobs = len (pbs_filenames ))
91+ print "Batch UID:\n {batch_uid}" .format (batch_uid = jobname )
8792 if not args .doNotLaunch :
93+ jobs_id = []
8894 for pbs_filename in pbs_filenames :
8995 qsub_output = check_output ('{launcher} {pbs_filename}' .format (launcher = LAUNCHER if args .launcher is None else args .launcher , pbs_filename = pbs_filename ), shell = True )
90- print qsub_output ,
96+ jobs_id += [qsub_output .rstrip ()]
97+
98+ with utils .open_with_lock (os .path .join (path_job , "jobs_id.txt" ), 'a' ) as jobs_id_file :
99+ jobs_id_file .writelines ("\n " .join (jobs_id ))
100+ print "\n Jobs id:\n {jobs_id}" .format (jobs_id = " " .join (jobs_id ))
101+ print "\n Logs, command, and jobs id related to this batch will be in:\n {smartdispatch_folder}" .format (smartdispatch_folder = path_job )
91102
92103
93104def parse_arguments ():
@@ -137,32 +148,32 @@ def _gen_job_paths(jobname):
137148 path_job_logs = os .path .join (path_job , 'logs' )
138149 path_job_commands = os .path .join (path_job , 'commands' )
139150
140- return path_job_logs , path_job_commands
151+ return path_job , path_job_logs , path_job_commands
141152
142153
143154def get_job_folders (jobname ):
144- path_job_logs , path_job_commands = _gen_job_paths (jobname )
155+ path_job , path_job_logs , path_job_commands = _gen_job_paths (jobname )
145156
146157 if not os .path .exists (path_job_commands ):
147158 raise LookupError ("Batch UID ({0}) does not exist! Cannot resume." .format (jobname ))
148159
149160 if not os .path .exists (path_job_logs ):
150161 os .makedirs (path_job_logs )
151162
152- return path_job_logs , path_job_commands
163+ return path_job , path_job_logs , path_job_commands
153164
154165
155166def create_job_folders (jobname ):
156167 """Creates the folders where the logs, commands and QSUB files will be saved."""
157- path_job_logs , path_job_commands = _gen_job_paths (jobname )
168+ path_job , path_job_logs , path_job_commands = _gen_job_paths (jobname )
158169
159170 if not os .path .exists (path_job_commands ):
160171 os .makedirs (path_job_commands )
161172
162173 if not os .path .exists (path_job_logs ):
163174 os .makedirs (path_job_logs )
164175
165- return path_job_logs , path_job_commands
176+ return path_job , path_job_logs , path_job_commands
166177
167178
168179if __name__ == "__main__" :
0 commit comments