def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() res = prodClient.getProductions() fields = ["ProductionName", "Status", "ProductionID", "CreationDate", "LastUpdate", "AuthorDN", "AuthorGroup"] records = [] if res["OK"]: prodList = res["Value"] if not isinstance(res["Value"], list): prodList = [res["Value"]] for prod in prodList: records.append( [ str(prod["ProductionName"]), str(prod["Status"]), str(prod["ProductionID"]), str(prod["CreationDate"]), str(prod["LastUpdate"]), str(prod["AuthorDN"]), str(prod["AuthorGroup"]), ] ) else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) else: prodID = args[0] res = prodClient.getProduction(prodID) if res['OK']: prod = res['Value'] else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) print('Description for production %s:\n' % prodID) print(prod['Description']) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() res = prodClient.getProductions() fields = [ 'ProductionName', 'Status', 'ProductionID', 'CreationDate', 'LastUpdate', 'AuthorDN', 'AuthorGroup' ] records = [] if res['OK']: prodList = res['Value'] if not isinstance(res['Value'], list): prodList = [res['Value']] for prod in prodList: records.append([ str(prod['ProductionName']), str(prod['Status']), str(prod['ProductionID']), str(prod['CreationDate']), str(prod['LastUpdate']), str(prod['AuthorDN']), str(prod['AuthorGroup']) ]) else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient prodClient = ProductionClient() transClient = TransformationClient() # get arguments args = Script.getPositionalArgs() if len(args) == 3: parentTransID = args[2] elif len(args) == 2: parentTransID = '' else: Script.showHelp(exitCode=1) prodID = args[0] transID = args[1] res = transClient.getTransformation(transID) if not res['OK']: DIRAC.gLogger.error('Failed to get transformation %s: %s' % (transID, res['Message'])) DIRAC.exit(-1) transID = res['Value']['TransformationID'] if parentTransID: res = transClient.getTransformation(parentTransID) if not res['OK']: DIRAC.gLogger.error('Failed to get transformation %s: %s' % (parentTransID, res['Message'])) DIRAC.exit(-1) parentTransID = res['Value']['TransformationID'] res = prodClient.getProduction(prodID) if not res['OK']: DIRAC.gLogger.error('Failed to get production %s: %s' % (prodID, res['Message'])) DIRAC.exit(-1) prodID = res['Value']['ProductionID'] res = prodClient.addTransformationsToProduction(prodID, transID, parentTransID) if not res['OK']: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) if parentTransID: msg = 'Transformation %s successfully added to production %s with parent transformation %s' % \ (transID, prodID, parentTransID) else: msg = 'Transformation %s successfully added to production %s with no parent transformation' % \ (transID, prodID) DIRAC.gLogger.notice(msg) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") Script.registerArgument("transID: Transformation ID") Script.registerArgument("parentTransID: Parent Transformation ID", default="", mandatory=False) _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient prodClient = ProductionClient() transClient = TransformationClient() # get arguments prodID, transID, parentTransID = Script.getPositionalArgs(group=True) if len(args) > 3: Script.showHelp(exitCode=1) res = transClient.getTransformation(transID) if not res["OK"]: DIRAC.gLogger.error("Failed to get transformation %s: %s" % (transID, res["Message"])) DIRAC.exit(-1) transID = res["Value"]["TransformationID"] if parentTransID: res = transClient.getTransformation(parentTransID) if not res["OK"]: DIRAC.gLogger.error("Failed to get transformation %s: %s" % (parentTransID, res["Message"])) DIRAC.exit(-1) parentTransID = res["Value"]["TransformationID"] res = prodClient.getProduction(prodID) if not res["OK"]: DIRAC.gLogger.error("Failed to get production %s: %s" % (prodID, res["Message"])) DIRAC.exit(-1) prodID = res["Value"]["ProductionID"] res = prodClient.addTransformationsToProduction(prodID, transID, parentTransID) if not res["OK"]: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) if parentTransID: msg = "Transformation %s successfully added to production %s with parent transformation %s" % ( transID, prodID, parentTransID, ) else: msg = "Transformation %s successfully added to production %s with no parent transformation" % (transID, prodID) DIRAC.gLogger.notice(msg) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.Core.Utilities.PrettyPrint import printTable from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) else: prodID = args[0] res = prodClient.getProduction(prodID) fields = [ 'ProductionName', 'Status', 'ProductionID', 'CreationDate', 'LastUpdate', 'AuthorDN', 'AuthorGroup'] records = [] if res['OK']: prodList = res['Value'] if not isinstance(res['Value'], list): prodList = [res['Value']] for prod in prodList: records.append( [ str( prod['ProductionName']), str( prod['Status']), str( prod['ProductionID']), str( prod['CreationDate']), str( prod['LastUpdate']), str( prod['AuthorDN']), str( prod['AuthorGroup'])]) else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient # get arguments prodID = args[0] res = ProductionClient().setProductionStatus(prodID, "Cleaned") if not res["OK"]: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(1) DIRAC.gLogger.notice("Production %s successully cleaned" % prodID) DIRAC.exit(0)
def setUp(self): self.prodClient = ProductionClient() self.transClient = TransformationClient() self.fc = FileCatalog() # ## Add metadata fields to the DFC self.MDFieldDict = { 'particle': 'VARCHAR(128)', 'analysis_prog': 'VARCHAR(128)', 'tel_sim_prog': 'VARCHAR(128)', 'outputType': 'VARCHAR(128)', 'zenith': 'int', 'data_level': 'int' } for MDField in self.MDFieldDict: MDFieldType = self.MDFieldDict[MDField] res = self.fc.addMetadataField(MDField, MDFieldType) self.assert_(res['OK'])
def setUp(self): self.prodClient = ProductionClient() self.transClient = TransformationClient() self.fc = FileCatalog() # ## Add metadata fields to the DFC self.MDFieldDict = { "particle": "VARCHAR(128)", "analysis_prog": "VARCHAR(128)", "tel_sim_prog": "VARCHAR(128)", "outputType": "VARCHAR(128)", "zenith": "int", "data_level": "int", } for MDField in self.MDFieldDict: MDFieldType = self.MDFieldDict[MDField] res = self.fc.addMetadataField(MDField, MDFieldType) self.assert_(res["OK"])
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) # get arguments prodID = args[0] res = ProductionClient().setProductionStatus(prodID, 'Cleaned') if not res['OK']: DIRAC.gLogger.error(res['Message']) DIRAC.exit(1) DIRAC.gLogger.notice('Production %s successully cleaned' % prodID) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient # get arguments prodID = args[0] prodClient = ProductionClient() res = prodClient.deleteProduction(prodID) if res["OK"]: DIRAC.gLogger.notice("Production %s successully deleted" % prodID) else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.Core.Utilities.PrettyPrint import printTable from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments prodID = args[0] res = prodClient.getProduction(prodID) fields = [ "ProductionName", "Status", "ProductionID", "CreationDate", "LastUpdate", "AuthorDN", "AuthorGroup" ] records = [] if res["OK"]: prodList = res["Value"] if not isinstance(res["Value"], list): prodList = [res["Value"]] for prod in prodList: records.append([ str(prod["ProductionName"]), str(prod["Status"]), str(prod["ProductionID"]), str(prod["CreationDate"]), str(prod["LastUpdate"]), str(prod["AuthorDN"]), str(prod["AuthorGroup"]), ]) else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) # get arguments prodID = args[0] prodClient = ProductionClient() res = prodClient.deleteProduction(prodID) if res['OK']: DIRAC.gLogger.notice('Production %s successully deleted' % prodID) else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments prodID = args[0] res = prodClient.getProduction(prodID) if res["OK"]: prod = res["Value"] else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) print("Description for production %s:\n" % prodID) print(prod["Description"]) DIRAC.exit(0)
def setUp(self): self.prodClient = ProductionClient()
fc = FileCatalog() MDFieldDict = { "application": "VARCHAR(128)", "image_format": "VARCHAR(128)", "image_width": "int", "image_height": "int", } for MDField in MDFieldDict.keys(): MDFieldType = MDFieldDict[MDField] res = fc.addMetadataField(MDField, MDFieldType) if not res["OK"]: gLogger.error("Failed to add metadata fields", res["Message"]) exit(-1) # Instantiate the ProductionClient prodClient = ProductionClient() # Create the first production step and add it to the Production outputquery = {"application": "mandelbrot", "image_format": "ascii", "image_width": 7680, "image_height": 200} prodStep1 = createProductionStep("ImageProd", "MCSimulation", outputQuery=outputquery) body = createWorkflowBodyStep1() prodStep1.Body = body res = prodClient.addProductionStep(prodStep1) if not res["OK"]: gLogger.error("Failed to add production step", res["Message"]) exit(-1) # Create the second production step and add it to the Production inputquery = {"application": "mandelbrot", "image_format": "ascii", "image_width": 7680, "image_height": 200} outputquery = {"application": "mandelbrot", "image_format": "ascii", "image_width": 7680, "image_height": 1400} prodStep2 = createProductionStep("MergeImage", "DataProcessing", inputQuery=inputquery, outputQuery=outputquery)
__RCSID__ = "$Id$" import DIRAC from DIRAC.Core.Base import Script Script.setUsageMessage('\n'.join([ __doc__.split('\n')[1], 'Usage:', ' %s prodID' % Script.scriptName, 'Arguments:', ' prodID: Production ID (mandatory)' ])) Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) # get arguments prodID = args[0] res = ProductionClient().setProductionStatus(prodID, 'Cleaned') if not res['OK']: DIRAC.gLogger.error(res['Message']) DIRAC.exit(1) DIRAC.gLogger.notice('Production %s successully cleaned' % prodID) DIRAC.exit(0)
return prod_step_2 ######################################################### if __name__ == '__main__': # get arguments args = Script.getPositionalArgs() if len(args) != 1: DIRAC.gLogger.error('At least 1 argument required: DL0_data_set') DIRAC.exit(-1) DL0_data_set = args[0] prod_name = DL0_data_set.replace('AdvancedBaseline_NSB1x_','')+'_DL1' ################################## # Create the production prod_sys_client = ProductionClient() ################################## # Define the first ProductionStep (Corsika+sim_telarray) prod_step_1 = build_simulation_step(DL0_data_set) # Add the step to the production prod_sys_client.addProductionStep(prod_step_1) ################################## # Define EventDisplay analysis steps and add them to the production # dark nsb = 1 prod_step_2 = build_evndisp_step(DL0_data_set, nsb=1) prod_step_2.ParentStep = prod_step_1 prod_sys_client.addProductionStep(prod_step_2) # moon nsb = 5 prod_step_3 = build_evndisp_step(DL0_data_set, nsb=5)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient # get arguments prodID = args[0] prodClient = ProductionClient() transClient = TransformationClient() res = prodClient.getProductionTransformations(prodID) transIDs = [] if res["OK"]: transList = res["Value"] if not transList: DIRAC.gLogger.notice( "No transformation associated with production %s" % prodID) DIRAC.exit(-1) for trans in transList: transIDs.append(trans["TransformationID"]) else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) fields = [ "TransformationName", "Status", "F_Proc.", "F_Proc.(%)", "TransformationID", "ProductionID", "Prod_LastUpdate", "Prod_InsertedTime", ] records = [] paramShowNames = [ "TransformationID", "TransformationName", "Type", "Status", "Files_Total", "Files_PercentProcessed", "Files_Processed", "Files_Unused", "Jobs_TotalCreated", "Jobs_Waiting", "Jobs_Running", "Jobs_Done", "Jobs_Failed", "Jobs_Stalled", ] resList = [] res = transClient.getTransformationSummaryWeb( {"TransformationID": transIDs}, [], 0, len(transIDs)) if not res["OK"]: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) if res["Value"]["TotalRecords"] > 0: paramNames = res["Value"]["ParameterNames"] for paramValues in res["Value"]["Records"]: paramShowValues = map( lambda pname: paramValues[paramNames.index(pname)], paramShowNames) showDict = dict(zip(paramShowNames, paramShowValues)) resList.append(showDict) for res in resList: files_Processed = res["Files_Processed"] files_PercentProcessed = res["Files_PercentProcessed"] status = res["Status"] type = res["Type"] transName = res["TransformationName"] transID = res["TransformationID"] records.append([ transName, status, str(files_Processed), str(files_PercentProcessed), str(transID), str(prodID), str(trans["LastUpdate"]), str(trans["InsertedTime"]), ]) printTable(fields, records) DIRAC.exit(0)
def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) # get arguments prodID = args[0] prodClient = ProductionClient() transClient = TransformationClient() res = prodClient.getProductionTransformations(prodID) transIDs = [] if res['OK']: transList = res['Value'] if not transList: DIRAC.gLogger.notice( 'No transformation associated with production %s' % prodID) DIRAC.exit(-1) for trans in transList: transIDs.append(trans['TransformationID']) else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) fields = [ 'TransformationName', 'Status', 'F_Proc.', 'F_Proc.(%)', 'TransformationID', 'ProductionID', 'Prod_LastUpdate', 'Prod_InsertedTime' ] records = [] paramShowNames = [ 'TransformationID', 'TransformationName', 'Type', 'Status', 'Files_Total', 'Files_PercentProcessed', 'Files_Processed', 'Files_Unused', 'Jobs_TotalCreated', 'Jobs_Waiting', 'Jobs_Running', 'Jobs_Done', 'Jobs_Failed', 'Jobs_Stalled' ] resList = [] res = transClient.getTransformationSummaryWeb( {'TransformationID': transIDs}, [], 0, len(transIDs)) if not res['OK']: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) if res['Value']['TotalRecords'] > 0: paramNames = res['Value']['ParameterNames'] for paramValues in res['Value']['Records']: paramShowValues = map( lambda pname: paramValues[paramNames.index(pname)], paramShowNames) showDict = dict(zip(paramShowNames, paramShowValues)) resList.append(showDict) for res in resList: files_Processed = res['Files_Processed'] files_PercentProcessed = res['Files_PercentProcessed'] status = res['Status'] type = res['Type'] transName = res['TransformationName'] transID = res['TransformationID'] records.append([ transName, status, str(files_Processed), str(files_PercentProcessed), str(transID), str(prodID), str(trans['LastUpdate']), str(trans['InsertedTime']) ]) printTable(fields, records) DIRAC.exit(0)
def __init__(self): self.transClient = TransformationClient() self.prodClient = ProductionClient()