How to use the ganga.GangaCore.GPIDev.Lib.Job.Job.JobError function in ganga

To help you get started, we’ve selected a few ganga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
logger.info('resubmitting job %s', fqid)

        if backend and auto_resubmit:
            msg = "job %s: cannot change backend when auto_resubmit=True. This is most likely an internal implementation problem." % self.getFQID('.')
            logger.error(msg)
            raise JobError(msg)

        if len(self.subjobs) != 0:
            these_jobs = self.subjobs
        else:
            these_jobs = [self]

        for this_job in these_jobs:
            (validOutputFiles, errorMsg) = this_job.validateOutputfilesOnSubmit()
            if not validOutputFiles:
                raise JobError(errorMsg)

        if self.status in ['new']:
            msg = "cannot resubmit a new job %s, please use submit()" % (self.getFQID('.'))
            logger.error(msg)
            raise JobError(msg)

        # the status check is disabled when auto_resubmit
        if self.status not in ['completed', 'failed', 'killed'] and not auto_resubmit:
            msg = "cannot resubmit job %s which is in '%s' state" % (self.getFQID('.'), self.status)
            logger.error(msg)
            raise JobError(msg)

        if backend is not None:
            backend = backend

        # do not allow to change the backend type
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
msg = "cannot resubmit job %s: change of the backend type is not allowed" % self.getFQID('.')
            logger.error(msg)
            raise JobError(msg)

        # if the backend argument is identical (no attributes changed) then it is equivalent to None
        # the good side effect is that in this case we don't require any backend resubmit method to support
        # the extra backend argument
        if backend == self.backend:
            backend = None

        # check if the backend supports extra 'backend' argument for
        # master_resubmit()
        supports_master_resubmit = len(inspect.getfullargspec(self.backend.master_resubmit)[0]) > 1

        if not supports_master_resubmit and backend:
            raise JobError('%s backend does not support changing of backend parameters at resubmission (optional backend argument is not supported)' % getName(self.backend))

        def check_changability(obj1, obj2):
            # check if the only allowed attributes have been modified
            for name, item in obj1._schema.allItems():
                v1 = getattr(obj1, name)
                v2 = getattr(obj2, name)
                if not item['changable_at_resubmit'] and item['copyable']:
                    if v1 != v2:
                        raise JobError('%s.%s attribute cannot be changed at resubmit' % (getName(obj1), name))
                if item.isA(ComponentItem):
                    check_changability(v1, v2)

        if backend:
            check_changability(self.backend, backend)

        oldstatus = self.status
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
rjobs = self._doSplitting()

            # Some old jobs may still contain None assigned to the self.subjobs so be careful when checking length
            if self.splitter is not None and not self.subjobs:
                raise SplitterError("Splitter '%s' failed to produce any subjobs from splitting. Aborting submit" % (getName(self.splitter),))

            #
            logger.debug("Now have %s subjobs" % len(self.subjobs))
            logger.debug("Also have %s rjobs" % len(rjobs))

            # Output Files
            # validate the output files
            for this_job in rjobs:
                (validOutputFiles, errorMsg) = this_job.validateOutputfilesOnSubmit()
                if not validOutputFiles:
                    raise JobError(errorMsg)

            # configure the application of each subjob
            appsubconfig = self._getAppSubConfig(rjobs)
            if appsubconfig is not None:
                logger.debug("# appsubconfig: %s" % len(appsubconfig))

            # Job Configuration
            logger.debug("Job Configuration, Job %s:" % self.getFQID('.'))

            # prepare the master job with the correct runtime handler
            # Calls rtHandler.master_prepare if it hasn't already been called by the master job or by self
            # Only stored as transient if the master_prepare successfully
            # completes
            jobmasterconfig = self._getJobMasterConfig()
            logger.debug("Preparing with: %s" % getName(rtHandler))
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
############
                    # added as part of typestamp prototype by Justin
                    if not self._getParent():
                        for jobs in self.getJobObject().subjobs:
                            # added this 10/8/2009 - now only kills subjobs
                            # which aren't finished.
                            if jobs.status not in ['failed', 'killed', 'completed']:
                                jobs.updateStatus('killed', transition_update=transition_update)
                    self.updateStatus('killed', transition_update=transition_update)
                    #
                    ############

                    return True
                else:
                    msg = "backend.master_kill() returned False"
                    raise JobError(msg)
            except GangaException as x:
                msg = "failed to kill job %s: %s" % (self.getFQID('.'), x)
                logger.error(msg)
                raise JobError(msg)
        finally:
            pass  # job._registry.cache_writers_mutex.release()
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
"""

        this_job_status = lazyLoadJobStatus(self)
        this_job_id = lazyLoadJobFQID(self)

        template = this_job_status == 'template'

        if template:
            logger.info('removing template %s', this_job_id)
        else:
            logger.info('removing job %s', this_job_id)

        if this_job_status == 'removed':
            msg = 'job %s already removed' % this_job_id
            logger.error(msg)
            raise JobError(msg)

        if this_job_status == 'completing':
            msg = 'job %s is completing (may be downloading output), do force_status("failed") and then remove() again' % self.getFQID('.')
            logger.error(msg)
            raise JobError(msg)

        if self.master is not None:
            msg = 'cannot remove subjob %s' % self.getFQID('.')
            logger.info(msg)
            raise JobError(msg)

        if getConfig('Output')['AutoRemoveFilesWithJob']:
            logger.info('Removing all output data of types %s' % getConfig('Output')['AutoRemoveFileTypes'])
            def removeFiles(this_file):
                if getName(this_file) in getConfig('Output')['AutoRemoveFileTypes'] and hasattr(this_file, '_auto_remove'):
                    this_file._auto_remove()
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
optimise disk usage of the Ganga client.

        See help(j.application.prepare) for application-specific comments.

        Prepared applications are always associated with a Shared Directory object
        which contains their required files. Details for all Shared Directories in use
        can been seen by calling 'shareref'. See help(shareref) for further details.

        """
        if not hasattr(self.application, 'is_prepared'):
            logger.warning("Non-preparable application %s cannot be prepared" % getName(self.application))
            return

        if (self.application.is_prepared is not None) and (force is False):
            msg = "The application associated with job %s has already been prepared. To force the operation, call prepare(force=True)" % self.id
            raise JobError(msg)
        if (self.application.is_prepared is None):
            add_to_inputsandbox = addProxy(self.application).prepare()
            if isType(add_to_inputsandbox, (list, tuple, GangaList)):
                self.inputsandbox.extend(add_to_inputsandbox)
        elif (self.application.is_prepared is not None) and (force is True):
            self.application.unprepare(force=True)
            addProxy(self.application).prepare(force=True)
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
"""Private helper. Kill the job. Raise JobError exception on error.
        """
        try:
            # make sure nobody writes to the cache during this operation
            # job._registry.cache_writers_mutex.lock()

            fqid = self.getFQID('.')
            logger.info('killing job %s', fqid)
            if self.status not in ['submitted', 'running']:
                if self.status in ['completed', 'failed']:
                    logger.warning("Job %s has already reached it's final state: %s and cannot be killed" % (self.getFQID('.'), self.status))
                    return True
                else:
                    msg = "cannot kill job which is in '%s' state. " % self.status
                    logger.error(msg)
                    raise JobError(msg)
            try:
                if self.backend.master_kill():
                    ############
                    # added as part of typestamp prototype by Justin
                    if not self._getParent():
                        for jobs in self.getJobObject().subjobs:
                            # added this 10/8/2009 - now only kills subjobs
                            # which aren't finished.
                            if jobs.status not in ['failed', 'killed', 'completed']:
                                jobs.updateStatus('killed', transition_update=transition_update)
                    self.updateStatus('killed', transition_update=transition_update)
                    #
                    ############

                    return True
                else: