CMS 3D CMS Logo

Functions
popcon2dropbox Namespace Reference

Functions

def checkFile ()
 
def copy (args)
 
def run (args)
 
def saveFileForImportErrors (datef, withMetadata=False)
 
def upload (args)
 

Function Documentation

def popcon2dropbox.checkFile ( )

Definition at line 35 of file popcon2dropbox.py.

References harvestTrackValidationPlots.str.

Referenced by run().

35 def checkFile():
36  # check if the expected input file is there...
37  # exit code < 0 => error
38  # exit code = 0 => skip
39  # exit code = 1 => import
40  if not os.path.exists( dbFileName ):
41  logger.error('The file expected as an input %s has not been found.'%dbFileName )
42  return -1
43 
44  empty = True
45  try:
46  dbcon = sqlite3.connect( dbFileName )
47  dbcur = dbcon.cursor()
48  dbcur.execute('SELECT * FROM IOV')
49  rows = dbcur.fetchall()
50  for r in rows:
51  empty = False
52  dbcon.close()
53  if empty:
54  logger.warning('The file expected as an input %s contains no data. The import will be skipped.'%dbFileName )
55  return 0
56  return 1
57  except Exception as e:
58  logger.error('Check on input data failed: %s' %str(e))
59  return -2
60 
def popcon2dropbox.copy (   args)

Definition at line 124 of file popcon2dropbox.py.

References saveFileForImportErrors(), and harvestTrackValidationPlots.str.

