Esempio n. 1
0
def _get_metric():
    request_message = _get_request_message(GetMetric())
    response_message = GetMetric.Response()
    metric = _get_store().get_metric(request_message.run_uuid, request_message.metric_key)
    response_message.metric.MergeFrom(metric.to_proto())
    response = Response(mimetype='application/json')
    response.set_data(_message_to_json(response_message))
    return response
Esempio n. 2
0
def _get_metric():
    request_message = _get_request_message(GetMetric(), from_get=True)
    response_message = GetMetric.Response()
    metric = _get_store().get_metric(request_message.run_uuid,
                                     request_message.metric_key)
    response_message.metric.MergeFrom(metric.to_proto())
    response = Response(mimetype='application/json')
    response.set_data(
        MessageToJson(response_message, preserving_proto_field_name=True))
    return response
    def get_metric(self, run_uuid, metric_key):
        """
        Returns the last logged value for a given metric.

        :param run_uuid: Unique identifier for run
        :param metric_key: Metric name within the run

        :return: A single float value for the give metric if logged, else None
        """
        req_body = _message_to_json(GetMetric(run_uuid=run_uuid, metric_key=metric_key))
        response_proto = self._call_endpoint(GetMetric, req_body)
        return Metric.from_proto(response_proto.metric)