How to use ganga - 10 common examples

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 / JobTree / JobTree.py View on Github external
def rm(self, path):
        """Removes folder or job in the path.
        To clean all use /* as a path.
        """
        try:
            path = str(path)
            pp = self.__get_path(path)
            if len(pp) > 1:
                dpath = os.path.join(*pp[:-1])
                f = self.__select_dir(dpath)
                if pp[-1] != '*':
                    try:
                        self.__remove_dir(path=dpath, dir=pp[-1])
                    except KeyError:
                        raise TreeError(1, "%s does not exist" % pp[-1])
                else:
                    for k in list(self.__get_folders()):
                        del self.__get_folders()[k]
            else:
                raise TreeError(3, "Can not delete the root directory")
            self._setDirty()
        finally:
            self._releaseSessionLockAndFlush()
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),
                                  State('submitting', 'j.resubmit(force=1)'),
                                  State('submitted', 'j.resubmit(force=1)')),
        'killed': Transitions(State('removed', 'j.remove()'),
                              State('failed', 'j.fail()'),
                              State('submitting', 'j.resubmit()'),
                              State('submitted', 'j.resubmit()')),
        'failed': Transitions(State('removed', 'j.remove()'),
                              State('submitting', 'j.resubmit()'),
                              State('completed', hook='postprocess_hook'),
                              State('submitted', 'j.resubmit()')),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),
                                  State('submitting', 'j.resubmit(force=1)'),
                                  State('submitted', 'j.resubmit(force=1)')),
        'killed': Transitions(State('removed', 'j.remove()'),
                              State('failed', 'j.fail()'),
                              State('submitting', 'j.resubmit()'),
                              State('submitted', 'j.resubmit()')),
        'failed': Transitions(State('removed', 'j.remove()'),
                              State('submitting', 'j.resubmit()'),
                              State('completed', hook='postprocess_hook'),
                              State('submitted', 'j.resubmit()')),
        'completed': Transitions(State('removed', 'j.remove()'),
                                 State('failed', 'j.fail()'),
                                 State('submitting', 'j.resubmit()'),
                                 State('submitted', 'j.resubmit()')),
        'incomplete': Transitions(State('removed', 'j.remove()')),
        'unknown': Transitions(State('removed', 'forced remove')),
        'template': Transitions(State('removed'))
    }

    transient_states = ['incomplete', 'removed', 'unknown']
    initial_states = ['new', 'incomplete', 'template']

    def updateStatus(self, newstatus, transition_update=True, update_master=True, ignore_failures=False):
        """ Move job to the new status. according to the state transition graph (Job.status_graph).
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
self.state = state
            self.transition_comment = transition_comment
            self.hook = hook

    class Transitions(dict):

        def __init__(self, *states):
            self.states = {}
            for s in states:
                assert(s.state not in self)
                self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
class State(object):

        def __init__(self, state, transition_comment='', hook=None):
            self.state = state
            self.transition_comment = transition_comment
            self.hook = hook

    class Transitions(dict):

        def __init__(self, *states):
            self.states = {}
            for s in states:
                assert(s.state not in self)
                self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
class Transitions(dict):

        def __init__(self, *states):
            self.states = {}
            for s in states:
                assert(s.state not in self)
                self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),
                                  State('submitting', 'j.resubmit(force=1)'),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),
                                  State('submitting', 'j.resubmit(force=1)'),
                                  State('submitted', 'j.resubmit(force=1)')),
        'killed': Transitions(State('removed', 'j.remove()'),
                              State('failed', 'j.fail()'),
                              State('submitting', 'j.resubmit()'),
                              State('submitted', 'j.resubmit()')),
        'failed': Transitions(State('removed', 'j.remove()'),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),
                                  State('submitting', 'j.resubmit(force=1)'),
                                  State('submitted', 'j.resubmit(force=1)')),
        'killed': Transitions(State('removed', 'j.remove()'),
                              State('failed', 'j.fail()'),
                              State('submitting', 'j.resubmit()'),
                              State('submitted', 'j.resubmit()')),
        'failed': Transitions(State('removed', 'j.remove()'),
                              State('submitting', 'j.resubmit()'),
                              State('completed', hook='postprocess_hook'),
                              State('submitted', 'j.resubmit()')),
        'completed': Transitions(State('removed', 'j.remove()'),
                                 State('failed', 'j.fail()'),
                                 State('submitting', 'j.resubmit()'),
                                 State('submitted', 'j.resubmit()')),
        'incomplete': Transitions(State('removed', 'j.remove()')),
        'unknown': Transitions(State('removed', 'forced remove')),
        'template': Transitions(State('removed'))
    }

    transient_states = ['incomplete', 'removed', 'unknown']
    initial_states = ['new', 'incomplete', 'template']

    def updateStatus(self, newstatus, transition_update=True, update_master=True, ignore_failures=False):
        """ Move job to the new status. according to the state transition graph (Job.status_graph).
        If transition is allowed:
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
self.hook = hook

    class Transitions(dict):

        def __init__(self, *states):
            self.states = {}
            for s in states:
                assert(s.state not in self)
                self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
github ganga-devs / ganga / ganga / GangaCore / GPIDev / Lib / Job / Job.py View on Github external
class Transitions(dict):

        def __init__(self, *states):
            self.states = {}
            for s in states:
                assert(s.state not in self)
                self[s.state] = s

    status_graph = {'new': Transitions(State('submitting', 'j.submit()', hook='monitorSubmitting_hook'),
                                       State('removed', 'j.remove()')),
        'submitting': Transitions(State('new', 'submission failed', hook='rollbackToNewState'),
                                  State('submitted', hook='monitorSubmitted_hook'),
                                  State('unknown', 'forced remove OR remote jobmgr error'),
                                  State('failed', 'manually forced or keep_on_failed=True', hook='monitorFailed_hook')),
        'submitted': Transitions(State('running'),
                                 State('killed', 'j.kill()', hook='monitorKilled_hook'),
                                 State('unknown', 'forced remove'),
                                 State('failed', 'j.fail(force=1)', hook='monitorFailed_hook'),
                                 State('completing'),
                                 State('completed', hook='postprocess_hook'),
                                 State('submitting', 'j.resubmit(force=1)')),
        'running': Transitions(State('completing'),
                               State('completed', 'job output already in outputdir', hook='postprocess_hook'),
                               State('failed', 'backend reported failure OR j.fail(force=1)', hook='monitorFailed_hook'),
                               State('killed', 'j.kill()', hook='monitorKilled_hook'),
                               State('unknown', 'forced remove'),
                               State('submitting', 'j.resubmit(force=1)'),
                               State('submitted', 'j.resubmit(force=1)')),
        'completing': Transitions(State('completed', hook='postprocess_hook'),
                                  State('failed', 'postprocessing error OR j.fail(force=1)', hook='postprocess_hook_failed'),
                                  State('unknown', 'forced remove'),