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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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.setProductionStatus(prodID, "Stopped")
    if res["OK"]:
        DIRAC.gLogger.notice("Production %s successully stopped" % prodID)
    else:
        DIRAC.gLogger.error(res["Message"])
        DIRAC.exit(-1)

    DIRAC.exit(0)
Beispiel #8
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)
Beispiel #9
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.setProductionStatus(prodID, 'Active')
    if res['OK']:
        DIRAC.gLogger.notice('Production %s successully started' % 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)
Beispiel #11
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'])
Beispiel #12
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"])
Beispiel #13
0
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'
]))

Script.parseCommandLine()

from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient

args = Script.getPositionalArgs()
if (len(args) != 1):
    Script.showHelp()

# get arguments
prodID = args[0]

prodClient = ProductionClient()

res = prodClient.setProductionStatus(prodID, 'Cleaned')
if res['OK']:
    DIRAC.gLogger.notice('Production %s successully cleaned' % prodID)
else:
    DIRAC.gLogger.error(res['Message'])
    DIRAC.exit(-1)

DIRAC.exit(0)
Beispiel #14
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)
Beispiel #15
0
Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s prodID transID [parentTransID]' % Script.scriptName,
                                  'Arguments:',
                                  '  prodID: Production ID',
                                  '  transID: Transformation ID',
                                  '  parentTransID: Parent Transformation ID'
                                  ]))


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()

prodID = args[0]
transID = args[1]

res = transClient.getTransformation(transID)
                                  ]))


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()

# 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)
Beispiel #17
0
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'
]))

Script.parseCommandLine()

from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient

args = Script.getPositionalArgs()
if (len(args) != 1):
    Script.showHelp()

# get arguments
prodID = args[0]

prodClient = ProductionClient()

res = prodClient.setProductionStatus(prodID, 'Active')
if res['OK']:
    DIRAC.gLogger.notice('Production %s successully started' % prodID)
else:
    DIRAC.gLogger.error(res['Message'])
    DIRAC.exit(-1)

DIRAC.exit(0)
Beispiel #18
0
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]

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 setUp(self):
     self.prodClient = ProductionClient()
Beispiel #20
0
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]

prodClient = ProductionClient()

res = prodClient.setProductionStatus(prodID, 'Stopped')
if res['OK']:
    DIRAC.gLogger.notice('Production %s successully stopped' % prodID)
else:
    DIRAC.gLogger.error(res['Message'])
    DIRAC.exit(-1)

DIRAC.exit(0)
Beispiel #21
0
from DIRAC.Core.Base import Script
from DIRAC.Core.Utilities.PrettyPrint import printTable

Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s prodID' % Script.scriptName,
                                  'Arguments:',
                                  '  prodID: Production ID'
                                  ]))


Script.parseCommandLine()

from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient

prodClient = ProductionClient()

# get arguments
args = Script.getPositionalArgs()
if (len(args) != 1):
  Script.showHelp()
else:
  prodID = args[0]
  res = prodClient.getProduction(prodID)

fields = [
    'ProductionName',
    'Status',
    'ProductionID',
    'CreationDate',
    'LastUpdate',
Beispiel #22
0
 def __init__(self):
     self.transClient = TransformationClient()
     self.prodClient = ProductionClient()
Beispiel #23
0
__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)
Beispiel #24
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)
Beispiel #25
0
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)
Beispiel #26
0
  Get summary informations of all productions
"""

__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script
from DIRAC.Core.Utilities.PrettyPrint import printTable

Script.setUsageMessage('\n'.join([__doc__.split('\n')[1]]))

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):
Beispiel #27
0
class ProdTransManager(object):
    def __init__(self):
        self.transClient = TransformationClient()
        self.prodClient = ProductionClient()

    def deleteTransformations(self, transIDs):
        """Delete given transformations from the TS

        :param list transIDs: a list of Transformation IDs
        """
        gLogger.notice("Deleting transformations %s from the TS" % transIDs)

        for transID in transIDs:
            res = self.transClient.deleteTransformation(transID)
            if not res["OK"]:
                return res

        return S_OK()

    def deleteProductionTransformations(self, prodID):
        """Delete the production transformations from the TS

        :param int prodID: the ProductionID
        """
        res = self.prodClient.getProductionTransformations(prodID)
        if res["OK"]:
            transList = res["Value"]

        gLogger.notice("Deleting production transformations %s from the TS" %
                       transList)

        for trans in transList:
            transID = trans["TransformationID"]
            res = self.transClient.deleteTransformation(transID)
            if not res["OK"]:
                gLogger.error(res["Message"])

        return S_OK()

    def addTransformationStep(self, stepID, prodID):
        """Add the transformation step to the TS

        :param int stepID: the production step ID
        :param int prodID: the production ID
        :return:
        """

        res = self.prodClient.getProductionStep(stepID)
        if not res["OK"]:
            return res
        prodStep = res["Value"]

        gLogger.notice("Add step %s to production %s" % (prodStep[0], prodID))

        stepDesc = prodStep[2]
        stepLongDesc = prodStep[3]
        stepBody = prodStep[4]
        stepType = prodStep[5]
        stepPlugin = prodStep[6]
        stepAgentType = prodStep[7]
        stepGroupsize = prodStep[8]
        stepInputquery = json.loads(prodStep[9])
        stepOutputquery = json.loads(prodStep[10])

        stepName = "%08d" % prodID + "_" + prodStep[1]

        res = self.transClient.addTransformation(
            stepName,
            stepDesc,
            stepLongDesc,
            stepType,
            stepPlugin,
            stepAgentType,
            "",
            groupSize=stepGroupsize,
            body=stepBody,
            inputMetaQuery=stepInputquery,
            outputMetaQuery=stepOutputquery,
        )

        if not res["OK"]:
            return S_ERROR(res["Message"])

        return S_OK(res["Value"])

    def executeActionOnTransformations(self, prodID, action):
        """Wrapper to start/stop/clean the transformations of a production

        :param int prodID: the production ID
        :param str action: it can be start/stop/clean
        """

        # Check if there is any action to do
        if not action:
            return S_OK()

        # Get the transformations of the production
        res = self.prodClient.getProductionTransformations(prodID)
        if not res["OK"]:
            return res

        transList = res["Value"]
        method = getattr(self.transClient, action)
        gLogger.notice("Executing action %s to %s" % (action, transList))

        # Execute the action on each transformation
        for trans in transList:
            transID = trans["TransformationID"]
            res = method(transID)
            if not res["OK"]:
                return res

        return S_OK()
Beispiel #28
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
    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)