From: SANDEEP KUMAR JAISAWAL Date: Fri, 8 Dec 2023 08:58:10 +0000 (+0530) Subject: Returning a fixed model.zip and review comments X-Git-Tag: 1.0.0~3 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=27f91b978bbddb0f427942a973ceb0500efa1465;p=aiml-fw%2Fawmf%2Fmodelmgmtservice.git Returning a fixed model.zip and review comments Issue-Id: AIMLFW-64 Change-Id: I1805ac7193594f79f44d24e3077d418bcc118c56 Signed-off-by: SANDEEP KUMAR JAISAWAL --- diff --git a/apis/mmes_apis.go b/apis/mmes_apis.go index 9b20521..545c3f6 100644 --- a/apis/mmes_apis.go +++ b/apis/mmes_apis.go @@ -46,7 +46,7 @@ func init() { router.GET("/getModelInfo/:modelName", GetModelInfoByName) router.MaxMultipartMemory = 8 << 20 //8 Mb router.POST("/uploadModel/:modelName", UploadModel) - router.GET("/downloadModel/:modelName", DownloadModel) + router.GET("/downloadModel/:modelName/model.zip", DownloadModel) router.Run(os.Getenv("MMES_URL")) logging.INFO("Started api server...") } @@ -76,7 +76,7 @@ func RegisterModel(cont *gin.Context) { s3_manager := core.GetS3ManagerInstance() s3Err := s3_manager.CreateBucket(modelInfo.ModelName) if s3Err == nil { - s3_manager.UploadFile(modelInfoBytes, modelInfo.ModelName+os.Getenv("INFO_FILE_PREFIX"), modelInfo.ModelName) + s3_manager.UploadFile(modelInfoBytes, modelInfo.ModelName+os.Getenv("INFO_FILE_POSTFIX"), modelInfo.ModelName) } else { returnCode = http.StatusInternalServerError responseMsg = s3Err.Error() @@ -104,7 +104,8 @@ func GetModelInfo(cont *gin.Context) { logging.INFO("The request model name: ", model_name) s3_manager := core.GetS3ManagerInstance() - model_info := s3_manager.GetBucketObject(model_name+os.Getenv("INFO_FILE_PREFIX"), model_name) + + model_info := s3_manager.GetBucketObject(model_name+os.Getenv("INFO_FILE_POSTFIX"), model_name) cont.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, @@ -120,7 +121,7 @@ func GetModelInfoByName(cont *gin.Context) { modelName := cont.Param("modelName") s3_manager := core.GetS3ManagerInstance() - model_info := s3_manager.GetBucketObject(modelName+os.Getenv("INFO_FILE_PREFIX"), modelName) + model_info := s3_manager.GetBucketObject(modelName+os.Getenv("INFO_FILE_POSTFIX"), modelName) cont.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, @@ -144,7 +145,7 @@ func UploadModel(cont *gin.Context) { logging.INFO("Uploading model : ", modelName) s3_manager := core.GetS3ManagerInstance() - s3_manager.UploadFile(byteFile, modelName+os.Getenv("MODEL_FILE_PREFIX"), modelName) + s3_manager.UploadFile(byteFile, modelName+os.Getenv("MODEL_FILE_POSTFIX"), modelName) cont.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, "message": string("Model uploaded successfully.."), @@ -158,13 +159,13 @@ Input: model name in path params as "modelName" func DownloadModel(cont *gin.Context) { logging.INFO("Download model API ...") modelName := cont.Param("modelName") - fileName := modelName + os.Getenv("MODEL_FILE_PREFIX") + fileName := modelName + os.Getenv("MODEL_FILE_POSTFIX") s3_manager := core.GetS3ManagerInstance() fileByes := s3_manager.GetBucketObject(fileName, modelName) //Return file in api reponse using byte slice cont.Header("Content-Disposition", "attachment;"+fileName) - cont.Header("Content-Type", "application/octet-stream") + cont.Header("Content-Type", "application/zip") cont.Data(http.StatusOK, "application/octet", fileByes) } diff --git a/config.env b/config.env index a825749..43df30b 100644 --- a/config.env +++ b/config.env @@ -1,8 +1,8 @@ -MMES_URL=localhost:8082 +MMES_URL=0.0.0.0:8083 S3_URL=http://localhost:32080 S3_ACCESS_KEY= S3_SECRET_KEY= S3_REGION= -MODEL_FILE_PREFIX=_model.zip -INFO_FILE_PREFIX=_info.json +MODEL_FILE_POSTFIX=_model.zip +INFO_FILE_POSTFIX=_info.json LOG_FILE_NAME=mmes.log