def _add_job_from_spec(self, job_json, use_job_id=True):
        """ Add a single job to the Dagobah from a spec. """

        job_id = (job_json['job_id']
                  if use_job_id
                  else self.backend.get_new_job_id())
        self.add_job(str(job_json['name']), job_id)
        job = self.get_job(job_json['name'])
        if job_json.get('cron_schedule', None):
            job.schedule(job_json['cron_schedule'])

        for task in job_json.get('tasks', []):
            self.add_task_to_job(job,
                                 str(task['command']),
                                 str(task['name']),
                                 soft_timeout=task.get('soft_timeout', 0),
                                 hard_timeout=task.get('hard_timeout', 0),
                                 hostname=task.get('hostname', None))

        dependencies = job_json.get('dependencies', {})
        for from_node, to_nodes in dependencies.iteritems():
            for to_node in to_nodes:
                job.add_dependency(from_node, to_node)

        if job_json.get('notes', None):
            job.update_job_notes(job_json['notes'])
def _add_job_from_spec ( self , job_json , use_job_id = True ) : job_id = ( job_json [ 'job_id' ] if use_job_id else self . backend . get_new_job_id ( ) ) self . add_job ( str ( job_json [ 'name' ] ) , job_id ) job = self . get_job ( job_json [ 'name' ] ) if job_json . get ( 'cron_schedule' , None ) : job . schedule ( job_json [ 'cron_schedule' ] ) for task in job_json . get ( 'tasks' , [ ] ) : self . add_task_to_job ( job , str ( task [ 'command' ] ) , str ( task [ 'name' ] ) , soft_timeout = task . get ( 'soft_timeout' , 0 ) , hard_timeout = task . get ( 'hard_timeout' , 0 ) , hostname = task . get ( 'hostname' , None ) ) dependencies = job_json . get ( 'dependencies' , { } ) for from_node , to_nodes in dependencies . iteritems ( ) : for to_node in to_nodes : job . add_dependency ( from_node , to_node ) if job_json . get ( 'notes' , None ) : job . update_job_notes ( job_json [ 'notes' ] )
Add a single job to the Dagobah from a spec.