@@ -151,7 +151,7 @@ def addTransformation(
151
151
res = self ._getTransformationID (transName , connection = connection )
152
152
if res ["OK" ]:
153
153
return S_ERROR (
154
- "Transformation with name %s already exists with TransformationID = %d" % ( transName , res [" Value" ])
154
+ f "Transformation with name { transName } already exists with TransformationID = { res [' Value' ] } "
155
155
)
156
156
elif res ["Message" ] != "Transformation does not exist" :
157
157
return res
@@ -229,7 +229,7 @@ def addTransformation(
229
229
if not res ["OK" ]:
230
230
gLogger .error ("Failed to update parent transformation agent type, now deleting" , res ["Message" ])
231
231
return self .deleteTransformation (transID , connection = connection )
232
- message = "Creation of the derived transformation (%d)" % transID
232
+ message = f "Creation of the derived transformation ({ transID } )"
233
233
self .__updateTransformationLogging (originalID , message , author , connection = connection )
234
234
res = self .getTransformationFiles (condDict = {"TransformationID" : originalID }, connection = connection )
235
235
if not res ["OK" ]:
@@ -264,7 +264,7 @@ def addTransformation(
264
264
res = self .__addFilesToTransformation (transID , fileIDs , connection = connection )
265
265
if not res ["OK" ]:
266
266
gLogger .error ("Failed to add files to transformation" , f"{ transID } { res ['Message' ]} " )
267
- message = "Created transformation %d" % transID
267
+ message = f "Created transformation { transID } "
268
268
269
269
self .__updateTransformationLogging (transID , message , author , connection = connection )
270
270
return S_OK (transID )
@@ -401,24 +401,16 @@ def __updateTransformationParameter(self, transID, paramName, paramValue, connec
401
401
if not res ["OK" ]:
402
402
return S_ERROR ("Failed to parse parameter value" )
403
403
paramValue = res ["Value" ]
404
- req = "UPDATE Transformations SET %s=%s, LastUpdate=UTC_TIMESTAMP() WHERE TransformationID=%d" % (
405
- paramName ,
406
- paramValue ,
407
- transID ,
408
- )
404
+ req = f"UPDATE Transformations SET { paramName } ={ paramValue } , LastUpdate=UTC_TIMESTAMP() WHERE TransformationID={ transID } "
409
405
return self ._update (req , conn = connection )
410
- req = "UPDATE Transformations SET %s='%s', LastUpdate=UTC_TIMESTAMP() WHERE TransformationID=%d" % (
411
- paramName ,
412
- paramValue ,
413
- transID ,
414
- )
406
+ req = f"UPDATE Transformations SET { paramName } ={ paramValue } , LastUpdate=UTC_TIMESTAMP() WHERE TransformationID={ transID } "
415
407
return self ._update (req , conn = connection )
416
408
417
409
def _getTransformationID (self , transName , connection = False ):
418
410
"""Method returns ID of transformation with the name=<name>"""
419
411
try :
420
412
transName = int (transName )
421
- cmd = "SELECT TransformationID from Transformations WHERE TransformationID=%d;" % transName
413
+ cmd = f "SELECT TransformationID from Transformations WHERE TransformationID={ transName } ;"
422
414
except ValueError :
423
415
if not isinstance (transName , str ):
424
416
return S_ERROR ("Transformation should be ID or name" )
@@ -433,7 +425,7 @@ def _getTransformationID(self, transName, connection=False):
433
425
return S_OK (res ["Value" ][0 ][0 ])
434
426
435
427
def __deleteTransformation (self , transID , connection = False ):
436
- req = "DELETE FROM Transformations WHERE TransformationID=%d;" % transID
428
+ req = f "DELETE FROM Transformations WHERE TransformationID={ transID } ;"
437
429
return self ._update (req , conn = connection )
438
430
439
431
def __updateFilterQueries (self , connection = False ):
@@ -513,7 +505,7 @@ def deleteTransformationParameter(self, transName, paramName, author="", connect
513
505
return res
514
506
515
507
def __addAdditionalTransformationParameter (self , transID , paramName , paramValue , connection = False ):
516
- req = "DELETE FROM AdditionalParameters WHERE TransformationID=%d AND ParameterName='%s'" % ( transID , paramName )
508
+ req = f "DELETE FROM AdditionalParameters WHERE TransformationID={ transID } AND ParameterName='{ paramName } '"
517
509
res = self ._update (req , conn = connection )
518
510
if not res ["OK" ]:
519
511
return res
@@ -552,7 +544,7 @@ def __deleteTransformationParameters(self, transID, parameters=None, connection=
552
544
"""Remove the parameters associated to a transformation"""
553
545
if parameters is None :
554
546
parameters = []
555
- req = "DELETE FROM AdditionalParameters WHERE TransformationID=%d" % transID
547
+ req = f "DELETE FROM AdditionalParameters WHERE TransformationID={ transID } "
556
548
if parameters :
557
549
req = f"{ req } AND ParameterName IN ({ stringListToString (parameters )} );"
558
550
return self ._update (req , conn = connection )
@@ -778,15 +770,7 @@ def __insertExistingTransformationFiles(self, transID, fileTuplesList, connectio
778
770
if taskID :
779
771
# Should be readable up to 999,999 tasks: that field is an int(11) in the DB, not a string
780
772
taskID = 1000000 * int (originalID ) + int (taskID )
781
- req = "%s (%d,'%s','%d',%d,'%s','%s',UTC_TIMESTAMP())," % (
782
- req ,
783
- transID ,
784
- status ,
785
- taskID ,
786
- fileID ,
787
- targetSE ,
788
- usedSE ,
789
- )
773
+ req = f"{ req } ({ transID } ,'{ status } ','{ taskID } ',{ fileID } ,'{ targetSE } ','{ usedSE } ',UTC_TIMESTAMP()),"
790
774
if not candidates :
791
775
continue
792
776
@@ -877,12 +861,12 @@ def __deleteTransformationFileTask(self, transID, taskID, connection=False):
877
861
"""Delete the file associated to a given task of a given transformation
878
862
from the TransformationFileTasks table for transformation with TransformationID and TaskID
879
863
"""
880
- req = "DELETE FROM TransformationFileTasks WHERE TransformationID=%d AND TaskID=%d" % ( transID , taskID )
864
+ req = f "DELETE FROM TransformationFileTasks WHERE TransformationID={ transID } AND TaskID={ taskID } "
881
865
return self ._update (req , conn = connection )
882
866
883
867
def __deleteTransformationFileTasks (self , transID , connection = False ):
884
868
"""Remove all associations between files, tasks and a transformation"""
885
- req = "DELETE FROM TransformationFileTasks WHERE TransformationID = %d;" % transID
869
+ req = f "DELETE FROM TransformationFileTasks WHERE TransformationID = { transID } "
886
870
res = self ._update (req , conn = connection )
887
871
if not res ["OK" ]:
888
872
gLogger .error ("Failed to delete transformation files/task history" , res ["Message" ])
@@ -997,7 +981,7 @@ def deleteTasks(self, transName, taskIDbottom, taskIDtop, author="", connection=
997
981
res = self .__removeTransformationTask (transID , taskID , connection = connection )
998
982
if not res ["OK" ]:
999
983
return res
1000
- message = "Deleted tasks from %d to %d" % ( taskIDbottom , taskIDtop )
984
+ message = f "Deleted tasks from { taskIDbottom } to { taskIDtop } "
1001
985
self .__updateTransformationLogging (transID , message , author , connection = connection )
1002
986
return res
1003
987
@@ -1088,17 +1072,17 @@ def __setTaskParameterValue(self, transID, taskID, paramName, paramValue, connec
1088
1072
1089
1073
def __deleteTransformationTasks (self , transID , connection = False ):
1090
1074
"""Delete all the tasks from the TransformationTasks table for transformation with TransformationID"""
1091
- req = "DELETE FROM TransformationTasks WHERE TransformationID=%d" % transID
1075
+ req = f "DELETE FROM TransformationTasks WHERE TransformationID={ transID } "
1092
1076
return self ._update (req , conn = connection )
1093
1077
1094
1078
def __deleteTransformationTask (self , transID , taskID , connection = False ):
1095
1079
"""Delete the task from the TransformationTasks table for transformation with TransformationID"""
1096
- req = "DELETE FROM TransformationTasks WHERE TransformationID=%d AND TaskID=%d" % ( transID , taskID )
1080
+ req = f "DELETE FROM TransformationTasks WHERE TransformationID={ transID } AND TaskID={ taskID } "
1097
1081
return self ._update (req , conn = connection )
1098
1082
1099
1083
def __deleteTransformationMetaQueries (self , transID , connection = False ):
1100
1084
"""Delete all the meta queries from the TransformationMetaQueries table for transformation with TransformationID"""
1101
- req = "DELETE FROM TransformationMetaQueries WHERE TransformationID=%d" % transID
1085
+ req = f "DELETE FROM TransformationMetaQueries WHERE TransformationID={ transID } "
1102
1086
return self ._update (req , conn = connection )
1103
1087
1104
1088
####################################################################
@@ -1258,9 +1242,9 @@ def __insertTaskInputs(self, transID, taskID, lfns, connection=False):
1258
1242
1259
1243
def __deleteTransformationTaskInputs (self , transID , taskID = 0 , connection = False ):
1260
1244
"""Delete all the tasks inputs from the TaskInputs table for transformation with TransformationID"""
1261
- req = "DELETE FROM TaskInputs WHERE TransformationID=%d" % transID
1245
+ req = f "DELETE FROM TaskInputs WHERE TransformationID={ transID } "
1262
1246
if taskID :
1263
- req = "%s AND TaskID=%d" % ( req , int ( taskID ))
1247
+ req = f" { req } AND TaskID={ taskID } "
1264
1248
return self ._update (req , conn = connection )
1265
1249
1266
1250
###########################################################################
@@ -1307,25 +1291,13 @@ def getTransformationLogging(self, transName, connection=False):
1307
1291
1308
1292
def __deleteTransformationLog (self , transID , connection = False ):
1309
1293
"""Remove the entries in the transformation log for a transformation"""
1310
- req = "DELETE FROM TransformationLog WHERE TransformationID=%d;" % transID
1294
+ req = f "DELETE FROM TransformationLog WHERE TransformationID={ transID } "
1311
1295
return self ._update (req , conn = connection )
1312
1296
1313
1297
###########################################################################
1314
1298
#
1315
1299
# These methods manipulate the DataFiles table
1316
1300
#
1317
- def __getAllFileIDs (self , connection = False ):
1318
- """Get all the fileIDs for the supplied list of lfns"""
1319
- req = "SELECT LFN,FileID FROM DataFiles;"
1320
- res = self ._query (req , conn = connection )
1321
- if not res ["OK" ]:
1322
- return res
1323
- fids = {}
1324
- lfns = {}
1325
- for lfn , fileID in res ["Value" ]:
1326
- fids [fileID ] = lfn
1327
- lfns [lfn ] = fileID
1328
- return S_OK ((fids , lfns ))
1329
1301
1330
1302
def __getFileIDsForLfns (self , lfns , connection = False ):
1331
1303
"""Get file IDs for the given list of lfns
0 commit comments