Skip to content

Commit 641d0dc

Browse files
committed
[Android] include database
Separate node info for pipeline, and include mlops database based on sqlite to build android library. Signed-off-by: Jaeyun Jung <[email protected]>
1 parent dd9e8b1 commit 641d0dc

11 files changed

+441
-216
lines changed

daemon/main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "gdbus-util.h"
2222
#include "log.h"
2323
#include "dbus-interface.h"
24-
#include "service-db-util.h"
24+
#include "mlops-agent-internal.h"
2525

2626
static GMainLoop *g_mainloop = NULL;
2727
static gboolean verbose = FALSE;
@@ -112,7 +112,8 @@ main (int argc, char **argv)
112112
/* path to database */
113113
if (!db_path)
114114
db_path = g_strdup (DB_PATH);
115-
svcdb_initialize (db_path);
115+
116+
ml_agent_initialize (db_path);
116117

117118
g_mainloop = g_main_loop_new (NULL, FALSE);
118119
gdbus_get_system_connection (is_session);
@@ -129,7 +130,7 @@ main (int argc, char **argv)
129130
g_mainloop = NULL;
130131

131132
error:
132-
svcdb_finalize ();
133+
ml_agent_finalize ();
133134

134135
is_session = verbose = FALSE;
135136
g_free (db_path);

daemon/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Machine Learning Agent
22
ml_agent_incs = include_directories('.', 'include')
33
ml_agent_lib_srcs = files('modules.c', 'gdbus-util.c', 'mlops-agent-interface.c',
4+
'mlops-agent-internal.c', 'mlops-agent-node.c',
45
'pipeline-dbus-impl.cc', 'model-dbus-impl.cc', 'resource-dbus-impl.cc', 'service-db.cc')
56

