예제 #1
0
def run(args):
    jobs = taro.client.read_jobs_info(args.instance)
    if args.format == 'table':
        ps.print_table(jobs,
                       view_inst.DEFAULT_COLUMNS,
                       _colours,
                       show_header=True,
                       pager=False)
    elif args.format == 'json':
        print(json.dumps([dto.to_info_dto(job) for job in jobs]))
    elif args.format == 'jsonp':
        json_str = json.dumps([dto.to_info_dto(job) for job in jobs], indent=2)
        print(highlight(json_str, JsonLexer(), TerminalFormatter()))
    else:
        assert False, 'Unknown format: ' + args.format
예제 #2
0
 def state_update(self, job_info: JobInfo):
     event_body = {
         "event_type": "execution_state_change",
         "event": {
             "job_info": dto.to_info_dto(job_info)
         }
     }
     self._client.communicate(event_body)
예제 #3
0
 def output_update(self, job_info: JobInfo, output):
     event_body = {
         "event_type": "new_output",
         "event": {
             "job_info": dto.to_info_dto(job_info),
             "output": output
         }
     }
     self._client.communicate(event_body)
예제 #4
0
    def handle(self, req_body):
        job_inst = (self._job_instance.job_id, self._job_instance.instance_id)

        if 'req' not in req_body:
            return _resp_err(422, job_inst, "missing_req")
        if 'api' not in req_body['req']:
            return _resp_err(422, job_inst, "missing_req_api")

        inst_filter = req_body.get('instance')
        if inst_filter and not self._job_instance.create_info().matches(inst_filter):
            return _resp(412, job_inst, {"reason": "instance_not_matching"})

        if req_body['req']['api'] == '/job':
            info_dto = dto.to_info_dto(self._job_instance.create_info())
            return _resp(200, job_inst, {"job_info": info_dto})

        if req_body['req']['api'] == '/release':
            if 'data' not in req_body:
                return _resp_err(422, job_inst, "missing_data")
            if 'pending' not in req_body['data']:
                return _resp_err(422, job_inst, "missing_data_field:pending")

            if self._latch_release:
                released = self._latch_release.release(req_body.get('data').get('pending'))
            else:
                released = False
            return _resp(200, job_inst, {"released": released})

        if req_body['req']['api'] == '/stop':
            self._job_instance.stop()
            return _resp(200, job_inst, {"result": "stop_performed"})

        if req_body['req']['api'] == '/interrupt':
            self._job_instance.interrupt()
            return _resp(200, job_inst, {"result": "interrupt_performed"})

        if req_body['req']['api'] == '/tail':
            return _resp(200, job_inst, {"tail": self._job_instance.last_output})

        return _resp_err(404, job_inst, "req_api_not_found")
예제 #5
0
파일: app.py 프로젝트: taro-suite/taro
def resource_job_info(job_info):
    return resource(dto.to_info_dto(job_info),
                    links={
                        "self": "/instances/" + job_info.instance_id,
                        "jobs": "/jobs/" + job_info.job_id
                    })