From 17a0438862adbf5b28e4964ea7bd60c5f89e4d1d Mon Sep 17 00:00:00 2001 From: gichan Date: Wed, 3 May 2023 16:50:30 +0900 Subject: [PATCH] [Service] Add remote service register function Add the function that registers remote service such as NN models, pipeline description and etc. Signed-off-by: gichan --- c/include/ml-api-service.h | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/c/include/ml-api-service.h b/c/include/ml-api-service.h index 576c7a55..14e71160 100644 --- a/c/include/ml-api-service.h +++ b/c/include/ml-api-service.h @@ -224,6 +224,86 @@ int ml_service_query_create (ml_option_h option, ml_service_h *handle); */ int ml_service_query_request (ml_service_h handle, const ml_tensors_data_h input, ml_tensors_data_h *output); +/** + * @todo DRAFT. API name should be determined later. + * @brief Register new information, such as neural network models or pipeline descriptions, on a remote server. + * @param[in] handle The query service handle created by ml_service_query_create(). + * @param[in] option The option used for registering machine learning service. + * @param[in] data The Data to be registered on the remote server. + * @return 0 on success. Otherwise a negative error value. + * @retval #ML_ERROR_NONE Successful. + * @retval #ML_ERROR_NOT_SUPPORTED Not supported. + * @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid. + * + * Here is an example of the usage: + * @code + * // ================== Server side ================== + * // Example of saving a model file received from a client. + * ml_service_h server_h; + * ml_option_h server_option_h = NULL; + * + * // Set option to handle + * ml_option_create (&server_option_h); + * + * gchar *node_type = g_strdup ("remote_launch_server"); + * ml_option_set (server_option_h, "node_type", node_type, g_free); + * + * // option for receiving model files + * gchar *model_path = g_strdup ("\/model\/path\/"); + * ml_option_set (server_option_h, "model_path", model_path, g_free); + * + * // Set the options required for connection, such as server address, port, protocol, etc. + * gchar *host = g_strdup ("localhost"); + * ml_option_set (server_option_h, "host", host, g_free); + * + * // Create query service. + * ml_service_query_create (server_option_h, &server_h); + * + * // Listen client .. + * + * ml_service_destroy (server_h); + * ml_option_destroy (server_option_h); + * + * // ================== Client side ================== + * // Send neural network model url to the query server. + * ml_service_h client_h; + * ml_option_h client_option_h = NULL; + * + * // Set option to handle + * ml_option_create (&client_option_h); + * + * gchar *node_type = g_strdup ("remote_launch_client"); + * ml_option_set (client_option_h, "node_type", node_type, g_free); + * + * // Set the options required for connection, such as server address, port, protocol, etc. + * gchar *dest_host = g_strdup ("localhost"); + * ml_option_set (client_option_h, "dest_host", dest_host, g_free); + * + * // Create query service. + * ml_service_query_create (client_option_h, &client_h); + * + * ml_option_h query_option_h = NULL; + * ml_option_create (&query_option_h); + * + * gchar *service_type = g_strdup ("model_url"); + * ml_option_set (query_option_h, "service_type", service_type, g_free); + * + * gchar *model_name = g_strdup ("model_name_registered_on_server"); + * ml_option_set (query_option_h, "model_name", model_name, g_free); + * + * gchar *model_url = g_strdup ("example:\/\/url.address"); + * + * ml_service_query_register (client_h, query_option_h, model_url); + * + * g_free (model_url); + * ml_service_destroy (client_h); + * ml_option_destroy (query_option_h); + * ml_option_destroy (client_option_h); + * + * @endcode + */ +int ml_service_query_register (ml_service_h handle, ml_option_h option, void *data); + /** * @brief Registers new information of a neural network model. * @since_tizen 8.0