Commit c4fb1590 authored by Antoine Millet's avatar Antoine Millet
Browse files

Added batch identifier to jobs

parent 14cbed04
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ class JobState(object):

    STATES = ('init', 'running', 'done', 'cancelling', 'rollbacking')

    def __init__(self, logger, job_class, job_id, manager, owner, settings, system=False):
    def __init__(self, logger, job_class, job_id, manager, owner, settings,
                 system=False, batch=None):
        self.logger = logger
        self._frozen = False  # Is the jobstate frozen (loaded from store and
                               # no more modifiable)
@@ -61,6 +62,7 @@ class JobState(object):
        self._ended = None                          # Termination date of the job
        self._system = system                       # Is a system job?
        self._attachments = set()                   # Files attached to the job
        self._batch = batch                         # Batch identifier

        # Bound to the job itself:
        self._job = job_class(self.logger, self, **settings)
@@ -110,6 +112,10 @@ class JobState(object):
    def system(self):
        return self._system

    @property
    def batch(self):
        return self._batch

    @property
    def title(self):
        return self._title
+2 −2
Original line number Diff line number Diff line
@@ -52,13 +52,13 @@ class JobsManager(object):
    # Public methods
    #

    def spawn(self, job_class, owner, system=False, settings={}):
    def spawn(self, job_class, owner, system=False, batch=None, settings={}):
        """ Spawn a new job.
        """
        job_id = 'job-%s' % self._counter.get()
        job_logger = self.logger.getChild(str(job_id))
        job = JobState(job_logger, job_class, job_id, self, owner,
                       settings=settings, system=system)
                       settings=settings, system=system, batch=batch)
        if not system:
            self._store.create_job(job)
            self._interface.on_job_created(job)