def GetJobMetrics(self, request, context): try: return self._server.get_job_metrics(request, context) except UnauthorizedException as e: return service_pb2.GetJobMetricsResponse(status=common_pb2.Status( code=common_pb2.STATUS_UNAUTHORIZED, msg=repr(e))) except Exception as e: logging.error('GetJobMetrics rpc server error: %s', repr(e)) return service_pb2.GetJobMetricsResponse(status=common_pb2.Status( code=common_pb2.STATUS_UNKNOWN_ERROR, msg=repr(e)))
def get_job_metrics(self, request, context): with self._app.app_context(): job = self._check_metrics_public(request, context) metrics = JobMetricsBuilder(job).plot_metrics() return service_pb2.GetJobMetricsResponse( status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS), metrics=json.dumps(metrics))
def get_job_metrics(self, request, context): with self._app.app_context(): project, party = self.check_auth_info(request.auth_info, context) job = Job.query.filter_by(name=request.job_name, project_id=project.id).first() assert job is not None, f'Job {request.job_name} not found' workflow = job.workflow if not workflow.metric_is_public: raise UnauthorizedException('Metric is private!') metrics = JobMetricsBuilder(job).plot_metrics() return service_pb2.GetJobMetricsResponse( status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS), metrics=json.dumps(metrics))
def get_job_metrics(self, job_name): msg = service_pb2.GetJobMetricsRequest( auth_info=self._auth_info, job_name=job_name) try: response = self._client.GetJobMetrics( request=msg, metadata=self._get_metadata()) if response.status.code != common_pb2.STATUS_SUCCESS: logging.error( 'get_job_metrics request error: %s', response.status.msg) return response except Exception as e: logging.error('get_job_metrics request error: %s', repr(e)) return service_pb2.GetJobMetricsResponse( status=common_pb2.Status( code=common_pb2.STATUS_UNKNOWN_ERROR, msg=repr(e)))
def get_job_metrics(self, request, context): with self._app.app_context(): project, party = self.check_auth_info(request.auth_info, context) workflow = Workflow.query.filter_by( name=request.workflow_name).first() assert workflow is not None, \ f'Workflow {request.workflow_name} not found' if not workflow.metric_is_public: raise UnauthorizedException('Metric is private!') job = None for i in workflow.get_jobs(): if i.get_config().name == request.job_name: job = i break assert job is not None, f'Job {request.job_name} not found' metrics = JobMetricsBuilder(job).plot_metrics() return service_pb2.GetJobMetricsResponse( status=common_pb2.Status(code=common_pb2.STATUS_SUCCESS), metrics=json.dumps(metrics))