Skip to content

Commit

Permalink
[Android] include database
Browse files Browse the repository at this point in the history
Separate node info for pipeline, and include mlops database based on sqlite to build android library.

Signed-off-by: Jaeyun Jung <[email protected]>
  • Loading branch information
jaeyun-jung committed Jan 21, 2025
1 parent dd9e8b1 commit 4dc3c0c
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 216 deletions.
7 changes: 4 additions & 3 deletions daemon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "gdbus-util.h"
#include "log.h"
#include "dbus-interface.h"
#include "service-db-util.h"
#include "mlops-agent-internal.h"

static GMainLoop *g_mainloop = NULL;
static gboolean verbose = FALSE;
Expand Down Expand Up @@ -112,7 +112,8 @@ main (int argc, char **argv)
/* path to database */
if (!db_path)
db_path = g_strdup (DB_PATH);
svcdb_initialize (db_path);

ml_agent_initialize (db_path);

g_mainloop = g_main_loop_new (NULL, FALSE);
gdbus_get_system_connection (is_session);
Expand All @@ -129,7 +130,7 @@ main (int argc, char **argv)
g_mainloop = NULL;

error:
svcdb_finalize ();
ml_agent_finalize ();

is_session = verbose = FALSE;
g_free (db_path);
Expand Down
1 change: 1 addition & 0 deletions daemon/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Machine Learning Agent
ml_agent_incs = include_directories('.', 'include')
ml_agent_lib_srcs = files('modules.c', 'gdbus-util.c', 'mlops-agent-interface.c',
'mlops-agent-internal.c', 'mlops-agent-node.c',
'pipeline-dbus-impl.cc', 'model-dbus-impl.cc', 'resource-dbus-impl.cc', 'service-db.cc')

ml_agent_deps = [
Expand Down
40 changes: 22 additions & 18 deletions daemon/mlops-agent-android.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "log.h"
#include "mlops-agent-interface.h"
#include "mlops-agent-internal.h"
#include "mlops-agent-node.h"
#include "service-db-util.h"

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

return 0;
return svcdb_pipeline_set (name, pipeline_desc);
}

/**
Expand All @@ -39,7 +41,7 @@ ml_agent_pipeline_get_description (const char *name, char **pipeline_desc)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_pipeline_get (name, pipeline_desc);
}

/**
Expand All @@ -52,7 +54,7 @@ ml_agent_pipeline_delete (const char *name)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_pipeline_delete (name);
}

/**
Expand All @@ -65,7 +67,7 @@ ml_agent_pipeline_launch (const char *name, int64_t * id)
g_return_val_if_reached (-EINVAL);
}

return 0;
return mlops_node_create (name, MLOPS_NODE_TYPE_PIPELINE, id);
}

/**
Expand All @@ -74,7 +76,7 @@ ml_agent_pipeline_launch (const char *name, int64_t * id)
int
ml_agent_pipeline_start (const int64_t id)
{
return 0;
return mlops_node_start (id);
}

/**
Expand All @@ -83,7 +85,7 @@ ml_agent_pipeline_start (const int64_t id)
int
ml_agent_pipeline_stop (const int64_t id)
{
return 0;
return mlops_node_stop (id);
}

/**
Expand All @@ -92,7 +94,7 @@ ml_agent_pipeline_stop (const int64_t id)
int
ml_agent_pipeline_destroy (const int64_t id)
{
return 0;
return mlops_node_destroy (id);
}

/**
Expand All @@ -101,7 +103,7 @@ ml_agent_pipeline_destroy (const int64_t id)
int
ml_agent_pipeline_get_state (const int64_t id, int *state)
{
return 0;
return mlops_node_get_state (id, (GstState *) state);
}

/**
Expand All @@ -115,7 +117,8 @@ ml_agent_model_register (const char *name, const char *path,
if (!STR_IS_VALID (name) || !STR_IS_VALID (path) || !version) {
g_return_val_if_reached (-EINVAL);
}
return 0;

return svcdb_model_add (name, path, activate, description, app_info, version);
}

/**
Expand All @@ -128,7 +131,8 @@ ml_agent_model_update_description (const char *name,
if (!STR_IS_VALID (name) || !STR_IS_VALID (description) || version == 0U) {
g_return_val_if_reached (-EINVAL);
}
return 0;

return svcdb_model_update_description (name, version, description);
}

/**
Expand All @@ -141,7 +145,7 @@ ml_agent_model_activate (const char *name, const uint32_t version)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_model_activate (name, version);
}

/**
Expand All @@ -154,7 +158,7 @@ ml_agent_model_get (const char *name, const uint32_t version, char **model_info)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_model_get (name, version, model_info);
}

/**
Expand All @@ -167,7 +171,7 @@ ml_agent_model_get_activated (const char *name, char **model_info)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_model_get_activated (name, model_info);
}

/**
Expand All @@ -180,7 +184,7 @@ ml_agent_model_get_all (const char *name, char **model_info)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_model_get_all (name, model_info);
}

/**
Expand All @@ -195,7 +199,7 @@ ml_agent_model_delete (const char *name, const uint32_t version,
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_model_delete (name, version, force);
}

/**
Expand All @@ -209,7 +213,7 @@ ml_agent_resource_add (const char *name, const char *path,
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_resource_add (name, path, description, app_info);
}

/**
Expand All @@ -222,7 +226,7 @@ ml_agent_resource_delete (const char *name)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_resource_delete (name);
}

/**
Expand All @@ -235,5 +239,5 @@ ml_agent_resource_get (const char *name, char **res_info)
g_return_val_if_reached (-EINVAL);
}

return 0;
return svcdb_resource_get (name, res_info);
}
5 changes: 3 additions & 2 deletions daemon/mlops-agent-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ml_agent_pipeline_set_description (const char *name, const char *pipeline_desc)
{
MachinelearningServicePipeline *mlsp;
gboolean result;
gint ret;

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

result = machinelearning_service_pipeline_call_set_pipeline_sync (mlsp,
name, pipeline_desc, NULL, NULL, NULL);
name, pipeline_desc, &ret, NULL, NULL);
g_object_unref (mlsp);

g_return_val_if_fail (result, -EIO);
g_return_val_if_fail (ret == 0 && result, ret);
return 0;
}

Expand Down
35 changes: 35 additions & 0 deletions daemon/mlops-agent-internal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: Apache-2.0 */
/**
* @file mlops-agent-internal.c
* @date 20 January 2025
* @brief Internal function for ml-agent interface.
* @see https://github.com/nnstreamer/deviceMLOps.MLAgent
* @author Jaeyun Jung <[email protected]>
* @bug No known bugs except for NYI items
*/

#include "log.h"
#include "mlops-agent-internal.h"
#include "mlops-agent-node.h"
#include "service-db-util.h"

/**
* @brief Internal function to initialize mlops-agent interface.
*/
void
ml_agent_initialize (const char *db_path)
{
g_assert (STR_IS_VALID (db_path));
svcdb_initialize (db_path);
mlops_node_initialize ();
}

/**
* @brief Internal function to finalize mlops-agent interface.
*/
void
ml_agent_finalize (void)
{
mlops_node_finalize ();
svcdb_finalize ();
}
10 changes: 10 additions & 0 deletions daemon/mlops-agent-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ typedef enum
ML_AGENT_SERVICE_END
} ml_agent_service_type_e;

/**
* @brief Internal function to initialize mlops-agent interface.
*/
void ml_agent_initialize (const char *db_path);

/**
* @brief Internal function to finalize mlops-agent interface.
*/
void ml_agent_finalize (void);

#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
Loading

0 comments on commit 4dc3c0c

Please sign in to comment.