5 import common_tools
as tools
6 import SAMView
as sam_view
11 def __init__(self, config_dict, release="development", local=False, verbose=False, user=False):
16 self.
name = config_dict[
"name"]
21 optional_attributes = [
"datasets",
"local_dataset",
"local_datasets",
"sam",
"directories"]
22 for attr
in optional_attributes:
23 if attr
in config_dict.keys():
24 setattr(self, attr, config_dict[attr])
26 setattr(self, attr,
False)
28 if "label" in config_dict.keys():
29 self.
label = config_dict[
"label"]
33 if "release" in config_dict.keys():
38 string_attributes = [
"n_jobs",
"files_per_job"]
39 for attr
in string_attributes:
40 if attr
in config_dict.keys():
41 setattr(self, attr, config_dict[attr])
43 setattr(self, attr,
"")
48 if (self.
local or self.sam):
51 self.
jobsub_command =
"jobsub_submit -G nova --resource-provides=usage_model=DEDICATED,OPPORTUNISTIC --expected-lifetime=3600s --OS=SL6 file://%s"%(os.environ[
"NOVAANAVALID_DIR"])
61 process = subprocess.Popen(self.command.split(
" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
63 output = process.stdout
66 for line
in self.
lines:
67 if self.
verbose:
print line.strip()
71 print "comp : ERROR in submission" 72 self.
status =
"submission error" 83 sam_url = tools.getSAMURL(self.
lines)
84 if self.
verbose:
print "comp : found sam URL: %s"%sam_url
88 if (
not hasattr(self,
"sam_view")):
92 return self.sam_view.get_status(sam, n_files=self.
n_files)
102 total_files = sam.countFiles(dimensions=
"snapshot_id %s"%self.sam_view.sam_summary[
"snapshot_id"])
111 return "not applicable" 112 if (
not hasattr(self,
"sam_merge_status")):
117 if hasattr(self,
"sam_merge_status")
and (self.
sam_merge_status !=
"not run"):
123 output_files = glob.glob(
"%s/*.root"%self.output_dir)
124 if (
not len(output_files)):
128 cmd =
'python %s/core/utils/hadd_caf.py -i %s/ -w * -o %s -s'%(os.environ[
"NOVAANAVALID_DIR"], self.output_dir, self.
root_file)
130 process = subprocess.Popen(cmd.split(
" "), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
133 line = process.stdout.readline()
134 if line !=
"": lines.append(line)
135 if line ==
'' and process.poll() !=
None:
break 138 if (process.returncode != 0):
139 print "comp : --- Exception caught while executing sam merge, return code: %i"%process.returncode
140 print "comp : command run: %s"%cmd
145 elif (
not os.path.exists(self.
root_file)):
def get_sam_status(self, sam)
def get_sam_merge_status(self)
def get_expected_sam_output_files(self, sam)
def __init__(self, config_dict, release="development", local=False, verbose=False, user=False)