def new_job_run_save(): """ JobRuns cannot be created classically from the GUI, only by hitting the Run button on a template, which creates and schedules the job run to be run immediately. Normally job runs are created by the background scheduler. """ jt = db_session.query(JobTemplate).get(request.json["job_template_id"]) jr = JobRun.create_job_run(jt) return jsonify({"id": jr.id})
def _decorator(self, *args, **kwargs): jt = JobTemplate(log_level=LogLevel.complete, name="Gob") self.s.add(jt) # Actually runs the job jr = JobRun.create_job_run(jt) jr = self.s.query(JobRun).get(jr.id) jt = self.s.query(JobTemplate).get(jt.id) func(self, jt, jr)
def assert_event(self, job_run_status, event_type, event_index, table='test.test_uniqueness_success'): c = Check(check_type=CheckType.uniqueness, check_metadata={'column': 'id'}) j = JobRun(status=job_run_status, scheduled_at=now()) d = self.dummy_datasource() self.s.add_all([c, j, d]) self.s.commit() c.run(j, d, table) l = c.logs[0] event = l.log[event_index] print event self.assertEqual(event['event'], event_type)
def _decorator(self, *args, **kwargs): jt = JobTemplate(log_level=LogLevel.complete, name="Gob") r = Rule(condition=RuleCondition.if_col_present, conditional={'column': 'id'}, checks=[ Check(check_type=CheckType.uniqueness, check_metadata={'column': 'id'}) ]) jt.data_sources.append(self.dummy_datasource()) jt.rules.append(r) self.s.add_all([jt, r]) # Actually runs the job jr = JobRun.create_job_run(jt) # Refresh Obj from DB jr = self.s.query(JobRun).get(jr.id) jt = self.s.query(JobTemplate).get(jt.id) func(self, jt, jr)
def dummy_job_run(self, d): return JobRun(job_template=JobTemplate(data_sources=[d], name="B"), scheduled_at=now(), status=JobRunStatus.running)