def _create_experiment(): request_message = _get_request_message(CreateExperiment()) experiment_id = _get_store().create_experiment(request_message.name) response_message = CreateExperiment.Response() response_message.experiment_id = experiment_id response = Response(mimetype='application/json') response.set_data(MessageToJson(response_message)) return response
def _create_experiment(): request_message = _get_request_message(CreateExperiment()) experiment_id = _get_tracking_store().create_experiment(request_message.name, request_message.artifact_location) response_message = CreateExperiment.Response() response_message.experiment_id = experiment_id response = Response(mimetype='application/json') response.set_data(message_to_json(response_message)) return response
def _create_experiment(): request_message = _get_request_message(CreateExperiment()) tags = [ExperimentTag(tag.key, tag.value) for tag in request_message.tags] experiment_id = _get_tracking_store().create_experiment( request_message.name, request_message.artifact_location, tags) response_message = CreateExperiment.Response() response_message.experiment_id = experiment_id response = Response(mimetype="application/json") response.set_data(message_to_json(response_message)) return response
def _create_experiment(): request_message = _get_request_message(CreateExperiment()) # add user id user_id = flask_login.current_user.id experiment_id = _get_tracking_store().create_experiment( request_message.name, user_id, request_message.artifact_location) response_message = CreateExperiment.Response() response_message.experiment_id = experiment_id response = Response(mimetype="application/json") response.set_data(message_to_json(response_message)) return response
def test_can_parse_json_string(): request = mock.MagicMock() request.method = "POST" request.get_json = mock.MagicMock() request.get_json.return_value = '{"name": "hello2"}' msg = _get_request_message(CreateExperiment(), flask_request=request) assert msg.name == "hello2"
def test_can_parse_json(): request = mock.MagicMock() request.query_string = "" request.get_json = mock.MagicMock() request.get_json.return_value = {"name": "hello"} msg = _get_request_message(CreateExperiment(), flask_request=request) assert msg.name == "hello"
def test_can_parse_post_json_with_unknown_fields(): request = mock.MagicMock() request.method = "POST" request.get_json = mock.MagicMock() request.get_json.return_value = {"name": "hello", "WHAT IS THIS FIELD EVEN": "DOING"} msg = _get_request_message(CreateExperiment(), flask_request=request) assert msg.name == "hello"
def create_experiment(self, name): """ Creates a new experiment. If an experiment with the given name already exists, throws exception. :param name: Desired name for an experiment :return: experiment_id (integer) for the newly created experiment if successful, else None """ req_body = MessageToJson(CreateExperiment(name=name)) response_proto = self._call_endpoint(CreateExperiment, req_body) return response_proto.experiment_id
def create_experiment(self, name, artifact_location=None): """ Create a new experiment. If an experiment with the given name already exists, throws exception. :param name: Desired name for an experiment :return: experiment_id (string) for the newly created experiment if successful, else None """ req_body = message_to_json(CreateExperiment(name=name, artifact_location=artifact_location)) response_proto = self._call_endpoint(CreateExperiment, req_body) return response_proto.experiment_id
def test_can_parse_get_json_with_unknown_fields(): request = mock.MagicMock() request.method = "GET" request.query_string = b"name=hello&superDuperUnknown=field" msg = _get_request_message(CreateExperiment(), flask_request=request) assert msg.name == "hello"