67
ml_agent_deps = [

daemon/mlops-agent-android.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "log.h"
1616
#include "mlops-agent-interface.h"
1717
#include "mlops-agent-internal.h"
18+
#include "mlops-agent-node.h"
19+
#include "service-db-util.h"
1820

1921
/**
2022
* @brief An interface exported for setting the description of a pipeline.
@@ -26,7 +28,7 @@ ml_agent_pipeline_set_description (const char *name, const char *pipeline_desc)
2628
g_return_val_if_reached (-EINVAL);
2729
}
2830

29-
return 0;
31+
return svcdb_pipeline_set (name, pipeline_desc);
3032
}
3133

3234
/**
@@ -39,7 +41,7 @@ ml_agent_pipeline_get_description (const char *name, char **pipeline_desc)
3941
g_return_val_if_reached (-EINVAL);
4042
}
4143

42-
return 0;
44+
return svcdb_pipeline_get (name, pipeline_desc);
4345
}
4446

4547
/**
@@ -52,7 +54,7 @@ ml_agent_pipeline_delete (const char *name)
5254
g_return_val_if_reached (-EINVAL);
5355
}
5456

55-
return 0;
57+
return svcdb_pipeline_delete (name);
5658
}
5759

5860
/**
@@ -65,7 +67,7 @@ ml_agent_pipeline_launch (const char *name, int64_t * id)
6567
g_return_val_if_reached (-EINVAL);
6668
}
6769

68-
return 0;
70+
return mlops_node_create (name, MLOPS_NODE_TYPE_PIPELINE, id);
6971
}
7072

7173
/**
@@ -74,7 +76,7 @@ ml_agent_pipeline_launch (const char *name, int64_t * id)
7476
int
7577
ml_agent_pipeline_start (const int64_t id)
7678
{
77-
return 0;
79+
return mlops_node_start (id);
7880
}
7981

8082
/**
@@ -83,7 +85,7 @@ ml_agent_pipeline_start (const int64_t id)
8385
int
8486
ml_agent_pipeline_stop (const int64_t id)
8587
{
86-
return 0;
88+
return mlops_node_stop (id);
8789
}
8890

8991
/**
@@ -92,7 +94,7 @@ ml_agent_pipeline_stop (const int64_t id)
9294
int
9395
ml_agent_pipeline_destroy (const int64_t id)
9496
{
95-
return 0;
97+
return mlops_node_destroy (id);
9698
}
9799

98100
/**
@@ -101,7 +103,7 @@ ml_agent_pipeline_destroy (const int64_t id)
101103
int
102104
ml_agent_pipeline_get_state (const int64_t id, int *state)
103105
{
104-
return 0;
106+
return mlops_node_get_state (id, (GstState *) state);
105107
}
106108

107109
/**
@@ -115,7 +117,8 @@ ml_agent_model_register (const char *name, const char *path,
115117
if (!STR_IS_VALID (name) || !STR_IS_VALID (path) || !version) {
116118
g_return_val_if_reached (-EINVAL);
117119
}
118-
return 0;
120+
121+
return svcdb_model_add (name, path, activate, description, app_info, version);
119122
}
120123

121124
/**
@@ -128,7 +131,8 @@ ml_agent_model_update_description (const char *name,
128131
if (!STR_IS_VALID (name) || !STR_IS_VALID (description) || version == 0U) {
129132
g_return_val_if_reached (-EINVAL);
130133
}
131-
return 0;
134+
135+
return svcdb_model_update_description (name, version, description);
132136
}
133137

134138
/**
@@ -141,7 +145,7 @@ ml_agent_model_activate (const char *name, const uint32_t version)
141145
g_return_val_if_reached (-EINVAL);
142146
}
143147

144-
return 0;
148+
return svcdb_model_activate (name, version);
145149
}
146150

147151
/**
@@ -154,7 +158,7 @@ ml_agent_model_get (const char *name, const uint32_t version, char **model_info)
154158
g_return_val_if_reached (-EINVAL);
155159
}
156160

157-
return 0;
161+
return svcdb_model_get (name, version, model_info);
158162
}
159163

160164
/**
@@ -167,7 +171,7 @@ ml_agent_model_get_activated (const char *name, char **model_info)
167171
g_return_val_if_reached (-EINVAL);
168172
}
169173

170-
return 0;
174+
return svcdb_model_get_activated (name, model_info);
171175
}
172176

173177
/**
@@ -180,7 +184,7 @@ ml_agent_model_get_all (const char *name, char **model_info)
180184
g_return_val_if_reached (-EINVAL);
181185
}
182186

183-
return 0;
187+
return svcdb_model_get_all (name, model_info);
184188
}
185189

186190
/**
@@ -195,7 +199,7 @@ ml_agent_model_delete (const char *name, const uint32_t version,
195199
g_return_val_if_reached (-EINVAL);
196200
}
197201

198-
return 0;
202+
return svcdb_model_delete (name, version, force);
199203
}
200204

201205
/**
@@ -209,7 +213,7 @@ ml_agent_resource_add (const char *name, const char *path,
209213
g_return_val_if_reached (-EINVAL);
210214
}
211215

212-
return 0;
216+
return svcdb_resource_add (name, path, description, app_info);
213217
}
214218

215219
/**
@@ -222,7 +226,7 @@ ml_agent_resource_delete (const char *name)
222226
g_return_val_if_reached (-EINVAL);
223227
}
224228

225-
return 0;
229+
return svcdb_resource_delete (name);
226230
}
227231

228232
/**
@@ -235,5 +239,5 @@ ml_agent_resource_get (const char *name, char **res_info)
235239
g_return_val_if_reached (-EINVAL);
236240
}
237241

238-
return 0;
242+
return svcdb_resource_get (name, res_info);
239243
}

daemon/mlops-agent-interface.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ ml_agent_pipeline_set_description (const char *name, const char *pipeline_desc)
202202
{
203203
MachinelearningServicePipeline *mlsp;
204204
gboolean result;
205+
gint ret;
205206

206207
if (!STR_IS_VALID (name) || !STR_IS_VALID (pipeline_desc)) {
207208
g_return_val_if_reached (-EINVAL);
@@ -213,10 +214,10 @@ ml_agent_pipeline_set_description (const char *name, const char *pipeline_desc)
213214
}
214215

215216
result = machinelearning_service_pipeline_call_set_pipeline_sync (mlsp,
216-
name, pipeline_desc, NULL, NULL, NULL);
217+
name, pipeline_desc, &ret, NULL, NULL);
217218
g_object_unref (mlsp);
218219

219-
g_return_val_if_fail (result, -EIO);
220+
g_return_val_if_fail (ret == 0 && result, ret);
220221
return 0;
221222
}
222223

daemon/mlops-agent-internal.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
/**
3+
* @file mlops-agent-internal.c
4+
* @date 20 January 2025
5+
* @brief Internal function for ml-agent interface.
6+
* @see https://github.com/nnstreamer/deviceMLOps.MLAgent
7+
* @author Jaeyun Jung <[email protected]>
8+
* @bug No known bugs except for NYI items
9+
*/
10+
11+
#include "log.h"
12+
#include "mlops-agent-internal.h"
13+
#include "mlops-agent-node.h"
14+
#include "service-db-util.h"
15+
16+
/**
17+
* @brief Internal function to initialize mlops-agent interface.
18+
*/
19+
void
20+
ml_agent_initialize (const char *db_path)
21+
{
22+
svcdb_initialize (db_path);
23+
mlops_node_initialize ();
24+
}
25+
26+
/**
27+
* @brief Internal function to finalize mlops-agent interface.
28+
*/
29+
void
30+
ml_agent_finalize (void)
31+
{
32+
mlops_node_finalize ();
33+
svcdb_finalize ();
34+
}

daemon/mlops-agent-internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ typedef enum
2929
ML_AGENT_SERVICE_END
3030
} ml_agent_service_type_e;
3131

32+
/**
33+
* @brief Internal function to initialize mlops-agent interface.
34+
*/
35+
void ml_agent_initialize (const char *db_path);
36+
37+
/**
38+
* @brief Internal function to finalize mlops-agent interface.
39+
*/
40+
void ml_agent_finalize (void);
41+
3242
#ifdef __cplusplus
3343
}
3444
#endif /* __cplusplus */

0 commit comments

Comments
 (0)