CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
command_line Namespace Reference

Functions

def copy_global_tag
 
def copy_tag
 
def diff_of_gts
 
def diff_of_tags
 
def list_object
 
def parse_command_line
 
def search
 

Variables

 dest_tag
 
 end
 
 input_tag
 
 start
 

Function Documentation

def command_line.copy_global_tag (   arguments)

Definition at line 139 of file command_line.py.

References submitPVValidationJobs.__init__(), writedatasetfile.args, querying.connect(), and data.

140 def copy_global_tag(arguments):
141  raise NotImplementedError("Copying Global Tags is currently not supported for this transition command-line interface for CondDBFW.")
142 
143  # set up connection
144  source_connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode, map_blobs=True)
145  dest_connection = querying.connect(arguments.dest_db, secrets=arguments.secrets, mode=arguments.mode, map_blobs=True)
146 
147  # get CondDBFW Global Tag object
148  global_tag = source_connection.global_tag(name=arguments.input_gt)
149  if global_tag == None:
150  raise Exception("Source Global Tag doesn't exist.")
151 
152  tag_names = global_tag.tags().get_members("tag_name").data()
153  tags = source_connection.tag(name=tags)
154 
155  # copy global tag first
156  global_tag.insertion_time = datetime.datetime.utcnow()
157  global_tag.validity = -1
158  dest_connection.write_and_commit(global_tag)
159 
160  for tag in tags:
161  # create temporary argument class
162  class args(object):
163  def __init__(self):
164  self.input_tag = tag.name
165  self.dest_tag = tag.name
166  self.start = 1
167  self.end = tag.latest_iov()+1
168  for attribute in dir(arguments):
169  self.__dict__[attribute] = getattr(arguments, attribute)
170 
171  copy_tag(args())
def connect
Definition: querying.py:453
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
def command_line.copy_tag (   arguments)

Definition at line 85 of file command_line.py.

References querying.connect(), data, and print().

85 
86 def copy_tag(arguments):
87 
88  # set up connection
89  source_connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode, map_blobs=True)
90  dest_connection = querying.connect(arguments.dest_db, secrets=arguments.secrets, mode=arguments.mode, map_blobs=True)
91 
92  # get tag from the source database, adjust it, and copy it (with the defined IOV range) to the destination database
93 
94  print("Reading source Tag.")
95  source_tag = source_connection.tag(name=arguments.input_tag)
96  if source_tag == None:
97  raise Exception("Source Tag doesn't exist.")
98 
99  # get all IOVs within the range [start, end]
100  print("Reading source IOVs.")
101  since_range = source_connection.range(arguments.start, arguments.end)
102  source_iovs = source_tag.iovs(since=since_range).data()
103 
104  # get hashes of all IOVs contained in the Tag in the source database
105  print("Reading source Payloads.")
106  hashes = source_tag.iovs().get_members("payload_hash").data()
107  payloads = source_connection.payload(hash=hashes)
108 
109  print("Writing to destination database...")
110 
111  # set end_of_validity to -1 because sqlite doesn't support long ints
112  source_tag.end_of_validity = -1
113  source_tag.name = arguments.dest_tag
114  source_tag.modification_time = datetime.datetime.utcnow()
115 
116  # create new iovs
117  new_iovs = []
118  for iov in source_iovs:
119  new_iovs.append(dest_connection.models["iov"](iov.as_dicts(convert_timestamps=False), convert_timestamps=False))
120 
121  # write new tag to destination database
122  print("Writing destination Tag.")
123  if dest_connection.tag(name=arguments.dest_tag) != None:
124  dest_connection.write_and_commit(source_tag)
125 
126  # write new iovs
127  print("Writing IOVs to destination Tag.")
128  for iov in new_iovs:
129  if dest_connection.iov(tag_name=iov.tag_name, since=iov.since, insertion_time=iov.insertion_time) == None:
130  dest_connection.write_and_commit(iov)
131 
132  # get payloads used by IOVs and copy those over
133  print("Copying Payloads over.")
134  for payload in payloads:
135  if dest_connection.payload(hash=payload.hash) == None:
136  dest_connection.write_and_commit(payload)
137 
138  print("Copy complete.")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def connect
Definition: querying.py:453
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
def command_line.diff_of_gts (   arguments)

Definition at line 65 of file command_line.py.

References querying.connect().

