6 |
|
from crab_logger import Logger |
7 |
|
from crab_exceptions import * |
8 |
|
from ProdCommon.FwkJobRep.ReportParser import readJobReport |
9 |
+ |
from ProdCommon.FwkJobRep.ReportState import checkSuccess |
10 |
|
from ProdCommon.MCPayloads.WorkflowSpec import WorkflowSpec |
11 |
|
from ProdCommon.DataMgmt.DBS.DBSWriter import DBSWriter |
12 |
|
from ProdCommon.DataMgmt.DBS.DBSErrors import DBSWriterError, formatEx,DBSReaderError |
25 |
|
""" |
26 |
|
|
27 |
|
try: |
28 |
< |
self.processedData = cfg_params['USER.publish_data_name'] |
28 |
> |
self.userprocessedData = cfg_params['USER.publish_data_name'] |
29 |
> |
self.processedData = None |
30 |
|
except KeyError: |
31 |
|
raise CrabException('Cannot publish output data, because you did not specify USER.publish_data_name parameter in the crab.cfg file') |
32 |
|
|
134 |
|
datasets=fileinfo.dataset |
135 |
|
common.logger.debug(6,"FileInfo = " + str(fileinfo)) |
136 |
|
common.logger.debug(6,"DatasetInfo = " + str(datasets)) |
137 |
+ |
if len(datasets)<=0: |
138 |
+ |
self.exit_status = '1' |
139 |
+ |
msg = "Error: No info about dataset in the xml file "+file |
140 |
+ |
common.logger.message(msg) |
141 |
+ |
return self.exit_status |
142 |
|
for dataset in datasets: |
143 |
|
#### for production data |
144 |
+ |
self.processedData = dataset['ProcessedDataset'] |
145 |
|
if (dataset['PrimaryDataset'] == 'null'): |
146 |
< |
dataset['PrimaryDataset'] = dataset['ProcessedDataset'] |
147 |
< |
|
146 |
> |
#dataset['PrimaryDataset'] = dataset['ProcessedDataset'] |
147 |
> |
dataset['PrimaryDataset'] = self.userprocessedData |
148 |
> |
#else: # add parentage from input dataset |
149 |
> |
elif self.datasetpath.upper() != 'NONE': |
150 |
> |
dataset['ParentDataset']= self.datasetpath |
151 |
> |
|
152 |
|
dataset['PSetContent']=self.content |
153 |
|
cfgMeta = {'name' : self.pset , 'Type' : 'user' , 'annotation': 'user cfg', 'version' : 'private version'} # add real name of user cfg |
154 |
|
common.logger.message("PrimaryDataset = %s"%dataset['PrimaryDataset']) |
194 |
|
self.noLFN.append(file['PFN']) |
195 |
|
else: |
196 |
|
if int(file['TotalEvents']) != 0 : |
197 |
< |
file.lumisections = {} |
197 |
> |
#file.lumisections = {} |
198 |
> |
# lumi info are now in run hash |
199 |
> |
file.runs = {} |
200 |
|
for ds in file.dataset: |
187 |
– |
ds['ProcessedDataset']=procdataset |
201 |
|
### Fede for production |
202 |
|
if (ds['PrimaryDataset'] == 'null'): |
203 |
< |
ds['PrimaryDataset']=procdataset |
203 |
> |
#ds['PrimaryDataset']=procdataset |
204 |
> |
ds['PrimaryDataset']=self.userprocessedData |
205 |
|
filestopublish.append(file) |
206 |
|
else: |
207 |
|
self.noEventsFiles.append(file['LFN']) |
216 |
|
Blocks=None |
217 |
|
try: |
218 |
|
Blocks=dbswriter.insertFiles(jobReport) |
219 |
< |
common.logger.message("Blocks = %s"%Blocks) |
219 |
> |
common.logger.message("Inserting file in blocks = %s"%Blocks) |
220 |
|
except DBSWriterError, ex: |
221 |
< |
common.logger.message("Insert file error: %s"%ex) |
221 |
> |
common.logger.error("Insert file error: %s"%ex) |
222 |
|
return Blocks |
223 |
|
|
224 |
|
def run(self): |
227 |
|
""" |
228 |
|
|
229 |
|
file_list = glob.glob(self.resDir+"crab_fjr*.xml") |
230 |
+ |
## Select only those fjr that are succesfull |
231 |
+ |
good_list=[] |
232 |
+ |
for fjr in file_list: |
233 |
+ |
reports = readJobReport(fjr) |
234 |
+ |
if len(reports)>0: |
235 |
+ |
if reports[0].status == "Success": |
236 |
+ |
good_list.append(fjr) |
237 |
+ |
file_list=good_list |
238 |
+ |
## |
239 |
|
common.logger.debug(6, "file_list = "+str(file_list)) |
240 |
|
common.logger.debug(6, "len(file_list) = "+str(len(file_list))) |
241 |
|
|
250 |
|
|
251 |
|
common.logger.message("--->>> Start files publication") |
252 |
|
for file in file_list: |
253 |
< |
common.logger.message("file = "+file) |
253 |
> |
common.logger.debug(1, "file = "+file) |
254 |
|
Blocks=self.publishAJobReport(file,self.processedData) |
255 |
|
if Blocks: |
256 |
< |
[BlocksList.append(x) for x in Blocks] |
256 |
> |
for x in Blocks: # do not allow multiple entries of the same block |
257 |
> |
if x not in BlocksList: |
258 |
> |
BlocksList.append(x) |
259 |
|
|
260 |
|
# close the blocks |
261 |
|
common.logger.debug(6, "BlocksList = %s"%BlocksList) |