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
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
def newRequest(self): """ _newRequest_ Util method to return a new ReqMgr.DataStructs.Request instance """ return Request()
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'))
def getRequest(requestId, reverseTypes=None, reverseStatus=None): """ _getRequest_ retrieve a request based on the request id, return a ReqMgr.DataStructs.Request instance containing the information """ factory = DBConnect.getConnection() reqGet = factory(classname="Request.Get") reqData = reqGet.execute(requestId) requestName = reqData['request_name'] if not reverseTypes or not reverseStatus: reverseTypes, reverseStatus = reverseLookups() getGroup = factory(classname="Group.GetGroupFromAssoc") groupData = getGroup.execute(reqData['requestor_group_id']) getUser = factory(classname="Requestor.GetUserFromAssoc") userData = getUser.execute(reqData['requestor_group_id']) request = Request() request["ReqMgrRequestID"] = reqData['request_id'] request["RequestName"] = requestName request["RequestType"] = reverseTypes[reqData['request_type']] request["RequestStatus"] = reverseStatus[reqData['request_status']] request["RequestPriority"] = reqData['request_priority'] request["ReqMgrRequestBasePriority"] = reqData['request_priority'] request["RequestWorkflow"] = reqData['workflow'] request["RequestNumEvents"] = reqData['request_num_events'] request["RequestSizeFiles"] = reqData['request_size_files'] request["RequestEventSize"] = reqData['request_event_size'] request["Group"] = groupData['group_name'] request["ReqMgrGroupID"] = groupData['group_id'] request["ReqMgrGroupBasePriority"] = \ groupData['group_base_priority'] request["Requestor"] = userData['requestor_hn_name'] request["ReqMgrRequestorID"] = userData['requestor_id'] request["ReqMgrRequestorBasePriority"] = \ userData['requestor_base_priority'] request["RequestPriority"] = \ request['RequestPriority'] + groupData['group_base_priority'] request["RequestPriority"] = \ request['RequestPriority'] + userData['requestor_base_priority'] updates = ChangeState.getProgress(requestName) request['percent_complete'], request['percent_success'] = percentages( updates) sqDeps = factory(classname="Software.GetByAssoc") swVers = sqDeps.execute(requestId) if swVers == {}: request['SoftwareVersions'] = ['DEPRECATED'] else: request['SoftwareVersions'] = swVers.values() getDatasetsIn = factory(classname="Datasets.GetInput") getDatasetsOut = factory(classname="Datasets.GetOutput") datasetsIn = getDatasetsIn.execute(requestId) datasetsOut = getDatasetsOut.execute(requestId) request['InputDatasetTypes'] = datasetsIn request['InputDatasets'] = datasetsIn.keys() request['OutputDatasets'] = datasetsOut return request
def getRequest(requestId, reverseTypes=None, reverseStatus=None): """ _getRequest_ retrieve a request based on the request id, return a ReqMgr.DataStructs.Request instance containing the information """ factory = DBConnect.getConnection() reqGet = factory(classname="Request.Get") reqData = reqGet.execute(requestId) requestName = reqData['request_name'] if not reverseTypes or not reverseStatus: reverseTypes, reverseStatus = reverseLookups() getGroup = factory(classname="Group.GetGroupFromAssoc") groupData = getGroup.execute(reqData['requestor_group_id']) getUser = factory(classname="Requestor.GetUserFromAssoc") userData = getUser.execute(reqData['requestor_group_id']) request = Request() request["RequestName"] = requestName request["RequestType"] = reverseTypes[reqData['request_type']] request["RequestStatus"] = reverseStatus[reqData['request_status']] request["RequestPriority"] = reqData['request_priority'] request["RequestWorkflow"] = reqData['workflow'] request["RequestNumEvents"] = reqData['request_num_events'] request["RequestSizeFiles"] = reqData['request_size_files'] # there used to be RequestEventSize argument, but then SizePerEvent # got introduce and got adopted so this is replacing it, presenting # this nomenclature inconsistency on Oracle level request["SizePerEvent"] = reqData['request_event_size'] request["PrepID"] = reqData['prep_id'] request["Group"] = groupData['group_name'] request["Requestor"] = userData['requestor_hn_name'] updates = ChangeState.getProgress(requestName) request['percent_complete'], request['percent_success'] = percentages( updates) sqDeps = factory(classname="Software.GetByAssoc") swVers = sqDeps.execute(requestId) if swVers == {}: request['SoftwareVersions'] = ['DEPRECATED'] else: request['SoftwareVersions'] = swVers.values() getDatasetsIn = factory(classname="Datasets.GetInput") getDatasetsOut = factory(classname="Datasets.GetOutput") datasetsIn = getDatasetsIn.execute(requestId) datasetsOut = getDatasetsOut.execute(requestId) request['InputDatasetTypes'] = datasetsIn request['InputDatasets'] = datasetsIn.keys() request['OutputDatasets'] = datasetsOut # fetch AcquisitionEra from spec, it's not stored in Oracle at all import WMCore.HTTPFrontEnd.RequestManager.ReqMgrWebTools as Utilities try: helper = Utilities.loadWorkload(request) request["AcquisitionEra"] = str(helper.getAcquisitionEra()) # add ProcessingVersion and ProcessingString in the response (#4561) request["ProcessingVersion"] = str(helper.getProcessingVersion()) request["ProcessingString"] = str(helper.getProcessingString()) except Exception, ex: logging.error("Could not check workload for %s, reason: %s" % (request["RequestName"], 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']: