Beispiel #1
0
def buildWorkloadForRequest(typename, schema):
    """
    _buildWorkloadForRequest_

    Prototype master class for ReqMgr request creation

    Should load factory, use the schema to find arguments,
    validate the arguments, and then return a finished workload.
    """
    requestName = schema['RequestName']

    if not typename in _Registry._Factories.keys():
        factoryName = '%sWorkloadFactory' % typename
        try:
            mod = __import__('WMCore.WMSpec.StdSpecs.%s' % typename, globals(),
                             locals(), [factoryName])
            factoryInstance = getattr(mod, factoryName)
        except ImportError:
            msg = "Spec type %s not found in WMCore.WMSpec.StdSpecs" % typename
            raise RuntimeError(msg)
        except AttributeError as ex:
            msg = "Factory not found in Spec for type %s" % typename
            raise RuntimeError(msg)
        _Registry._Factories[typename] = factoryInstance
    else:
        factoryInstance = _Registry._Factories[typename]

    # So now we have a factory
    # Time to run it
    # Any exception here will be caught at a higher level (ReqMgrWebTools)
    # This should also handle validation
    factory = factoryInstance()
    workload = factory.factoryWorkloadConstruction(workloadName=requestName,
                                                   arguments=schema)
    # Now build a request
    request = Request()
    request.update(schema)
    loadRequestSchema(workload=workload, requestSchema=schema)
    request['WorkloadSpec'] = workload.data
    # use the CMSSWVersion from the input schema only if it's defined (like
    # for a new request). for example for a resubmission request, schema['CMSSWVersion']
    # is empty and will be worked out later ; do not use any defaults
    # TODO:
    # all these fiddling along the route of creating the request should be concentrated
    #    at single place! Otherwise implementation of things like request cloning is
    #    unnecessary complicated for there is a lot hidden manipulations
    #    for for cloning - do this only if it's not defined already!
    #    seeing what is written above about resubmission, not sure if for resubmission
    #    this is not now screwed up
    if schema.get('CMSSWVersion') and schema.get(
            'CMSSWVersion') not in request['SoftwareVersions']:
        request['SoftwareVersions'].append(schema.get('CMSSWVersion'))

    # Storing the DBSURL causes problems for cloning
    # If it is not present in the schema then there is no reason to store
    # it in couch.

    return request
Beispiel #2
0
def buildWorkloadForRequest(typename, schema):
    """
    _buildWorkloadForRequest_

    Prototype master class for ReqMgr request creation

    Should load factory, use the schema to find arguments,
    validate the arguments, and then return a finished workload.
    """
    requestName = schema['RequestName']

    if not typename in _Registry._Factories.keys():
        factoryName = '%sWorkloadFactory' % typename
        try:
            mod = __import__('WMCore.WMSpec.StdSpecs.%s' % typename,
                             globals(), locals(), [factoryName])
            factoryInstance = getattr(mod, factoryName)
        except ImportError:
            msg =  "Spec type %s not found in WMCore.WMSpec.StdSpecs" % typename
            raise RuntimeError, msg
        except AttributeError as ex:
            msg = "Factory not found in Spec for type %s" % typename
            raise RuntimeError, msg
        _Registry._Factories[typename] = factoryInstance
    else:
        factoryInstance = _Registry._Factories[typename]

    # So now we have a factory
    # Time to run it
    # Any exception here will be caught at a higher level (ReqMgrWebTools)
    # This should also handle validation
    factory  = factoryInstance()
    workload = factory.factoryWorkloadConstruction(workloadName = requestName,
                                                   arguments = schema)
    # Now build a request
    request = Request()
    request.update(schema)
    loadRequestSchema(workload = workload, requestSchema = schema)
    request['WorkloadSpec'] = workload.data
    # use the CMSSWVersion from the input schema only if it's defined (like
    # for a new request). for example for a resubmission request, schema['CMSSWVersion']
    # is empty and will be worked out later ; do not use any defaults
    # TODO:
    # all these fiddling along the route of creating the request should be concentrated
    #    at single place! Otherwise implementation of things like request cloning is
    #    unnecessary complicated for there is a lot hidden manipulations
    #    for for cloning - do this only if it's not defined already!
    #    seeing what is written above about resubmission, not sure if for resubmission
    #    this is not now screwed up
    if schema.get('CMSSWVersion') and schema.get('CMSSWVersion') not in request['SoftwareVersions']:
        request['SoftwareVersions'].append(schema.get('CMSSWVersion'))

    # Storing the DBSURL causes problems for cloning
    # If it is not present in the schema then there is no reason to store
    # it in couch.

    return request
Beispiel #3
0
            raise RuntimeError, msg
        _Registry._Factories[typename] = factoryInstance
    else:
        factoryInstance = _Registry._Factories[typename]

    # So now we have a factory
    # Time to run it
    # Any exception here will be caught at a higher level (ReqMgrWebTools)
    # This should also handle validation
    factory  = factoryInstance()
    workload = factory.factoryWorkloadConstruction(workloadName = requestName,
                                                   arguments = schema)

    # Now build a request
    request = Request()
    request.update(schema)
    loadRequestSchema(workload = workload, requestSchema = schema)
    request['WorkloadSpec'] = workload.data
    # use the CMSSWVersion from the input schema only if it's defined (like
    # for a new request). for example for a resubmission request, schema['CMSSWVersion']
    # is empty and will be worked out later ; do not use any defaults
    # TODO:
    # all these fiddling along the route of creating the request should be concentrated
    #    at single place! Otherwise implementation of things like request cloning is
    #    unnecessary complicated for there is a lot hidden manipulations
    #    for for cloning - do this only if it's not defined already!
    #    seeing what is written above about resubmission, not sure if for resubmission
    #    this is not now screwed up
    if schema.get('CMSSWVersion') and schema.get('CMSSWVersion') not in request['SoftwareVersions']:
        request['SoftwareVersions'].append(schema.get('CMSSWVersion'))
    # assume only one dbs for all the task
Beispiel #4
0
            raise RuntimeError, msg
        _Registry._Factories[typename] = factoryInstance
    else:
        factoryInstance = _Registry._Factories[typename]

    # So now we have a factory
    # Time to run it
    # Any exception here will be caught at a higher level (ReqMgrWebTools)
    # This should also handle validation
    factory = factoryInstance()
    workload = factory.factoryWorkloadConstruction(workloadName=requestName,
                                                   arguments=schema)

    # Now build a request
    request = Request()
    request.update(schema)
    loadRequestSchema(workload=workload, requestSchema=schema)
    request['WorkloadSpec'] = workload.data
    # use the CMSSWVersion from the input schema only if it's defined (like
    # for a new request). for example for a resubmission request, schema['CMSSWVersion']
    # is empty and will be worked out later ; do not use any defaults
    # TODO:
    # all these fiddling along the route of creating the request should be concentrated
    #    at single place! Otherwise implementation of things like request cloning is
    #    unnecessary complicated for there is a lot hidden manipulations
    #    for for cloning - do this only if it's not defined already!
    #    seeing what is written above about resubmission, not sure if for resubmission
    #    this is not now screwed up
    if schema.get('CMSSWVersion') and schema.get(
            'CMSSWVersion') not in request['SoftwareVersions']:
        request['SoftwareVersions'].append(schema.get('CMSSWVersion'))