def _log_batch(): _validate_batch_log_api_req(_get_request_json()) request_message = _get_request_message(LogBatch()) metrics = [Metric.from_proto(proto_metric) for proto_metric in request_message.metrics] params = [Param.from_proto(proto_param) for proto_param in request_message.params] tags = [RunTag.from_proto(proto_tag) for proto_tag in request_message.tags] _get_store().log_batch(run_id=request_message.run_id, metrics=metrics, params=params, tags=tags) response_message = LogBatch.Response() response = Response(mimetype='application/json') response.set_data(message_to_json(response_message)) return response
def get_param(self, run_uuid, param_name): """ Returns the value of the specified parameter. :param run_uuid: Unique identifier for run :param param_name: Parameter name within the run :return: Value of the given parameter if logged, else None """ req_body = _message_to_json(GetParam(run_uuid=run_uuid, param_name=param_name)) response_proto = self._call_endpoint(GetParam, req_body) return Param.from_proto(response_proto.parameter)
def test_creation_and_hydration(self): key = random_str(random_int( 10, 25)) # random string on size in range [10, 25] value = random_str(random_int( 55, 75)) # random string on size in range [55, 75] param = Param(key, value) self._check(param, key, value) as_dict = {"key": key, "value": value} self.assertEqual(dict(param), as_dict) proto = param.to_proto() param2 = Param.from_proto(proto) self._check(param2, key, value) param3 = Param.from_dictionary(as_dict) self._check(param3, key, value)