Referenced by DigiCollectionFP420.add(), AlignmentSurfaceDeformations.add(), GeometricDet.addComponents(), MatacqProducer.addMatacqData(), nanoaod::MergeableCounterTable.addVFloat(), nanoaod::MergeableCounterTable.addVInt(), AlignableExtras.alignmentErrors(), AlignableDet.alignmentErrors(), AlignableCSCEndcap.alignmentErrors(), AlignableDTBarrel.alignmentErrors(), AlignableComposite.alignmentErrors(), AlignableMuon.alignmentErrors(), AlignableTracker.alignmentErrors(), AlignableExtras.alignments(), AlignableDet.alignments(), AlignableCSCEndcap.alignments(), AlignableDTBarrel.alignments(), AlignableComposite.alignments(), AlignableMuon.alignments(), AlignableTracker.alignments(), LHEWriter.analyze(), DTResidualCalibration.analyze(), DTEfficiencyTask.analyze(), DTResolutionAnalysisTask.analyze(), FFTJetImageRecorder.analyze(), FFTJetPileupAnalyzer.analyze(), GeometryAligner.applyAlignments(), SegmentsTrackAssociator.associate(), GeometryAligner.attachSurfaceDeformations(), EmbeddingLHEProducer.beginRunProduce(), ecaldqm::MESetNonObject.book(), ecaldqm::MESetEcal.book(), L1ExtraDQM::L1ExtraMonElement< CollectionType >.bookhistograms(), MuonTransientTrackingRecHitBreaker.breakInSubRecHits(), CSCGeometryParsFromDD.build(), SiStripFedCabling.buildFedCabling(), DTCombinatorialPatternReco4D.buildPhiSuperSegmentsCandidates(), DTMeantimerPatternReco4D.buildPhiSuperSegmentsCandidates(), DTCombinatorialPatternReco.buildPointsCollection(), DTCombinatorialExtendedPatternReco.buildPointsCollection(), FWDTSegmentProxyBuilder.buildViewType(), lumi::LumiSectionData.bunchCrossingInfo(), reco::FlavorHistoryEvent.cache(), ecaldqm::MESetNonObject.clone(), ecaldqm::MESetDet2D.clone(), ecaldqm::MESetProjection.clone(), ecaldqm::MESetDet0D.clone(), ecaldqm::MESetDet1D.clone(), ecaldqm::MESetTrend.clone(), ecaldqm::MESetEcal.clone(), ecaldqm::MESetMulti.clone(), ecaldqm::MESet.clone(), CmsShowMainFrame.CmsShowMainFrame(), EcalGlobalShowerContainmentCorrectionsVsEta::Coefficients.Coefficients(), EcalShowerContainmentCorrections::Coefficients.Coefficients(), SiStripProcessedRawDigiProducer.common_process(), CompoundPseudoJet.CompoundPseudoJet(), CompoundPseudoSubJet.CompoundPseudoSubJet(), DTCalibValidation.compute(), EcalDccWeightBuilder.computeAllWeights(), OMTFConfiguration.configure(), Measurement.construct(), DDAHcalModuleAlgo.constructLayers(), DDHGCalModule.constructLayers(), DDHGCalModuleAlgo.constructLayers(), DDHGCalTBModule.constructLayers(), DDHGCalEEAlgo.constructLayers(), DDHGCalHEAlgo.constructLayers(), edm.copy_all(), copy_and_sort_vector(), o2o_helper.copy_payload(), MuonAlignment.copyAlignmentToSurvey(), PFBenchmarkAlgo.copyCollection(), Vispa.Main.Application.Application.copyEvent(), edm::soa::Table< Args >.copyFromToWithResize(), Measurement.copyMeas(), EcalDBCopy.copyToDB(), TruncatedPyramid.createCorners(), sistrip::DetSetVectorFiller< T, dsvIsSparse >.createDetSetVector(), genericValidation.ValidationWithPlots.createPlottingScript(), align.createPoints(), TGeoMgrFromDdd.createShape(), TGeoFromDddService.createShape(), AlignableMuon.cscAlignmentErrorsExtended(), AlignableMuon.cscAlignments(), AlignableMuon.CSCChambers(), AlignableMuon.CSCEndcaps(), AlignableMuon.CSCRings(), AlignableMuon.CSCStations(), DetGeomDesc.deepComponents(), HGCalSimHitValidation.defineGeometry(), edm::StreamerInputSource.deserializeEvent(), magfieldparam::rz_poly.Diff(), reco::DiscretizedEnergyFlow.DiscretizedEnergyFlow(), genericValidation.ValidationWithComparison.doComparison(), FWLiteJobMetadataManager.doUpdate(), AlignableMuon.DTBarrel(), AlignableMuon.DTChambers(), AlignableMuon.DTStations(), AlignableMuon.DTWheels(), BeamFitter.dumpTxtFile(), empty(), MuonSeedOrcaPatternRecognition.endcapPatterns(), LHEWriter.endRun(), PhysicsTools::Interceptor.eval(), EventMsgBuilder.EventMsgBuilder(), eventSetupComponent(), DDTIDModulePosAlgo.execute(), DDTrackerZPosAlgo.execute(), DDHGCalWafer.execute(), DDHGCalWaferAlgo.execute(), DDPixBarLayerAlgo.execute(), DDPixBarLayerUpgradeAlgo.execute(), DDPixFwdDiskAlgo.execute(), DDPixPhase1FwdDiskAlgo.execute(), DDTrackerLinearXY.execute(), DDTrackerXYZPosAlgo.execute(), DDHCalFibreBundle.execute(), DDHCalLinearXY.execute(), DDTrackerAngular.execute(), DDTrackerAngularV1.execute(), DDLinear.execute(), DDAngular.execute(), DDTrackerRingAlgo.execute(), DDPixFwdBlades.execute(), reco::FFTJetProducerSummary.FFTJetProducerSummary(), Measurement.fillData(), MuonShowerInformationFiller.fillHitsByStation(), CSCHitFromStripOnly.fillPulseHeights(), DTNewROS8FileReader.fillRawData(), DTROS8FileReader.fillRawData(), DTDDUFileReader.fillRawData(), DTROS25FileReader.fillRawData(), DTSpyReader.fillRawData(), reco::modules::JetFlavourIdentifier.findCandidates(), DTCombinatorialPatternReco.findCompatibleHits(), DTCombinatorialExtendedPatternReco.findCompatibleHits(), CSCHitFromStripOnly.findHitOnStripPosition(), SequentialPartitionGenerator.first_part(), ecaldqm::binning.formAxis(), edm.get_underlying_safe(), EcalBarrelGeometry.getClosestCell(), genericValidation.GenericValidation.getCompareStrings(), ROOT::Math::Transform3DPJ.GetComponents(), DTTimeBoxFitter.getFitSeeds(), WatcherStreamFileReader.getInputFile(), l1t::stage2::GMTCollections.getMuons(), MsgTools.getNames(), edm::ParameterSet.getParameterNamesForType(), PhysicsPerformancePayload.getRow(), METCorrectorParametersCollection.getSections(), JetCorrectorParametersCollection.getSections(), TrackTransformerForGlobalCosmicMuons.getTransientRecHits(), TrackTransformerForCosmicMuons.getTransientRecHits(), l1t::Parameter.getVector(), FedRawDataInputSource.grabNextJsonFile(), HcalLogicalMap.HcalLogicalMap(), EventMsgView.hltTriggerBits(), edm::RangeMap< int, std::vector< float >, edm::CopyPolicy< float > >.ids(), EcalSRCondTools.importParameterSet(), gen::JetMatchingAlpgen.init(), SimHitMatcher.init(), RecoIdealGeometry.insert(), edm::helper::Filler< Association< C > >.insert(), Phase2ITPixelClusterShapeCache.insert(), SiPixelClusterShapeCache.insert(), edmNew::DetSetVector< edm::Ref< edmNew::DetSetVector< SiStripCluster >, SiStripCluster, edmNew::DetSetVector< SiStripCluster >::FindForDetSetVector > >.insert(), magfieldparam::rz_poly.Int(), MatacqTBDataFormatter.interpretRawData(), MatacqDataFormatter.interpretRawData(), lhef::LHERunInfo.LHERunInfo(), CaloTowerHardcodeGeometryLoader.load(), HcalGeomParameters.loadGeometry(), HGCalGeomParameters.loadGeometryHexagon(), edm::MapOfVectors< std::string, AnalysisDescription * >.loadNext(), HGCalGeomParameters.loadWaferHexagon(), OptoScanTask.locateTicks(), MagFieldConfig.MagFieldConfig(), make_array(), CSCHitFromStripOnly.makeStripData(), reco::tau::RecoTauIsolationMasking.mask(), SiStripRecHitConverterAlgorithm.match(), GEMDigiMatcher.matchDigisToSimTrack(), GEMDigiMatcher.matchPadsToSimTrack(), GEMRecHitMatcher.matchRecHitsToSimTrack(), LHERunInfoProduct.mergeProduct(), MuRodBarrelLayer.MuRodBarrelLayer(), SequentialCombinationGenerator< T >.next_combi(), SequentialPartitionGenerator.next_part(), SequentialCombinationGenerator< T >.next_subset(), nonProducerComponent(), reco::tau::RecoTauPhotonFilter.operator()(), reco::tau::RecoTauElectronRejectionPlugin.operator()(), reco::TrackKinematics.operator+(), Json::ValueIteratorBase.operator-(), operator<<(), EcalGlobalShowerContainmentCorrectionsVsEta::Coefficients.operator=(), EcalShowerContainmentCorrections::Coefficients.operator=(), PhysicsTools::MVAComputer::DerivContext.output(), l1t::Parameter.Parameter(), edm.ParameterSet::getParameterNamesForType< std::vector< PdtEntry > >(), AlpgenHeader.parse(), PartitionGenerator.partitions(), PhiMemoryImage.PhiMemoryImage(), CmsTrackerPhase1DiskBuilder.PhiPosNegSplit_innerOuter(), CmsTrackerPhase2TPDiskBuilder.PhiPosNegSplit_innerOuter(), fftjetcms::Polynomial.Polynomial(), DDAHcalModuleAlgo.positionSensitive(), DDHGCalModule.positionSensitive(), DDHGCalModuleAlgo.positionSensitive(), DDHGCalTBModule.positionSensitive(), L1GtConditionEvaluation.print(), l1t::ConditionEvaluation.print(), GlobalObjectMap.print(), L1GlobalTriggerObjectMap.print(), FillInfo.print(), SiStripQuality.printActiveFedsInfo(), L1RCTProducer.printFedVector(), MagGeoBuilderFromDDD::volumeHandle.printUniqueNames(), sistrip::SpyDigiConverter.processFED(), MuonSeedOrcaPatternRecognition.produce(), PFMuonUntagger.produce(), EcalBasicClusterLocalContCorrectionsESProducer.produce(), PFCandidateMuonUntagger.produce(), DTRecSegment4DProducer.produce(), reco::tautools::CopyProducer< Collection >.produce(), CSCTFPacker.produce(), EcalGlobalShowerContainmentCorrectionsVsEtaESProducer.produce(), pat::L1MuonMatcher.produce(), EcalShowerContainmentCorrectionsESProducer.produce(), ReducedRecHitCollectionProducer.produce(), DTRecSegment2DExtendedProducer.produce(), EmbeddingLHEProducer.produce(), EcalTrivialConditionRetriever.produceEcalSamplesCorrelation(), EcalTrivialConditionRetriever.produceEcalTimeBiasCorrections(), HcalAlignmentEP.produceHcalAli(), FQueue< T >.push_back(), edm::DataFrameContainer.push_back(), MuonDigiCollection< CSCDetId, CSCCLCTDigi >.put(), SurveyPxbImageReader< T >.read(), DTCalibrationMap.readConsts(), RunInfoRead.readData(), LmfSource.readEventWithinFile(), EcalTBReadout.readOut(), Model.readSystemDescription(), DTRefitAndCombineReco4D.refitSuperSegments(), edm::soa::Table< Args >.resizeFromTo(), PhiMemoryImage.rotl(), PhiMemoryImage.rotr(), HGCalDDDConstants.rowColumnWafer(), run(), magfieldparam::rz_poly.rz_poly(), edm::Schedule.Schedule(), SeedTransformer.seedTransform(), edm::StreamerOutputModuleBase.serializeEvent(), edm::StreamerOutputModuleBase.serializeRegistry(), edm::DataFrameContainer.set_back(), lumi::LumiSectionData.setBunchCrossingData(), lumi::LumiSectionData.setHLTData(), l1t::stage2::MuonUnpacker.setMuonCopy(), lumi::LumiSectionData.setTriggerData(), PhysicsTools::MVAComputer.setup(), DQMStore.showDirStructure(), SiStripDetInfoFileReader.SiStripDetInfoFileReader(), SiStripHashedDetId.SiStripHashedDetId(), cond::SmallWORMDict.SmallWORMDict(), edm::DataFrameContainer.sort(), MuonDetLayerGeometry.sortLayers(), TrackerGeometryCompare.surveyToTracker(), edm::SystemTimeKeeper.SystemTimeKeeper(), topLevelPSet(), TrackerStablePhiSort(), reco::TrackExtrapolation.TrackExtrapolation(), TrackMVAClassifierBase.TrackMVAClassifierBase(), TrackTransformerForCosmicMuons.transform(), edm::TransientDataFrame< SIZE >.TransientDataFrame(), MuonTransientTrackingRecHit.transientHits(), MuonTrackLoader.unpackHit(), l1t::stage2.unpacking(), PrintGeomInfoAction.update(), SimG4FluxProducer.update(), HGCPassive.update(), sistrip::RawToDigiUnpacker.update(), Version.Version(), AdaptiveVertexReconstructor.vertices(), HGCalDDDConstants.volumes(), DTCalibrationMap.writeConsts(), EcalDccWeightBuilder.writeWeightToRootFile(), and ext::basic_omemstream< Item_t, Traits_t, Allocator_t >.xsputn().

