11from __future__ import print_function
22
3+ from datetime import datetime
4+ import ROOT
35import configparser as ConfigParser
6+ import datetime
47import glob
5- import os
8+ import json
69import numpy
10+ import optparse
11+ import os
712import re
8- import ROOT
13+ import sqlalchemy
914import string
1015import subprocess
1116import sys
12- import optparse
1317import time
14- import json
15- import datetime
16- from datetime import datetime
1718import CondCore .Utilities .conddblib as conddb
1819
1920##############################################
@@ -59,6 +60,14 @@ def build_curl_command(url, proxy="", certs="", timeout=30, retries=3, user_agen
5960 cmd += f'--connect-timeout { timeout } --retry { retries } { url } '
6061 return cmd
6162
63+ ##############################################
64+ def get_hlt_fcsr (session ):
65+ ##############################################
66+ RunInfo = session .get_dbtype (conddb .RunInfo )
67+ lastRun = session .query (sqlalchemy .func .max (RunInfo .run_number )).scalar ()
68+ fcsr = lastRun + 1
69+ return int (fcsr )
70+
6271##############################################
6372def getFCSR (proxy = "" , certs = "" ):
6473##############################################
@@ -86,6 +95,24 @@ def getExpressGT(proxy="", certs=""):
8695 response = json .loads (out )["result" ][0 ]['global_tag' ]
8796 return response
8897
98+ ##############################################
99+ def resetSynchonization (db_name ):
100+ ##############################################
101+ import sqlite3
102+
103+ # Connect to the SQLite database
104+ conn = sqlite3 .connect (db_name )
105+
106+ # Create a cursor object to execute SQL commands
107+ cursor = conn .cursor ()
108+
109+ # Execute the SQL command to update the database
110+ cursor .execute ("UPDATE TAG SET SYNCHRONIZATION='any' WHERE SYNCHRONIZATION='express';" )
111+
112+ # Commit the changes and close the connection
113+ conn .commit ()
114+ conn .close ()
115+
89116##############################################
90117if __name__ == "__main__" :
91118##############################################
@@ -130,10 +157,12 @@ def getExpressGT(proxy="", certs=""):
130157 FCSR = getFCSR (proxy = options .proxy , certs = certs )
131158 promptGT = getPromptGT (proxy = options .proxy , certs = certs )
132159 expressGT = getExpressGT (proxy = options .proxy , certs = certs )
133- print ("Current FCSR:" ,FCSR ,"| Express Global Tag" ,expressGT ,"| Prompt Global Tag" ,promptGT )
134160
135161 con = conddb .connect (url = conddb .make_url ("pro" ))
136162 session = con .session ()
163+
164+ HLTFCSR = get_hlt_fcsr (session )
165+ print ("Current next HLT run" , HLTFCSR , "| curret FCSR:" , FCSR ,"| Express Global Tag" ,expressGT ,"| Prompt Global Tag" ,promptGT )
137166 IOV = session .get_dbtype (conddb .IOV )
138167 TAG = session .get_dbtype (conddb .Tag )
139168 GT = session .get_dbtype (conddb .GlobalTag )
@@ -154,12 +183,12 @@ def getExpressGT(proxy="", certs=""):
154183 IOVsToValidate = []
155184 if (options .since == - 1 ):
156185 IOVsToValidate .append (validationTagIOVs [- 1 ][0 ])
157- print ("changing the default validation tag since to:" ,IOVsToValidate [0 ])
186+ print ("Changing the default validation tag since to:" ,IOVsToValidate [0 ])
158187
159188 else :
160189 for entry in validationTagIOVs :
161190 if (options .since != 1 and int (entry [0 ])>= int (options .since )):
162- print ("appending to the validation list:" ,entry [0 ],entry [1 ],entry [2 ])
191+ print ("Appending to the validation list:" ,entry [0 ],entry [1 ],entry [2 ])
163192 IOVsToValidate .append (entry [0 ])
164193
165194 for element in myGTMap :
@@ -169,24 +198,33 @@ def getExpressGT(proxy="", certs=""):
169198 Tag = element [2 ]
170199 if (Record == "SiStripApvGain2Rcd" ):
171200 TagIOVs = session .query (IOV .since ,IOV .payload_hash ,IOV .insertion_time ).filter (IOV .tag_name == Tag ).all ()
172- lastG2Payload = TagIOVs [- 1 ]
173- print ("last payload has IOV since:" ,lastG2Payload [0 ],"payload hash:" ,lastG2Payload [1 ],"insertion time:" ,lastG2Payload [2 ])
201+ sorted_TagIOVs = sorted (TagIOVs , key = lambda x : x [0 ])
202+ lastG2Payload = sorted_TagIOVs [- 1 ]
203+ print ("Last G2 Prompt payload has IOV since:" ,lastG2Payload [0 ],"payload hash:" ,lastG2Payload [1 ],"insertion time:" ,lastG2Payload [2 ])
204+
205+ # Get and print the current working directory
206+ current_directory = os .getcwd ()
207+ print ("Current Working Directory:" , current_directory )
208+
174209 command = 'conddb_import -c sqlite_file:toCompare.db -f frontier://FrontierProd/CMS_CONDITIONS -i ' + str (Tag ) + ' -t ' + str (Tag )+ ' -b ' + str (lastG2Payload [0 ])
175210 print (command )
176211 getCommandOutput (command )
177212
213+ # set syncrhonization to any
214+ resetSynchonization ("toCompare.db" )
215+
178216 for i ,theValidationTagSince in enumerate (IOVsToValidate ):
179217
180218 command = 'conddb_import -c sqlite_file:toCompare.db -f frontier://FrontierPrep/CMS_CONDITIONS -i ' + str (options .validationTag ) + ' -t ' + str (Tag )+ ' -b ' + str (theValidationTagSince )
181219 if (theValidationTagSince < lastG2Payload [0 ]):
182- print ("the last available IOV in the validation tag is older than the current last express IOV, taking FCSR as a since!" )
220+ print ("The last available IOV in the validation tag is older than the current last express IOV, taking FCSR as a since!" )
183221 command = 'conddb_import -c sqlite_file:toCompare.db -f frontier://FrontierPrep/CMS_CONDITIONS -i ' + str (options .validationTag ) + ' -t ' + str (Tag )+ ' -b ' + str (FCSR + i )
184222
185223 print (command )
186224 getCommandOutput (command )
187225
188- command = './ testCompare.sh SiStripApvGain_FromParticles_GR10_v1_express ' + str (lastG2Payload [0 ])+ ' ' + str (theValidationTagSince )+ ' toCompare.db'
226+ command = '${CMSSW_BASE}/src/CondCore/SiStripPlugins/scripts/ testCompare.sh SiStripApvGain_FromParticles_GR10_v1_express ' + str (lastG2Payload [0 ])+ ' ' + str (theValidationTagSince )+ ' ' + current_directory + '/ toCompare.db'
189227 if (theValidationTagSince < lastG2Payload [0 ]):
190- command = './ testCompare.sh SiStripApvGain_FromParticles_GR10_v1_express ' + str (lastG2Payload [0 ])+ ' ' + str (FCSR + i )+ ' toCompare.db'
228+ command = '${CMSSW_BASE}/src/CondCore/SiStripPlugins/scripts/ testCompare.sh SiStripApvGain_FromParticles_GR10_v1_express ' + str (lastG2Payload [0 ])+ ' ' + str (FCSR + i )+ ' ' + current_directory + '/ toCompare.db'
191229 print (command )
192230 getCommandOutput (command )
0 commit comments