예제 #1
0
  def submitJob(self, executableFile, proxy, **kwargs):
    """ Method to submit job.

    :param str executableFile: location of the executable file
    :param str proxy: payload proxy

    :return: S_OK/S_ERROR of the result of the job submission
    """

    if self.pPool is None:
      self.pPool = ProcessPool(minSize=self.processors,
                               maxSize=self.processors,
                               poolCallback=self.finalizeJob)

    self.pPool.processResults()

    processorsForJob = self._getProcessorsForJobs(kwargs)
    if not processorsForJob:
      return S_ERROR('Not enough processors for the job')

    # Now persisiting the job limits for later use in pilot.cfg file (pilot 3 default)
    cd = ConfigurationData(loadDefaultCFG=False)
    res = cd.loadFile('pilot.cfg')
    if not res['OK']:
      self.log.error("Could not load pilot.cfg", res['Message'])
    # only NumberOfProcessors for now, but RAM (or other stuff) can also be added
    jobID = int(kwargs.get('jobDesc', {}).get('jobID', 0))
    cd.setOptionInCFG('/Resources/Computing/JobLimits/%d/NumberOfProcessors' % jobID, processorsForJob)
    res = cd.dumpLocalCFGToFile('pilot.cfg')
    if not res['OK']:
      self.log.error("Could not dump cfg to pilot.cfg", res['Message'])

    ret = getProxyInfo()
    if not ret['OK']:
      pilotProxy = None
    else:
      pilotProxy = ret['Value']['path']
    self.log.notice('Pilot Proxy:', pilotProxy)

    kwargs = {'UseSudo': False}
    if self.useSudo:
      for nUser in range(MAX_NUMBER_OF_SUDO_UNIX_USERS):
        if nUser not in self.userNumberPerTask.values():
          break
      kwargs['NUser'] = nUser
      kwargs['PayloadUser'] = os.environ['USER'] + 'p%s' % str(nUser).zfill(2)
      kwargs['UseSudo'] = True

    result = self.pPool.createAndQueueTask(executeJob,
                                           args=(executableFile, proxy, self.taskID),
                                           kwargs=kwargs,
                                           taskID=self.taskID,
                                           usePoolCallbacks=True)
    self.processorsPerTask[self.taskID] = processorsForJob
    self.taskID += 1

    self.pPool.processResults()

    return result
예제 #2
0
    def submitJob(self, executableFile, proxy=None, inputs=None, **kwargs):
        """Method to submit job.
        This method will submit to a ProcessPoolExecutor, which returns Future objects.

        :param str executableFile: location of the executable file
        :param str proxy: payload proxy
        :param list inputs: dependencies of executableFile

        :return: S_OK/S_ERROR of the result of the job submission
        """

        if self.pPool is None:
            self.pPool = concurrent.futures.ProcessPoolExecutor(
                max_workers=self.processors)

        processorsForJob = self._getProcessorsForJobs(kwargs)
        if not processorsForJob:
            return S_ERROR("Not enough processors for the job")

        # Now persisting the job limits for later use in pilot.cfg file (pilot 3 default)
        cd = ConfigurationData(loadDefaultCFG=False)
        res = cd.loadFile("pilot.cfg")
        if not res["OK"]:
            self.log.error("Could not load pilot.cfg", res["Message"])
        else:
            # only NumberOfProcessors for now, but RAM (or other stuff) can also be added
            jobID = int(kwargs.get("jobDesc", {}).get("jobID", 0))
            cd.setOptionInCFG(
                "/Resources/Computing/JobLimits/%d/NumberOfProcessors" % jobID,
                processorsForJob)
            res = cd.dumpLocalCFGToFile("pilot.cfg")
            if not res["OK"]:
                self.log.error("Could not dump cfg to pilot.cfg",
                               res["Message"])

        # Here we define task kwargs: adding complex objects like thread.Lock can trigger errors in the task
        taskKwargs = {"InnerCESubmissionType": self.innerCESubmissionType}
        if self.innerCESubmissionType == "Sudo":
            for nUser in range(MAX_NUMBER_OF_SUDO_UNIX_USERS):
                if nUser not in self.userNumberPerTask.values():
                    break
            taskKwargs["NUser"] = nUser
            if "USER" in os.environ:
                taskKwargs["PayloadUser"] = os.environ["USER"] + "p%s" % str(
                    nUser).zfill(2)

        future = self.pPool.submit(executeJob, executableFile, proxy,
                                   self.taskID, inputs, **taskKwargs)
        self.processorsPerTask[future] = processorsForJob
        self.taskID += 1
        future.add_done_callback(self.finalizeJob)

        return S_OK()  # returning S_OK as callback will do the rest
예제 #3
0
""" Unit tests for PathFinder only for functions that I added
"""
import pytest
from diraccfg import CFG

from DIRAC.Core.Utilities import List
from DIRAC.ConfigurationSystem.Client import PathFinder
from DIRAC.ConfigurationSystem.Client.Helpers import Operations
from DIRAC.ConfigurationSystem.private.ConfigurationData import ConfigurationData

localCFGData = ConfigurationData(False)
mergedCFG = CFG()
mergedCFG.loadFromBuffer("""
DIRAC
{
  Setup=TestSetup
  Setups
  {
    TestSetup
    {
      WorkloadManagement=MyWM
    }
  }
}
Systems
{
  WorkloadManagement
  {
    MyWM
    {
      URLs
예제 #4
0
from DIRAC.ConfigurationSystem.private.ConfigurationData import ConfigurationData

gConfigurationData = ConfigurationData()