65 
66 def diff_of_gts(arguments):
67  # get a CondDBFW Global Tag object for the first GT
68  # then use the diff() method to draw the table of differences
69 
70  # set up connection
71  connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode)
72 
73  gt1 = connection.global_tag(name=arguments.gt1)
74  gt2 = connection.global_tag(name=arguments.gt2)
75 
76  gt1.diff(gt2).as_table(columns=["Record", "Label", "%s Tag" % arguments.gt1, "%s Tag" % arguments.gt2])
def connect
Definition: querying.py:453
def command_line.diff_of_tags (   arguments)

Definition at line 53 of file command_line.py.

References querying.connect().

53 
54 def diff_of_tags(arguments):
55  # get a CondDBFW Tag object for the first tag
56  # then use the diff() method to draw the table of differences
57 
58  # set up connection
59  connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode)
60 
61  tag1 = connection.tag(name=arguments.tag1)
62  tag2 = connection.tag(name=arguments.tag2)
63 
64  tag1.diff(tag2).as_table(columns=["since", arguments.tag1, arguments.tag2])
def connect
Definition: querying.py:453
def command_line.list_object (   arguments)

Definition at line 13 of file command_line.py.

References querying.connect(), beamvalidation.exit(), and print().

13 
14 def list_object(arguments):
15 
16  # set up connection
17  connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode)
18 
19  options = ["tag", "gt", "gts_for_tag"]
20  number_of_options_given = 0
21  for option in options:
22  if getattr(arguments, option):
23  number_of_options_given += 1
24  if number_of_options_given != 1:
25  print("You must specify a single object to list.")
26  exit()
27 
28  if arguments.tag:
29  tag_name = arguments.tag
30  tag = connection.tag(name=tag_name)
31  if tag:
32  iovs = tag.iovs(amount=arguments.limit)
33  iovs.as_table()
34  else:
35  print("The Tag '%s' was not found in the database '%s'." % (tag_name, arguments.db))
36  exit()
37 
38  elif arguments.gt:
39  gt_name = arguments.gt
40  gt = connection.global_tag(name=gt_name)
41  if gt:
42  gt_maps = gt.tags(amount=arguments.limit)
43  gt_maps.as_table(hide=["global_tag_name"])
44  else:
45  print("The Global Tag '%s' was not found in the database '%s'." % (gt_name, arguments.db))
46  exit()
47 
48  elif arguments.gts_for_tag:
49  tag_name = arguments.gts_for_tag
50  tag = connection.tag(name=tag_name)
51  gts = tag.parent_global_tags(amount=arguments.limit)
52  gts.as_table(columns=["name", "insertion_time", "snapshot_time"])
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def connect
Definition: querying.py:453
def command_line.parse_command_line (   arguments)
Assumes script name has been removed from the list of arguments.
Hence, arguments[0] is the subcommand.

Definition at line 172 of file command_line.py.

References print().

173 def parse_command_line(arguments):
174  """
175  Assumes script name has been removed from the list of arguments.
176  Hence, arguments[0] is the subcommand.
177  """
178  top_level_parser = argparse.ArgumentParser(description="CondDBFW Command line tool")
179  top_level_parser.add_argument("--db", type=str, required=False, default="frontier://FrontierProd/CMS_CONDITIONS")
180  top_level_parser.add_argument("--mode", type=str, required=False, default="w")
181  top_level_parser.add_argument("--secrets", type=str, required=False)
182  top_level_parser.add_argument("--limit", type=int, required=False, default=10)
183 
184  subparser = top_level_parser.add_subparsers(title="Subcommands")
185 
186  list_parser = subparser.add_parser("list", description="Lists the Metadata objects contained within the given object.")
187  list_parser.add_argument("--tag", required=False, help="List all IOVs in a Tag.")
188  list_parser.add_argument("--gt", required=False, help="List all Global Tag Maps linked to a Global Tag.")
189  list_parser.add_argument("--gts-for-tag", required=False, help="List all Global Tags that contain a Tag.")
190 
191  list_parser.set_defaults(func=list_object)
192 
193  diff_parser = subparser.add_parser("diff-tags", description="Gives the differences in payload hashes used by IOVs between Tags.")
194  diff_parser.add_argument("--tag1", required=True, help="First Tag to use in the comparison.")
195  diff_parser.add_argument("--tag2", required=True, help="Second Tag to use in the comparison.")
196 
197  diff_parser.set_defaults(func=diff_of_tags)
198 
199  gt_diff_parser = subparser.add_parser("diff-gts", description="Gives the differences in Global Tag Maps contained within Global Tag.")
200  gt_diff_parser.add_argument("--gt1", required=True, help="First Global Tag to use in the comparison.")
201  gt_diff_parser.add_argument("--gt2", required=True, help="Second Global Tag to use in the comparison.")
202 
203  gt_diff_parser.set_defaults(func=diff_of_gts)
204 
205  copy_tag_parser = subparser.add_parser("copy-tag", description="Copies a Tag with its IOVs and Payloads to a destination database."
206  + "\nFor copying to official databases, use cmsDbCondUpload (https://cms-conddb-dev.cern.ch/cmsDbCondUpload).")
207  copy_tag_parser.add_argument("--dest-db", required=True, help="Database to copy the Tag and its IOVs to.")
208  copy_tag_parser.add_argument("--input-tag", required=True, help="Tag to take data from in source database.")
209  copy_tag_parser.add_argument("--dest-tag", required=True, help="Tag to copy input Tag to in the destination database.")
210  copy_tag_parser.add_argument("--start", required=True, help="Since to start from. If this is between two, the highest one is taken (no adjustments are made).")
211  copy_tag_parser.add_argument("--end", required=True, help="Since to finidh at. If this is between two, the lowest one is taken (no adjustments are made).")
212 
213  copy_tag_parser.set_defaults(func=copy_tag)
214 
215  parsed_arguments = top_level_parser.parse_args()
216 
217  print("Using database '%s'." % parsed_arguments.db)
218 
219  parsed_arguments.func(parsed_arguments)
def parse_command_line
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def command_line.search (   arguments)

