Refactor models to separate folder.
Change-Id: I5d3611b2293989589d9513449727409d2e07872a
Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
"gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/core"
"gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/logging"
+ "gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/models"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
-type Metadata struct {
- Author string `json:"author"`
-}
-
-type ModelSpec struct {
- Metadata Metadata `json:"metadata"`
-}
-type ModelID struct {
- ModelName string `json:"modelName"`
- modelVersion string `json:"modelVersion"`
-}
-
-type ModelInfo struct {
- Id string `json:"id"`
- ModelId ModelID `json:"model-id,omitempty"`
- Description string `json:"description"`
- ModelSpec ModelSpec `json:"meta-info"`
-}
-
-
-type ModelInfoResponse struct {
- Name string `json:"name"`
- Data string `json:"data"`
-}
-
type MmeApiHandler struct {
dbmgr core.DBMgr
}
logging.INFO("Creating model...")
bodyBytes, _ := io.ReadAll(cont.Request.Body)
- var modelInfo ModelInfo
+ var modelInfo models.ModelInfo
//Need to unmarshal JSON to Struct, to access request
//data such as model name, rapp id etc
err := json.Unmarshal(bodyBytes, &modelInfo)
return
}
- modelInfoListResp := []ModelInfoResponse{}
+ modelInfoListResp := []models.ModelInfoResponse{}
for _, bucket := range bucketList {
- modelInfoListResp = append(modelInfoListResp, ModelInfoResponse{
+ modelInfoListResp = append(modelInfoListResp, models.ModelInfoResponse{
Name: bucket.Name,
Data: string(bucket.Object),
})
modelName := cont.Param("modelName")
bucketObj := m.dbmgr.GetBucketObject(modelName+os.Getenv("INFO_FILE_POSTFIX"), modelName)
- modelInfoListResp := ModelInfoResponse{
+ modelInfoListResp := models.ModelInfoResponse{
Name: modelName,
Data: string(bucketObj),
}
"gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/apis"
"gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/core"
+ "gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/models"
"gerrit.o-ran-sc.org/r/aiml-fw/awmf/modelmgmtservice/routers"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
var registerModelBody = `{
"id" : "id",
- "model-id": {
+ "modelId": {
"modelName": "test-model",
"modelVersion":"1"
},
"description": "testing",
- "meta-info": {
+ "metaInfo": {
"metadata": {
"author":"tester"
}
body, _ := io.ReadAll(response.Body)
var modelInfoListResp struct {
- Code int `json:"code"`
- Message []apis.ModelInfoResponse `json:"message"`
+ Code int `json:"code"`
+ Message []models.ModelInfoResponse `json:"message"`
}
json.Unmarshal(body, &modelInfoListResp)
body, _ := io.ReadAll(response.Body)
var modelInfoListResp struct {
- Code int `json:"code"`
- Message []apis.ModelInfoResponse `json:"message"`
+ Code int `json:"code"`
+ Message []models.ModelInfoResponse `json:"message"`
}
json.Unmarshal(body, &modelInfoListResp)
require (
github.com/aws/aws-sdk-go v1.47.3
github.com/gin-gonic/gin v1.9.1
+ github.com/google/uuid v1.6.0
github.com/stretchr/testify v1.8.3
)
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
- github.com/google/uuid v1.6.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
--- /dev/null
+/*
+==================================================================================
+Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================================
+*/
+
+package models
+
+type Metadata struct {
+ Author string `json:"author"`
+}
+
+type ModelSpec struct {
+ Metadata Metadata `json:"metadata"`
+}
+type ModelID struct {
+ ModelName string `json:"modelName"`
+ ModelVersion string `json:"modelVersion"`
+}
+
+type ModelInfo struct {
+ Id string `json:"id"`
+ ModelId ModelID `json:"modelId,omitempty"`
+ Description string `json:"description"`
+ ModelSpec ModelSpec `json:"metaInfo"`
+}
+
+type ModelInfoResponse struct {
+ Name string `json:"name"`
+ Data string `json:"data"`
+}