124 def copy( args ):
125  destDb = args.destDb
126  destTag = args.destTag
127  comment = args.comment
128 
129  datef = datetime.now()
130  destMap = { "oracle://cms_orcoff_prep/cms_conditions": "oradev", "oracle://cms_orcon_prod/cms_conditions": "onlineorapro" }
131  if destDb.lower() in destMap.keys():
132  destDb = destMap[destDb.lower()]
133  else:
134  logger.error( 'Destination connection %s is not supported.' %destDb )
135  return
136  # run the copy
137  note = '"Importing data with O2O execution"'
138  commandOptions = '--force --yes --db %s copy %s %s --destdb %s --synchronize --note %s' %(dbFileName,destTag,destTag,destDb,note)
139  copyCommand = 'conddb %s' %commandOptions
140  logger.info( 'Executing command: %s' %copyCommand )
141  try:
142  pipe = subprocess.Popen( copyCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
143  stdout = pipe.communicate()[0]
144  print stdout
145  retCode = pipe.returncode
146  if retCode != 0:
147  saveFileForImportErrors( datef )
148  ret = retCode
149  except Exception as e:
150  ret = 1
151  logger.error( str(e) )
152  return ret
153 
def saveFileForImportErrors(datef, withMetadata=False)
def popcon2dropbox.run (   args)

Definition at line 154 of file popcon2dropbox.py.

References checkFile(), copy(), and upload().

154 def run( args ):
155  if args.auth is not None and not args.auth=='':
156  if auth_path_key in os.environ:
157  logger.warning("Cannot set authentication path to %s in the environment, since it is already set." %args.auth)
158  else:
159  logger.info("Setting the authentication path to %s in the environment." %args.auth)
160  os.environ[auth_path_key]=args.auth
161  if os.path.exists( '%s.db' %dbName ):
162  logger.info("Removing files with name %s" %dbName )
163  os.remove( '%s.db' %dbName )
164  if os.path.exists( '%s.txt' %dbName ):
165  os.remove( '%s.txt' %dbName )
166  command = 'cmsRun %s ' %args.job_file
167  command += ' destinationDatabase=%s' %args.destDb
168  command += ' destinationTag=%s' %args.destTag
169  command += ' 2>&1'
170  pipe = subprocess.Popen( command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
171  stdout = pipe.communicate()[0]
172  retCode = pipe.returncode
173  print stdout
174  logger.info('PopCon Analyzer return code is: %s' %retCode )
175  if retCode!=0:
176  logger.error( 'O2O job failed. Skipping upload.' )
177  return retCode
178 
179  ret = checkFile()
180  if ret < 0:
181  return ret
182  elif ret == 0:
183  return 0
184  if args.copy:
185  return copy( args )
186  return upload( args )
187 
def upload(args)
def popcon2dropbox.saveFileForImportErrors (   datef,
  withMetadata = False 
)

Definition at line 61 of file popcon2dropbox.py.

Referenced by copy(), and upload().

61 def saveFileForImportErrors( datef, withMetadata=False ):
62  # save a copy of the files in case of upload failure...
63  leafFolderName = datef.strftime(dateformatForFolder)
64  fileFolder = os.path.join( errorInImportFileFolder, leafFolderName)
65  if not os.path.exists(fileFolder):
66  os.makedirs(fileFolder)
67  df= '%s.db' %dbName
68  dataDestFile = os.path.join( fileFolder, df)
69  if not os.path.exists(dataDestFile):
70  shutil.copy2(df, dataDestFile)
71  if withMetadata:
72  mf= '%s.txt' %dbName
73  metadataDestFile = os.path.join( fileFolder, mf )
74  if not os.path.exists(metadataDestFile):
75  shutil.copy2(df, metadataDestFile)
76  logger.error("Upload failed. Data file and metadata saved in folder '%s'" %os.path.abspath(fileFolder))
77 
def saveFileForImportErrors(datef, withMetadata=False)
def popcon2dropbox.upload (   args)

Definition at line 78 of file popcon2dropbox.py.

References saveFileForImportErrors(), and harvestTrackValidationPlots.str.

Referenced by run().

78 def upload( args ):
79  destDb = args.destDb
80  destTag = args.destTag
81  comment = args.comment
82 
83  datef = datetime.now()
84 
85  # first remove any existing metadata file...
86  if os.path.exists( '%s.txt' %dbName ):
87  logger.debug('Removing already existing file %s' %dbName)
88  os.remove( '%s.txt' %dbName )
89 
90  # dump Metadata for the Upload
91  uploadMd = {}
92  uploadMd['destinationDatabase'] = destDb
93  tags = {}
94  tagInfo = {}
95  tags[ destTag ] = tagInfo
96  uploadMd['destinationTags'] = tags
97  uploadMd['inputTag'] = destTag
98  uploadMd['since'] = None
99  datelabel = datef.strftime(dateformatForLabel)
100  commentStr = ''
101  if not comment is None:
102  commentStr = comment
103  uploadMd['userText'] = '%s : %s' %(datelabel,commentStr)
104  with open( '%s.txt' %dbName, 'wb') as jf:
105  jf.write( json.dumps( uploadMd, sort_keys=True, indent = 2 ) )
106  jf.write('\n')
107 
108  # run the upload
109  uploadCommand = 'uploadConditions.py %s' %dbName
110  ret = 0
111  try:
112  pipe = subprocess.Popen( uploadCommand, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
113  stdout = pipe.communicate()[0]
114  print stdout
115  retCode = pipe.returncode
116  if retCode != 0:
117  saveFileForImportErrors( datef, True )
118  ret |= retCode
119  except Exception as e:
120  ret |= 1
121  logger.error(str(e))
122  return ret
123 
def upload(args)
def saveFileForImportErrors(datef, withMetadata=False)