Definition at line 77 of file command_line.py.

References querying.connect().

77 
78 def search(arguments):
79 
80  raise NotImplementedError("Todo")
81 
82  connection = querying.connect(arguments.db, secrets=arguments.secrets, mode=arguments.mode)
83 
84  search_string = connection.regexp(".*%s.*" % arguments.string)
def connect
Definition: querying.py:453

Variable Documentation

command_line.dest_tag

Definition at line 164 of file command_line.py.

command_line.end

Definition at line 166 of file command_line.py.

command_line.input_tag

Definition at line 163 of file command_line.py.

command_line.start

Definition at line 165 of file command_line.py.

Referenced by HBHERecHitProducerGPU.acquire(), l1tVertexFinder::VertexFinder.adaptiveVertexReconstruction(), L1TMP7ZeroSupp.analyze(), EcalDumpRaw.analyze(), HLTObjectMonitorProtonLead.analyze(), HLTObjectMonitor.analyze(), RunInfoUpdate.appendNewRun(), L1TDTTF.bookHistograms(), EcalBoundaryInfoCalculator< EcalDetId >.boundaryRecHits(), GEMGeometryParsFromDD.buildGeometry(), L1TDTTFClient.buildPhiEtaPlotO(), L1TDTTFClient.buildPhiEtaPlotOFC(), edm::storage::LocalCacheFile.cache(), HIPAlignmentAlgorithm.calcParameters(), tkDetUtil.calculatePhiWindow(), CalibrationScanTask.CalibrationScanTask(), CalibrationTask.CalibrationTask(), SimpleCosmicBONSeeder.checkNoisyModules(), convertFile(), LegacyIOHelper.createDirectoryIfNeededAndCd(), edm::soahelper::SoATupleHelper< I, Args >.destroy(), edm::VParameterSetEntry.dump(), FWLiteEnabler.enable(), ElectronCalibrationUniv.endJob(), trklet::TrackletEngine.execute(), trklet::TripletEngine.execute(), trklet::TrackletEngineDisplaced.execute(), trklet::TrackletProcessor.execute(), MagFieldConfig.expandList(), TotemSampicFrame.extractDataFromBytesLSB(), EZArrayFL< GlobalPoint >.EZArrayFL(), EcalCondDBInterface.fetchDCSPTMTempList(), DCSPTMTempList.fetchValuesForECIDAndTime(), CSCConditions.fillBadStripWord(), CSCConditions.fillBadWireWord(), MuonResidualsBfieldAngleFitter.fit(), MuonResidualsPositionFitter.fit(), MuonResidualsAngleFitter.fit(), MuonResiduals1DOFFitter.fit(), MuonResiduals6DOFrphiFitter.fit(), MuonResiduals5DOFFitter.fit(), MuonResiduals6DOFFitter.fit(), hgcalsimclustertime::ComputeClusterTime.fixSizeHighestDensity(), EcalBoundaryInfoCalculator< EcalDetId >.gapRecHits(), L1UpgradeTfMuonTreeProducer.getAlgoFwVersion(), EcalBarrelGeometry.getClosestCell(), DTTimeBoxFitter.getFitSeeds(), cond::persistency::RunInfoEditor.getLastInserted(), StripCompactDigiSimLinks.getLinks(), popcon::EcalLaser_weekly_Handler.getNewObjects(), LMFRunIOV.getParameters(), TrackAssociatorByPositionImpl.getState(), edm::storage::StormLcgGtStorageMaker.getTURL(), edm::storage::StormStorageMaker.getTURL(), HcalDigisClient.HcalDigisEndjob(), RunInfoUpdate.import(), JetCorrectorParametersHelper.init(), HcalZSAlgoRealistic.keepMe(), edm::EDConsumerBase.labelsForToken(), evf::EvFDaqDirector.make_flock(), DeepFlavourONNXJetTagsProducer.make_inputs(), DeepCombinedONNXJetTagsProducer.make_inputs(), DeepVertexONNXJetTagsProducer.make_inputs(), DeepDoubleXONNXJetTagsProducer.make_inputs(), StripCompactDigiSimLinks.makeReverseMap(), MatcherUsingTracksAlgorithm.match(), edm::ProductResolverIndexHelper::Matches.moduleLabel(), RKPropagatorInZ.myPropagate(), RKPropagatorInR.myPropagate(), CSCFileReader.nextEventFromFUs(), offsetBy(), RK4PreciseStep.operator()(), CartesianLorentzForce.operator()(), MeasurementByLayerGrouper.operator()(), edm.operator<<(), HcalTBObjectUnpacker.parseCalib(), pos::PixelFEDTestDAC.PixelFEDTestDAC(), edm::service::StallMonitor.postModuleEventPrefetching(), edm::storage::LocalCacheFile.prefetch(), edm::service::StallMonitor.preModuleEvent(), edm::service::StallMonitor.preModuleEventAcquire(), prettyPrint(), l1t::Stage2Layer2DemuxJetAlgoFirmwareImp1.processEvent(), dqmBmtfAlgoSelector::L1TBMTFAlgoSelector.produce(), l1t::L1TRawToDigi.produce(), edm::ProductResolverIndexHelper::Matches.productInstanceName(), RKPropagatorInS.propagateParametersOnCylinder(), RKPropagatorInS.propagateParametersOnPlane(), l1tVertexFinder::VertexFinder.PVR(), FileReaderDCC.read(), FileReaderDDU.read(), RunInfoRead.readData(), L1MuRegionalCand.readDataField(), L1MuGMTCand.readDataField(), edm::storage::LocalCacheFile.readv(), edm::storage::XrdFile.readv(), FedRawDataInputSource.readWorker(), L1MuBMExtrapolationUnit.run(), L1MuDTExtrapolationUnit.run(), HGCFEElectronics< DFr >.runShaperWithToT(), CTPPSOpticalFunctionsESSource.setIntervalFor(), PPSAssociationCutsESSource.setIntervalFor(), CondDBESSource.setIntervalFor(), CSCCFEBData.setL1A(), gen::Pythia6Service.setPYUPDAParams(), RunIOV.setRunStart(), gen::Pythia6Service.setSLHAParams(), LMFIOV.setStart(), DCSPTMTemp.setStart(), MODRunIOV.setSubRunStart(), MonRunIOV.setSubRunStart(), RunDCSMagnetDat.setTime(), ecaldqm::MESetTrend.shift_(), HcalZSAlgoRealistic.shouldKeep(), CastorDbASCIIIO.splitString(), HcalQIEManager.splitString(), splitString(), splitStringToDoubleByComma(), splitStringToFloatByComma(), splitStringToIntByComma(), CosmicMuonUtilities.stepPropagate(), pos::PixelTimeFormatter.stopTimer(), TrackerScenarioBuilder.stripOffModule(), APVGain.subdetectorPlane(), TkStripMeasurementDet.testStrips(), th1ToFormulaBinTree(), CSCCFEBData.timeSlice(), TkOfflineVariables.TkOfflineVariables(), edm::VParameterSetEntry.toString(), edm::ParameterSet.toStringImp(), KFTrajectorySmoother.trajectory(), L1MuRegionalCand.writeDataField(), L1MuGMTCand.writeDataField(), LMFUnique.writeDB(), and trklet::DTCLinkMemory.writeStubs().