def register_metric_summary( self, metric_name: Text, metric_key: Text, metric_value: Text, metric_timestamp: int, model_version: Optional[Text] = None, job_execution_id: Optional[Text] = None ) -> Tuple[int, Text, Optional[MetricSummary]]: """ Register metric summary in Metric Center. :param metric_name: Name of registered metric summary. :param metric_key: Key of registered metric summary. :param metric_value: Value of registered metric summary. :param metric_timestamp: Timestamp of registered metric summary. :param model_version: (Optional) Version of the model version associated with the registered metric summary. :param job_execution_id: (Optional) ID of the job execution associated with the registered metric summary. :return: A single :py:class:`ai_flow.meta.metric_meta.MetricSummary` object. """ request = MetricSummaryRequest(metric_summary=MetricSummaryProto( metric_name=stringValue(metric_name), metric_key=stringValue(metric_key), metric_value=stringValue(metric_value), metric_timestamp=int64Value(metric_timestamp), model_version=stringValue(model_version), job_execution_id=stringValue(job_execution_id))) response = self.metric_stub.registerMetricSummary(request) if 0 == response.return_code: metric_summary_proto = response.metric_summary metric_summary = proto_to_metric_summary(metric_summary_proto) return response.return_code, response.return_msg, metric_summary else: return response.return_code, response.return_msg, None
def registerMetricSummary(self, request, context): metric_summary_proto = request.metric_summary metric_summary = proto_to_metric_summary(metric_summary_proto) res_metric_summary = self.store.register_metric_summary( metric_summary.metric_name, metric_summary.metric_key, metric_summary.metric_value, metric_summary.metric_timestamp, metric_summary.model_version, metric_summary.job_execution_id) return _warp_metric_summary_response(res_metric_summary)
def registerMetricSummary(self, request, context): metric_summary_proto = request.metric_summary metric_summary = proto_to_metric_summary(metric_summary_proto) res_metric_summary = self.store.register_metric_summary( metric_id=metric_summary.metric_id, metric_key=metric_summary.metric_key, metric_value=metric_summary.metric_value) return _warp_metric_summary_response(res_metric_summary)
def list_metric_summaries( self, metric_name: Optional[Text] = None, metric_key: Optional[Text] = None, model_version: Optional[Text] = None, start_time: int = None, end_time=None ) -> Tuple[int, Text, Union[None, MetricSummary, List[MetricSummary]]]: """ List of metric summaries filter by metric summary fields for Metric Center. :param metric_name: (Optional) Name of filtered metric summary. :param metric_key: (Optional) Key of filtered metric summary. :param model_version: (Optional) Version of the model version associated with the registered metric summary. :param start_time: (Optional) Start time for timestamp filtered metric summary. :param end_time: (Optional) End time for timestamp filtered metric summary. :return: List of :py:class:`ai_flow.meta.metric_meta.MetricSummary` objects. """ request = ListMetricSummariesRequest( metric_name=stringValue(metric_name), metric_key=stringValue(metric_key), model_version=stringValue(model_version), start_time=int64Value(start_time), end_time=int64Value(end_time)) response = self.metric_stub.listMetricSummaries(request) if 0 == response.return_code: repeated_metric_summary_proto = response.metric_summaries if 1 == len(repeated_metric_summary_proto): metric_summary = proto_to_metric_summary( repeated_metric_summary_proto[0]) return response.return_code, response.return_msg, metric_summary else: res = [] for metric_summary_proto in repeated_metric_summary_proto: res.append(proto_to_metric_summary(metric_summary_proto)) return response.return_code, response.return_msg, res else: return response.return_code, response.return_msg, None
def get_metric_summary(self, metric_id: int) \ -> Tuple[int, Text, Union[None, List[MetricSummary]]]: request = metric_service_pb2.GetMetricSummaryRequest(metric_id=metric_id) response = self.metric_stub.getMetricSummary(request) if 0 == response.return_code: repeated_metric_summary_proto = response.metric_summary if 0 == len(repeated_metric_summary_proto): return response.return_code, response.return_msg, None else: res = [] for metric_summary_proto in repeated_metric_summary_proto: res.append(proto_to_metric_summary(metric_summary_proto)) return response.return_code, response.return_msg, res else: return response.return_code, response.return_msg, None
def get_metric_summary( self, uuid: int) -> Tuple[int, Text, Union[None, MetricSummary]]: """ Get metric summary detail filter by summary uuid for Metric Center. :param uuid: UUID of registered metric summary. :return: A single :py:class:`ai_flow.meta.metric_meta.MetricSummary` object. """ request = UuidRequest(uuid=uuid) response = self.metric_stub.getMetricSummary(request) if 0 == response.return_code: metric_summary_proto = response.metric_summary metric_summary = proto_to_metric_summary(metric_summary_proto) return response.return_code, response.return_msg, metric_summary else: return response.return_code, response.return_msg, None
def register_metric_summary(self, metric_id: int, metric_key: Text, metric_value: Text ) -> Tuple[int, Text, Optional[MetricSummary]]: request = metric_service_pb2.MetricSummaryRequest( metric_summary=message_pb2.MetricSummaryProto( metric_id=int64Value(metric_id), metric_key=stringValue(metric_key), metric_value=stringValue(metric_value)) ) response = self.metric_stub.registerMetricSummary(request) if 0 == response.return_code: metric_summary_proto = response.metric_summary metric_summary = proto_to_metric_summary(metric_summary_proto) return response.return_code, response.return_msg, metric_summary else: return response.return_code, response.return_msg, None