ProductionDB

DIRAC Production DB

Production database is used to collect and serve the necessary information in order to automate the task of transformation preparation for high level productions.

class DIRAC.ProductionSystem.DB.ProductionDB.ProductionDB(dbname=None, dbconfig=None, dbIn=None)

Bases: DIRAC.Core.Base.DB.DB

ProductionDB class

class ConnectionPool(host, user, passwd, port=3306, graceTime=600)

Bases: object

Management of connections per thread

__init__(host, user, passwd, port=3306, graceTime=600)

x.__init__(…) initializes x; see help(type(x)) for signature

clean(now=False)
get(dbName, retries=10)
transactionCommit(dbName)
transactionRollback(dbName)
transactionStart(dbName)
__init__(dbname=None, dbconfig=None, dbIn=None)

The standard constructor takes the database name (dbname) and the name of the configuration section (dbconfig)

addProduction(prodName, prodDescription, authorDN, authorGroup, connection=False)

Create new production starting from its description

Parameters:
  • prodName (str) – a string with the Production name
  • prodDescription (str) – a json object with the Production description
  • authorDN (str) – string with the author DN
  • authorGroup (str) – string with author group
addProductionStep(stepName, stepDescription, stepLongDescription, stepBody, stepType, stepPlugin, stepAgentType, stepGroupSize, stepInputquery, stepOutputquery, connection=False)

Add a Production Step

Parameters:
  • stepName (str) – name of the production Step
  • stepDescription (str) – description of the production Step
  • stepLongDescription (str) – long description of the production Step
  • stepBody (str) – body of the production Step
  • stepType (str) – type of the production Step
  • stepPlugin (str) – plugin to be used for the production Step
  • stepAgentType (str) – agent type to be used for the production Step
  • stepGroupSize (int) – group size of the production Step
  • stepInputquery (str) – InputQuery of the production Step
  • stepOutputquery (str) – OutputQuery of the production Step
Returns:

addTransformationsToProduction(prodName, transIDs, parentTransIDs=None, connection=False)

Check the production validity and the add the transformations to the production

Parameters:
  • prodName (str) – the Production name or ID
  • transIDs (list) – the list of transformations to be added to the production
buildCondition(condDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, limit=False, greater=None, smaller=None, offset=None)

Build SQL condition statement from provided condDict and other extra check on a specified time stamp. The conditions dictionary specifies for each attribute one or a List of possible values greater and smaller are dictionaries in which the keys are the names of the fields, that are requested to be >= or < than the corresponding value. For compatibility with current usage it uses Exceptions to exit in case of invalid arguments

cleanProduction(prodName, author='', connection=False)

Clean the production specified by name or id

Parameters:prodName (str) – the Production name or ID
countEntries(table, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of entries wit the given conditions

deleteEntries(tableName, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Delete rows from “tableName” with N records can match the condition if limit is not False, the given limit is set String type values will be appropriately escaped, they can be single values or lists of values.

deleteProduction(prodName, author='', connection=False)

Remove the production specified by name or id

Parameters:prodName (str) – the Production name or ID
executeStoredProcedure(packageName, parameters, outputIds)
executeStoredProcedureWithCursor(packageName, parameters)
getCSOption(optionName, defaultValue=None)
getCounters(table, attrList, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Count the number of records on each distinct combination of AttrList, selected with condition defined by condDict and time stamps

getDistinctAttributeValues(table, attribute, condDict=None, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)

Get distinct values of a table attribute under specified conditions

getFields(tableName, outFields=None, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Select “outFields” from “tableName” with condDict N records can match the condition return S_OK( tuple(Field,Value) ) if outFields is None all fields in “tableName” are returned if limit is not False, the given limit is set inValues are properly escaped using the _escape_string method, they can be single values or lists of values.

getProduction(prodName, connection=False)

Get the Production definition

Parameters:prodName (str) – the Production name or ID
getProductionParameters(prodName, parameters, connection=False)

Get the requested parameters for a supplied production

Parameters:
  • prodName (str) – the Production name or ID
  • parameters (str) – any valid production parameter in self.PRODPARAMS
getProductionStep(stepID, connection=False)

It returns the ProductionStep corresponding to the stepID

Parameters:stepID (int) – the ID of the production Step stored in the ProductionSteps table
Returns:the attributes of Production Step corresponding to the stepID
getProductionTransformations(prodName, condDict=None, older=None, newer=None, timeStamp='CreationTime', orderAttribute=None, limit=None, offset=None, connection=False)

Gets the transformations of a given Production

Parameters:prodName (str) – the Production name or ID
Returns:
getProductions(condDict=None, older=None, newer=None, timeStamp='LastUpdate', orderAttribute=None, limit=None, offset=None, connection=False)

Get parameters of all the Productions with support for the web standard structure

Parameters:
  • condDict (dict) –
  • older (str) –
  • newer (str) –
  • timeStamp (str) –
  • orderAttribute (str) –
  • limit (int) –
  • offset (int) –
  • connection (bool) –
Returns:

insertFields(tableName, inFields=None, inValues=None, conn=None, inDict=None)

Insert a new row in “tableName” assigning the values “inValues” to the fields “inFields”. String type values will be appropriately escaped.

setProductionStatus(prodName, status, connection=False)

Set the status to the production and to all the associated transformations

Parameters:
  • prodName (str) – the Production name or ID
  • status (str) – the Production status
startProduction(prodName, connection=False)

Instantiate and start the transformations belonging to the production

Parameters:prodName (str) – the Production name or ID
transactionCommit()
transactionRollback()
transactionStart()
updateFields(tableName, updateFields=None, updateValues=None, condDict=None, limit=False, conn=None, updateDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)

Update “updateFields” from “tableName” with “updateValues”. updateDict alternative way to provide the updateFields and updateValues N records can match the condition return S_OK( number of updated rows ) if limit is not False, the given limit is set String type values will be appropriately escaped.