Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:07

0001 import argparse
0002 
0003 from rucio.client import Client as RucioClient
0004 from rucio.common.exception import DataIdentifierNotFound
0005 
0006 from pandaserver.config import panda_config
0007 from pandaserver.dataservice.ddm import rucioAPI
0008 from pandaserver.taskbuffer.TaskBuffer import taskBuffer
0009 from pandaserver.userinterface import Client
0010 
0011 taskBuffer.init(panda_config.dbhost, panda_config.dbpasswd, nDBConnection=1)
0012 
0013 # parse option
0014 parser = argparse.ArgumentParser()
0015 parser.add_argument("--tid", action="store", dest="tid", default=None, required=True, help="task ID")
0016 parser.add_argument(
0017     "--resurrectDS",
0018     action="store_const",
0019     const=True,
0020     dest="resurrectDS",
0021     default=False,
0022     help="resurrect output and log datasets if they were already deleted",
0023 )
0024 
0025 options = parser.parse_args()
0026 
0027 task_id = int(options.tid)
0028 
0029 if True:
0030     if options.resurrectDS:
0031         sd, so = taskBuffer.querySQLS(
0032             "SELECT datasetName FROM ATLAS_PANDA.JEDI_Datasets WHERE jediTaskID=:id AND type IN (:t1,:t2)",
0033             {":id": task_id, ":t1": "output", ":t2": "log"},
0034         )
0035         rucio_client = RucioClient()
0036         for (dataset_name,) in so:
0037             for i in range(3):
0038                 try:
0039                     scope, name = rucioAPI.extract_scope(dataset_name)
0040                     rucio_client.get_did(scope, name)
0041                     break
0042                 except DataIdentifierNotFound:
0043                     print(f"resurrect {dataset_name}")
0044                     rucio_client.resurrect([{"scope": scope, "name": name}])
0045                     try:
0046                         rucio_client.set_metadata(scope, name, "lifetime", None)
0047                     except Exception:
0048                         pass
0049 
0050     print(Client.reload_input(task_id))
0051     print(f"done for task_id={task_id}")