10 #include "KVBatchSystem.h"
13 #include "TPluginManager.h"
15 #include "KVDataAnalyser.h"
16 #include "KVDataAnalysisTask.h"
37 :
KVBase(name), fAnalyser(nullptr)
49 SetTitle(gEnv->GetValue(Form(
"%s.BatchSystem.Title", name),
""));
51 fJobSubCmd = gEnv->GetValue(Form(
"%s.BatchSystem.JobSubCmd", name),
"");
54 KVError::Warning(
this,
"KVBatchSystem",
"Batch system %s has unknown job submission command: %s",
55 name, fJobSubCmd.Data());
58 SetJobScript(gEnv->GetValue(Form(
"%s.BatchSystem.JobScript", name),
""));
71 if (gBatchSystem ==
this)
136 static TString command_line;
137 command_line.Form(
"%s %s ", fJobSubCmd.Data(), fDefOpt.Data());
139 for (
int i = 0; i < fParList.
GetNpar(); i++) {
141 command_line += par->GetName();
148 command_line += fJobScript;
150 command_line.ReplaceAll(
"#JobName#",
GetJobName());
152 command_line.ReplaceAll(
"#tmpDIR#", gSystem->TempDirectory());
154 command_line.ReplaceAll(
"#launchDIR#", gSystem->WorkingDirectory());
155 return command_line.Data();
206 gSystem->Setenv(
"KVLAUNCHDIR", gSystem->WorkingDirectory());
259 KVError::Error(
KVBatchSystem{
""},
"GetBatchSystem",
"Batch system plugin %s: class %s not found, system undefined", plugin, ph->GetClass());
280 Info(
"SubmitTask",
"Task submission for analyser class : %s", da->ClassName());
317 TString tmp = gEnv->GetValue(Form(
"%s.BatchSystem.DefaultJobOptions.%s",
320 Info(
"ChangeDefJobOpt",
"Changing default batch options for task %s.", da->
GetAnalysisTask()->GetName());
321 Info(
"ChangeDefJobOpt",
"Batch job options for this job are : %s", tmp.Data());
325 tmp = gEnv->GetValue(Form(
"%s.BatchSystem.DefaultJobOptions", GetName()),
"");
360 fCurrJobName = fJobName;
376 return fCurrJobName.Data();
389 while (!jobName.Length()) {
390 cout <<
"Please enter the job name : ";
392 jobName.ReadToDelim(cin);
393 if (jobName.Length()) {
411 env->SetValue(
"BatchSystem.JobName",
GetJobName());
425 fJobName = env->GetValue(
"BatchSystem.JobName",
"");
439 if (!strcmp(option,
"log")) {
441 <<
" executed by batch system " << GetName() << endl;
443 else if (!strcmp(option,
"all")) {
444 cout << ClassName() <<
" : Name = " << GetName() << endl <<
" Title = " << GetTitle() << endl;
445 cout <<
" fJobSubCmd = " << fJobSubCmd.Data() << endl;
446 cout <<
" fJobScript = " << fJobScript.Data() << endl;
447 cout <<
" fDefOpt = " << fDefOpt.Data() << endl;
495 nl.SetTitle(GetTitle());
498 nl.
SetValue(
"AutoJobNameFormat",
"$UserClass");
514 Info(
"SetBatchSystemParameters",
"JobName = %s",
GetJobName());
Base class for KaliVeda framework.
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
void Print(Option_t *option="") const override
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Base class for interface to a batch job management system.
virtual void SubmitTask(KVDataAnalyser *da)
void SetAnalyser(KVDataAnalyser *da)
virtual void WriteBatchEnvFile(TEnv *)
void Clear(Option_t *opt="") override
virtual const Char_t * GetJobSubCmdLine()
virtual void SetJobName(const Char_t *name)
virtual void SetDefaultJobOptions(const Char_t *opt)
virtual Bool_t MultiJobsMode() const
void cd()
Make this the default batch system.
KVBatchSystem(const Char_t *name)
virtual const Char_t * GetJobName() const
virtual void SanitizeJobName() const
virtual KVList * GetListOfJobs()
static KVBatchSystem * GetBatchSystem(const Char_t *plugin)
virtual void ReadBatchEnvFile(TEnv *)
virtual void SetBatchSystemParameters(const KVNameValueList &)
Use the parameters in the list to set all relevant parameters for batch system.
virtual void SetJobScript(const Char_t *path)
void Print(Option_t *="") const override
virtual ~KVBatchSystem()
Destructor.
virtual void GetBatchSystemParameterList(KVNameValueList &)
virtual Bool_t CheckJobParameters()
Checks the job and ask for the job name if needed.
Manager class which sets up and runs data analysis tasks.
virtual TString ExpandAutoBatchName(const Char_t *format) const
virtual void WriteBatchEnvFile(const TString &, Bool_t sav=kTRUE)
virtual TString GetAnalyserClassNameForBatchJob()
KVDataAnalysisTask * GetAnalysisTask() const
Extended TList class which owns its objects by default.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
void SetValue(const Char_t *name, value_type value)
Int_t GetNpar() const
return the number of stored parameters
void Clear(Option_t *opt="") override
Bool_t GetBoolValue(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
void Print(Option_t *opt="") const override
A generic named parameter storing values of different types.
const Char_t * GetString() const
TString GetTString() const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
const run_index_t & Last() const
const run_index_t & First() const
TString as_string() const
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)