|
| 1 | +/* SPDX-License-Identifier: Apache-2.0 */ |
| 2 | +/** |
| 3 | + * @file mlops-agent-android.c |
| 4 | + * @date 5 April 2023 |
| 5 | + * @brief A set of exported ml-agent interfaces for managing pipelines, models, and other service. |
| 6 | + * @see https://github.com/nnstreamer/deviceMLOps.MLAgent |
| 7 | + * @author Wook Song <[email protected]> |
| 8 | + * @bug No known bugs except for NYI items |
| 9 | + */ |
| 10 | + |
| 11 | +#include <errno.h> |
| 12 | +#include <glib.h> |
| 13 | +#include <stdint.h> |
| 14 | +#include "include/mlops-agent-interface.h" |
| 15 | + |
| 16 | +#define STR_IS_VALID(s) ((s) && (s)[0] != '\0') |
| 17 | + |
| 18 | +typedef enum |
| 19 | +{ |
| 20 | + ML_AGENT_SERVICE_PIPELINE = 0, |
| 21 | + ML_AGENT_SERVICE_MODEL, |
| 22 | + ML_AGENT_SERVICE_RESOURCE, |
| 23 | + ML_AGENT_SERVICE_END |
| 24 | +} ml_agent_service_type_e; |
| 25 | + |
| 26 | +/** |
| 27 | + * @brief An interface exported for setting the description of a pipeline. |
| 28 | + */ |
| 29 | +int |
| 30 | +ml_agent_pipeline_set_description (const char *name, const char *pipeline_desc) |
| 31 | +{ |
| 32 | + if (!STR_IS_VALID (name) || !STR_IS_VALID (pipeline_desc)) { |
| 33 | + g_return_val_if_reached (-EINVAL); |
| 34 | + } |
| 35 | + |
| 36 | + return 0; |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * @brief An interface exported for getting the pipeline's description corresponding to the given @a name. |
| 41 | + */ |
| 42 | +int |
| 43 | +ml_agent_pipeline_get_description (const char *name, char **pipeline_desc) |
| 44 | +{ |
| 45 | + if (!STR_IS_VALID (name) || !pipeline_desc) { |
| 46 | + g_return_val_if_reached (-EINVAL); |
| 47 | + } |
| 48 | + |
| 49 | + return 0; |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * @brief An interface exported for deletion of the pipeline's description corresponding to the given @a name. |
| 54 | + */ |
| 55 | +int |
| 56 | +ml_agent_pipeline_delete (const char *name) |
| 57 | +{ |
| 58 | + if (!STR_IS_VALID (name)) { |
| 59 | + g_return_val_if_reached (-EINVAL); |
| 60 | + } |
| 61 | + |
| 62 | + return 0; |
| 63 | +} |
| 64 | + |
| 65 | +/** |
| 66 | + * @brief An interface exported for launching the pipeline's description corresponding to the given @a name. |
| 67 | + */ |
| 68 | +int |
| 69 | +ml_agent_pipeline_launch (const char *name, int64_t * id) |
| 70 | +{ |
| 71 | + if (!STR_IS_VALID (name) || !id) { |
| 72 | + g_return_val_if_reached (-EINVAL); |
| 73 | + } |
| 74 | + |
| 75 | + return 0; |
| 76 | +} |
| 77 | + |
| 78 | +/** |
| 79 | + * @brief An interface exported for changing the pipeline's state of the given @a id to start. |
| 80 | + */ |
| 81 | +int |
| 82 | +ml_agent_pipeline_start (const int64_t id) |
| 83 | +{ |
| 84 | + return 0; |
| 85 | +} |
| 86 | + |
| 87 | +/** |
| 88 | + * @brief An interface exported for changing the pipeline's state of the given @a id to stop. |
| 89 | + */ |
| 90 | +int |
| 91 | +ml_agent_pipeline_stop (const int64_t id) |
| 92 | +{ |
| 93 | + return 0; |
| 94 | +} |
| 95 | + |
| 96 | +/** |
| 97 | + * @brief An interface exported for destroying a launched pipeline corresponding to the given @a id. |
| 98 | + */ |
| 99 | +int |
| 100 | +ml_agent_pipeline_destroy (const int64_t id) |
| 101 | +{ |
| 102 | + return 0; |
| 103 | +} |
| 104 | + |
| 105 | +/** |
| 106 | + * @brief An interface exported for getting the pipeline's state of the given @a id. |
| 107 | + */ |
| 108 | +int |
| 109 | +ml_agent_pipeline_get_state (const int64_t id, int *state) |
| 110 | +{ |
| 111 | + return 0; |
| 112 | +} |
| 113 | + |
| 114 | +/** |
| 115 | + * @brief An interface exported for registering a model. |
| 116 | + */ |
| 117 | +int |
| 118 | +ml_agent_model_register (const char *name, const char *path, |
| 119 | + const int activate, const char *description, const char *app_info, |
| 120 | + uint32_t * version) |
| 121 | +{ |
| 122 | + if (!STR_IS_VALID (name) || !STR_IS_VALID (path) || !version) { |
| 123 | + g_return_val_if_reached (-EINVAL); |
| 124 | + } |
| 125 | + return 0; |
| 126 | +} |
| 127 | + |
| 128 | +/** |
| 129 | + * @brief An interface exported for updating the description of the model with @a name and @a version. |
| 130 | + */ |
| 131 | +int |
| 132 | +ml_agent_model_update_description (const char *name, |
| 133 | + const uint32_t version, const char *description) |
| 134 | +{ |
| 135 | + if (!STR_IS_VALID (name) || !STR_IS_VALID (description) || version == 0U) { |
| 136 | + g_return_val_if_reached (-EINVAL); |
| 137 | + } |
| 138 | + return 0; |
| 139 | +} |
| 140 | + |
| 141 | +/** |
| 142 | + * @brief An interface exported for activating the model with @a name and @a version. |
| 143 | + */ |
| 144 | +int |
| 145 | +ml_agent_model_activate (const char *name, const uint32_t version) |
| 146 | +{ |
| 147 | + if (!STR_IS_VALID (name) || version == 0U) { |
| 148 | + g_return_val_if_reached (-EINVAL); |
| 149 | + } |
| 150 | + |
| 151 | + return 0; |
| 152 | +} |
| 153 | + |
| 154 | +/** |
| 155 | + * @brief An interface exported for getting the information of the model with @a name and @a version. |
| 156 | + */ |
| 157 | +int |
| 158 | +ml_agent_model_get (const char *name, const uint32_t version, char **model_info) |
| 159 | +{ |
| 160 | + if (!STR_IS_VALID (name) || !model_info || version == 0U) { |
| 161 | + g_return_val_if_reached (-EINVAL); |
| 162 | + } |
| 163 | + |
| 164 | + return 0; |
| 165 | +} |
| 166 | + |
| 167 | +/** |
| 168 | + * @brief An interface exported for getting the information of the activated model with @a name. |
| 169 | + */ |
| 170 | +int |
| 171 | +ml_agent_model_get_activated (const char *name, char **model_info) |
| 172 | +{ |
| 173 | + if (!STR_IS_VALID (name) || !model_info) { |
| 174 | + g_return_val_if_reached (-EINVAL); |
| 175 | + } |
| 176 | + |
| 177 | + return 0; |
| 178 | +} |
| 179 | + |
| 180 | +/** |
| 181 | + * @brief An interface exported for getting the information of all the models corresponding to the given @a name. |
| 182 | + */ |
| 183 | +int |
| 184 | +ml_agent_model_get_all (const char *name, char **model_info) |
| 185 | +{ |
| 186 | + if (!STR_IS_VALID (name) || !model_info) { |
| 187 | + g_return_val_if_reached (-EINVAL); |
| 188 | + } |
| 189 | + |
| 190 | + return 0; |
| 191 | +} |
| 192 | + |
| 193 | +/** |
| 194 | + * @brief An interface exported for removing the model of @a name and @a version. |
| 195 | + * @details If @a force is true, this will delete the model even if it is activated. |
| 196 | + */ |
| 197 | +int |
| 198 | +ml_agent_model_delete (const char *name, const uint32_t version, |
| 199 | + const int force) |
| 200 | +{ |
| 201 | + if (!STR_IS_VALID (name)) { |
| 202 | + g_return_val_if_reached (-EINVAL); |
| 203 | + } |
| 204 | + |
| 205 | + return 0; |
| 206 | +} |
| 207 | + |
| 208 | +/** |
| 209 | + * @brief An interface exported for adding the resource. |
| 210 | + */ |
| 211 | +int |
| 212 | +ml_agent_resource_add (const char *name, const char *path, |
| 213 | + const char *description, const char *app_info) |
| 214 | +{ |
| 215 | + if (!STR_IS_VALID (name) || !STR_IS_VALID (path)) { |
| 216 | + g_return_val_if_reached (-EINVAL); |
| 217 | + } |
| 218 | + |
| 219 | + return 0; |
| 220 | +} |
| 221 | + |
| 222 | +/** |
| 223 | + * @brief An interface exported for removing the resource with @a name. |
| 224 | + */ |
| 225 | +int |
| 226 | +ml_agent_resource_delete (const char *name) |
| 227 | +{ |
| 228 | + if (!STR_IS_VALID (name)) { |
| 229 | + g_return_val_if_reached (-EINVAL); |
| 230 | + } |
| 231 | + |
| 232 | + return 0; |
| 233 | +} |
| 234 | + |
| 235 | +/** |
| 236 | + * @brief An interface exported for getting the description of the resource with @a name. |
| 237 | + */ |
| 238 | +int |
| 239 | +ml_agent_resource_get (const char *name, char **res_info) |
| 240 | +{ |
| 241 | + if (!STR_IS_VALID (name) || !res_info) { |
| 242 | + g_return_val_if_reached (-EINVAL); |
| 243 | + } |
| 244 | + |
| 245 | + return 0; |
| 246 | +} |
0 commit comments