Exemple #1
0
def execute ( arguments ):

  global gJobReport

  jobID = arguments['Job']['JobID']
  os.environ['JOBID'] = jobID
  jobID = int( jobID )
  # Fix in the environment to get a reasonable performance from dCache,
  # until we move to a new version of root
#  os.environ['DCACHE_RAHEAD'] = str(1)
#  os.environ['DCACHE_RA_BUFFER'] = str(50*1024)

  if arguments.has_key( 'WorkingDirectory' ):
    wdir = os.path.expandvars( arguments['WorkingDirectory'] )
    if os.path.isdir( wdir ):
      os.chdir( wdir )
    else:
      try:
        os.makedirs( wdir )
        if os.path.isdir( wdir ):
          os.chdir( wdir )
      except Exception:
        gLogger.exception( 'JobWrapperTemplate could not create working directory' )
        rescheduleFailedJob( jobID, 'Could Not Create Working Directory' )
        return 1

  #root = arguments['CE']['Root']
  gJobReport = JobReport( jobID, 'JobWrapper' )

  try:
    job = JobWrapper( jobID, gJobReport )
    job.initialize( arguments )
  except Exception:
    gLogger.exception( 'JobWrapper failed the initialization phase' )
    rescheduleFailedJob( jobID, 'Job Wrapper Initialization', gJobReport )
    job.sendWMSAccounting( 'Failed', 'Job Wrapper Initialization' )
    return 1

  if arguments['Job'].has_key( 'InputSandbox' ):
    gJobReport.commit()
    try:
      result = job.transferInputSandbox( arguments['Job']['InputSandbox'] )
      if not result['OK']:
        gLogger.warn( result['Message'] )
        raise JobWrapperError( result['Message'] )
    except Exception:
      gLogger.exception( 'JobWrapper failed to download input sandbox' )
      rescheduleFailedJob( jobID, 'Input Sandbox Download' )
      job.sendWMSAccounting( 'Failed', 'Input Sandbox Download' )
      return 1
  else:
    gLogger.verbose( 'Job has no InputSandbox requirement' )

  gJobReport.commit()

  if arguments['Job'].has_key( 'InputData' ):
    if arguments['Job']['InputData']:
      try:
        result = job.resolveInputData()
        if not result['OK']:
          gLogger.warn( result['Message'] )
          raise JobWrapperError( result['Message'] )
      except Exception, x:
        gLogger.exception( 'JobWrapper failed to resolve input data' )
        rescheduleFailedJob( jobID, 'Input Data Resolution' )
        job.sendWMSAccounting( 'Failed', 'Input Data Resolution' )
        return 1
    else:
      gLogger.verbose( 'Job has a null InputData requirement:' )
      gLogger.verbose( arguments )
          os.chdir(wdir)
      except Exception, x:
        gLogger.exception('JobWrapperTemplate could not create working directory')
        rescheduleFailedJob(jobID,'Could Not Create Working Directory')
        return 1

  #root = arguments['CE']['Root']
  jobReport = JobReport(jobID,'JobWrapper')

  try:
    job = JobWrapper( jobID, jobReport )
    job.initialize(arguments)
  except Exception, x:
    gLogger.exception('JobWrapper failed the initialization phase')
    rescheduleFailedJob(jobID,'Job Wrapper Initialization')
    job.sendWMSAccounting('Failed','Job Wrapper Initialization')
    return 1

  if arguments['Job'].has_key('InputSandbox'):
    jobReport.commit()
    try:
      result = job.transferInputSandbox(arguments['Job']['InputSandbox'])
      if not result['OK']:
        gLogger.warn(result['Message'])
        raise JobWrapperError(result['Message'])
    except Exception, x:
      gLogger.exception('JobWrapper failed to download input sandbox')
      rescheduleFailedJob(jobID,'Input Sandbox Download')
      job.sendWMSAccounting('Failed','Input Sandbox Download')
      return 1
  else:
def execute(arguments):

    global gJobReport

    jobID = arguments['Job']['JobID']
    os.environ['JOBID'] = jobID
    jobID = int(jobID)
    # Fix in the environment to get a reasonable performance from dCache,
    # until we move to a new version of root
    #  os.environ['DCACHE_RAHEAD'] = str(1)
    #  os.environ['DCACHE_RA_BUFFER'] = str(50*1024)

    if arguments.has_key('WorkingDirectory'):
        wdir = os.path.expandvars(arguments['WorkingDirectory'])
        if os.path.isdir(wdir):
            os.chdir(wdir)
        else:
            try:
                os.makedirs(wdir)
                if os.path.isdir(wdir):
                    os.chdir(wdir)
            except Exception:
                gLogger.exception(
                    'JobWrapperTemplate could not create working directory')
                rescheduleFailedJob(jobID,
                                    'Could Not Create Working Directory')
                return 1

    #root = arguments['CE']['Root']
    gJobReport = JobReport(jobID, 'JobWrapper')

    try:
        job = JobWrapper(jobID, gJobReport)
        job.initialize(arguments)
    except Exception:
        gLogger.exception('JobWrapper failed the initialization phase')
        rescheduleFailedJob(jobID, 'Job Wrapper Initialization', gJobReport)
        job.sendWMSAccounting('Failed', 'Job Wrapper Initialization')
        return 1

    if arguments['Job'].has_key('InputSandbox'):
        gJobReport.commit()
        try:
            result = job.transferInputSandbox(arguments['Job']['InputSandbox'])
            if not result['OK']:
                gLogger.warn(result['Message'])
                raise JobWrapperError(result['Message'])
        except Exception:
            gLogger.exception('JobWrapper failed to download input sandbox')
            rescheduleFailedJob(jobID, 'Input Sandbox Download')
            job.sendWMSAccounting('Failed', 'Input Sandbox Download')
            return 1
    else:
        gLogger.verbose('Job has no InputSandbox requirement')

    gJobReport.commit()

    if arguments['Job'].has_key('InputData'):
        if arguments['Job']['InputData']:
            try:
                result = job.resolveInputData()
                if not result['OK']:
                    gLogger.warn(result['Message'])
                    raise JobWrapperError(result['Message'])
            except Exception, x:
                gLogger.exception('JobWrapper failed to resolve input data')
                rescheduleFailedJob(jobID, 'Input Data Resolution')
                job.sendWMSAccounting('Failed', 'Input Data Resolution')
                return 1
        else:
            gLogger.verbose('Job has a null InputData requirement:')
            gLogger.verbose(arguments)
Exemple #4
0
                gLogger.exception(
                    'JobWrapperTemplate could not create working directory')
                rescheduleFailedJob(jobID,
                                    'Could Not Create Working Directory')
                return 1

    #root = arguments['CE']['Root']
    jobReport = JobReport(jobID, 'JobWrapper')

    try:
        job = JobWrapper(jobID, jobReport)
        job.initialize(arguments)
    except Exception, x:
        gLogger.exception('JobWrapper failed the initialization phase')
        rescheduleFailedJob(jobID, 'Job Wrapper Initialization')
        job.sendWMSAccounting('Failed', 'Job Wrapper Initialization')
        return 1

    if arguments['Job'].has_key('InputSandbox'):
        jobReport.commit()
        try:
            result = job.transferInputSandbox(arguments['Job']['InputSandbox'])
            if not result['OK']:
                gLogger.warn(result['Message'])
                raise JobWrapperError(result['Message'])
        except Exception, x:
            gLogger.exception('JobWrapper failed to download input sandbox')
            rescheduleFailedJob(jobID, 'Input Sandbox Download')
            job.sendWMSAccounting('Failed', 'Input Sandbox Download')
            return 1
    else: