share/rbbt_commands/hpc/tail in rbbt-util-5.33.4 vs share/rbbt_commands/hpc/tail in rbbt-util-5.33.5
- old
+ new
@@ -8,11 +8,11 @@
options = SOPT.setup <<EOF
Queue a job in Marenostrum
-$ rbbt slurm tail <directory> [options]
+$ rbbt slurm tail <directory|jobid> [options]
-h--help Print this help
EOF
if options[:help]
@@ -33,10 +33,30 @@
directory = ARGV.shift
raise ParameterException if directory.nil?
-directory = File.dirname(directory) unless File.directory?(directory)
+if directory =~ /^[0-9]*$/
+ workdir = File.expand_path('~/rbbt-batch')
+ Path.setup(workdir)
+ workdir.glob("**/job.id").each do |file|
+ next unless directory == Open.read(file).strip
+ directory = File.dirname(file)
+ break
+ end
+end
+
+raise ParameterException, "Could not identify job #{directory}" unless File.exists?(directory)
+
require 'rbbt/hpc/slurm'
+
+command_txt = Open.read(File.join(directory, 'command.batch'))
+if m = command_txt.match(/#STEP_PATH: (.*)/)
+ step_path = m[1]
+else
+ step_path = nil
+end
+
+puts Log.color(:magenta, "Step path: ") + step_path if step_path
HPC::BATCH_MODULE.follow_job directory, true