예제 #1
0
    def deleteTransformation(self, transID, author='', connection=False):
        """ Small extension to not forget to delete the BkQueries
    """
        res = self.deleteBookkeepingQuery(transID, connection)
        if not res['OK']:
            return res

        return DIRACTransformationDB.deleteTransformation(
            self, transID, author, connection)
예제 #2
0
 def __init__(self, dbname=None, dbconfig=None, dbIn=None):
     """ The standard constructor takes the database name (dbname) and the name of the
     configuration section (dbconfig)
 """
     DIRACTransformationDB.__init__(self, dbname, dbconfig, dbIn)
     self.lock = threading.Lock()
     self.queryFields = ('SimulationConditions', 'DataTakingConditions',
                         'ProcessingPass', 'FileType', 'EventType',
                         'ConfigName', 'ConfigVersion', 'ProductionID',
                         'DataQualityFlag', 'StartRun', 'EndRun', 'Visible',
                         'RunNumbers', 'TCK')
     self.intFields = ('EventType', 'ProductionID', 'StartRun', 'EndRun')
     self.transRunParams = ('TransformationID', 'RunNumber', 'SelectedSite',
                            'Status', 'LastUpdate')
     self.allowedStatusForTasks = ('Unused', 'ProbInFC')
     self.TRANSPARAMS.append('Hot')
     self.TRANSFILEPARAMS.extend(
         ['RunNumber', 'Size', 'FileType', 'RAWAncestors'])
     self.TASKSPARAMS.append('RunNumber')
예제 #3
0
    def cleanTransformation(self, transID, author='', connection=False):
        """ Clean the transformation specified by name or id
        Extends DIRAC one for deleting the unused runs metadata
    """
        res = self._getConnectionTransID(connection, transID)
        if not res['OK']:
            return res
        connection = res['Value']['Connection']

        # deleting runs metadata
        req = "SELECT DISTINCT RunNumber FROM TransformationRuns WHERE TransformationID = %s" % transID
        res = self._query(req)
        if not res['OK']:
            gLogger.error("Failure executing %s" % str(req))
            return res
        runsMaybeToDelete = [r[0] for r in res['Value']]

        req = "SELECT DISTINCT RunNumber FROM TransformationRuns WHERE TransformationID != %s" % transID
        res = self._query(req)
        if not res['OK']:
            gLogger.error("Failure executing %s" % str(req))
            return res
        runsToKeep = [r[0] for r in res['Value']]

        runIDsToBeDeleted = list(set(runsMaybeToDelete) - set(runsToKeep))

        if runIDsToBeDeleted:
            res = self.deleteRunsMetadata(
                {
                    'RunNumber': runIDsToBeDeleted,
                    'Name': ['TCK', 'CondDb', 'DDDB']
                }, connection)
            if not res['OK']:
                return res

        res = DIRACTransformationDB.cleanTransformation(self,
                                                        transID,
                                                        connection=connection)
        if not res['OK']:
            return res

        res = self.removeStoredJobDescription(transID, connection=connection)
        if not res['OK']:
            return res

        res = self.__cleanTransformationRuns(transID, connection=connection)
        if not res['OK']:
            return res
        return S_OK(transID)
예제 #4
0
    def getTasksForSubmission(self,
                              transID,
                              numTasks=1,
                              site="",
                              statusList=['Created'],
                              older=None,
                              newer=None,
                              connection=False):
        """ extends base class including the run metadata
    """
        tasksDict = DIRACTransformationDB.getTasksForSubmission(
            self, transID, numTasks, site, statusList, older, newer,
            connection)
        if not tasksDict['OK']:
            return tasksDict

        tasksDict = tasksDict['Value']
        runNumbers = []
        for taskForSumbission in tasksDict.values():
            run = taskForSumbission.get('RunNumber')
            if run and run not in runNumbers:
                runNumbers.append(run)

        if runNumbers:
            runsMetadata = self.getRunsMetadata(runNumbers, connection)
            if not runsMetadata['OK']:
                return runsMetadata

            runsMetadata = runsMetadata['Value']
            for taskForSumbission in tasksDict.values():
                try:
                    taskForSumbission['RunMetadata'] = runsMetadata[
                        taskForSumbission['RunNumber']]
                except KeyError:
                    continue

        return S_OK(tasksDict)
예제 #5
0
 def initializeHandler(cls, serviceInfoDict):
     """ Initialization of DB object
 """
     cls.transformationDB = TransformationDB()
     return S_OK()
예제 #6
0
def initializeTransformationManagerHandler(serviceInfo):
    global database
    database = TransformationDB('TransformationDB',
                                'Transformation/TransformationDB')
    return S_OK()