From a085c8f5680f26bccdd6b71aef606b264a289a05 Mon Sep 17 00:00:00 2001 From: songjc <969378911@qq.com> Date: Mon, 11 Sep 2023 08:57:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pcm/pcm.go | 24 ++++++++++++------------ api/storage/cache.go | 2 +- api/storage/storage_test.go | 2 +- models/job.go | 2 ++ utils/convertto/convertto.go | 26 ++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 utils/convertto/convertto.go diff --git a/api/pcm/pcm.go b/api/pcm/pcm.go index 3e9ed19..88bcda4 100644 --- a/api/pcm/pcm.go +++ b/api/pcm/pcm.go @@ -12,7 +12,7 @@ import ( const CORRECT_CODE int = 200 type UploadImageReq struct { - NodeID int64 `json:"nodeID"` + SlwNodeID int64 `json:"slwNodeID"` ImagePath string `json:"imagePath"` } @@ -52,7 +52,7 @@ func (c *Client) UploadImage(req UploadImageReq) (*UploadImageResp, error) { } type GetImageListReq struct { - NodeID int64 `json:"nodeID"` + SlwNodeID int64 `json:"slwNodeID"` } type GetImageListResp struct { @@ -90,8 +90,8 @@ func (c *Client) GetImageList(req GetImageListReq) (*GetImageListResp, error) { } type DeleteImageReq struct { - NodeID int64 `json:"nodeID"` - PCMJobID int64 `json:"pcmJobID"` + SlwNodeID int64 `json:"slwNodeID"` + PCMJobID int64 `json:"pcmJobID"` } type DeleteImageResp struct { @@ -129,10 +129,10 @@ func (c *Client) DeleteImage(req DeleteImageReq) (*DeleteImageResp, error) { } type ScheduleTaskReq struct { - NodeID int64 `json:"nodeID"` - Envs []map[string]string `json:"envs"` - ImageID int64 `json:"imageID"` - CMDLine string `json:"cmdLine"` + SlwNodeID int64 `json:"slwNodeID"` + Envs []map[string]string `json:"envs"` + ImageID int64 `json:"imageID"` + CMDLine string `json:"cmdLine"` } type ScheduleTaskResp struct { @@ -171,8 +171,8 @@ func (c *Client) ScheduleTask(req ScheduleTaskReq) (*ScheduleTaskResp, error) { } type GetTaskStatusReq struct { - NodeID int64 `json:"nodeID"` - PCMJobID int64 `json:"pcmJobID"` + SlwNodeID int64 `json:"slwNodeID"` + PCMJobID int64 `json:"pcmJobID"` } type GetTaskStatusResp struct { @@ -211,8 +211,8 @@ func (c *Client) GetTaskStatus(req GetTaskStatusReq) (*GetTaskStatusResp, error) } type DeleteTaskReq struct { - NodeID int64 `json:"nodeID"` - PCMJobID int64 `json:"pcmJobID"` + SlwNodeID int64 `json:"slwNodeID"` + PCMJobID int64 `json:"pcmJobID"` } type DeleteTaskResp struct { diff --git a/api/storage/cache.go b/api/storage/cache.go index 8ee9ac2..3f8339d 100644 --- a/api/storage/cache.go +++ b/api/storage/cache.go @@ -13,7 +13,7 @@ import ( type CacheMovePackageReq struct { UserID int64 `json:"userID"` PackageID int64 `json:"packageID"` - NodeID int64 `json:"nodeID"` + StgNodeID int64 `json:"stgNodeID"` } func (c *Client) CacheMovePackage(req CacheMovePackageReq) error { diff --git a/api/storage/storage_test.go b/api/storage/storage_test.go index 53c352f..e3e3395 100644 --- a/api/storage/storage_test.go +++ b/api/storage/storage_test.go @@ -145,7 +145,7 @@ func Test_Cache(t *testing.T) { err = cli.CacheMovePackage(CacheMovePackageReq{ UserID: 0, PackageID: upResp.PackageID, - NodeID: 1, + StgNodeID: 1, }) So(err, ShouldBeNil) diff --git a/models/job.go b/models/job.go index 94c0ca2..d796491 100644 --- a/models/job.go +++ b/models/job.go @@ -88,6 +88,8 @@ type EnvVar struct { Value string `json:"value"` } +// CPU、GPU、NPU、MLU单位为:核 +// Storage、Memory单位为:字节 type JobResourcesInfo struct { CPU float64 `json:"cpu"` GPU float64 `json:"gpu"` diff --git a/utils/convertto/convertto.go b/utils/convertto/convertto.go new file mode 100644 index 0000000..b779647 --- /dev/null +++ b/utils/convertto/convertto.go @@ -0,0 +1,26 @@ +package convertto + +import ( + "github.com/inhies/go-bytesize" +) + +func GBToBytes(gb float64) int64 { + // 将 float64 转换为 bytesize.ByteSize 类型 + size := bytesize.GB * bytesize.ByteSize(gb) + + // 获取字节数 + bytes := int64(size) + + return bytes +} + +func BytesToGB(bytes int64) float64 { + // 将字节数转换成 ByteSize 类型 + size := bytesize.B * bytesize.ByteSize(bytes) + + // 获取 GB 值 + gb := float64(size) + + return gb + +} From 1ddc62308ced247c4f051867eac549d72bd33a9b Mon Sep 17 00:00:00 2001 From: songjc <969378911@qq.com> Date: Tue, 12 Sep 2023 15:35:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/storage/cache.go | 2 +- api/storage/storage_test.go | 2 +- utils/convertto/convertto.go | 26 -------------------------- 3 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 utils/convertto/convertto.go diff --git a/api/storage/cache.go b/api/storage/cache.go index 3f8339d..8ee9ac2 100644 --- a/api/storage/cache.go +++ b/api/storage/cache.go @@ -13,7 +13,7 @@ import ( type CacheMovePackageReq struct { UserID int64 `json:"userID"` PackageID int64 `json:"packageID"` - StgNodeID int64 `json:"stgNodeID"` + NodeID int64 `json:"nodeID"` } func (c *Client) CacheMovePackage(req CacheMovePackageReq) error { diff --git a/api/storage/storage_test.go b/api/storage/storage_test.go index 04e4e91..910a0d8 100644 --- a/api/storage/storage_test.go +++ b/api/storage/storage_test.go @@ -147,7 +147,7 @@ func Test_Cache(t *testing.T) { err = cli.CacheMovePackage(CacheMovePackageReq{ UserID: 0, PackageID: upResp.PackageID, - StgNodeID: 1, + NodeID: 1, }) So(err, ShouldBeNil) diff --git a/utils/convertto/convertto.go b/utils/convertto/convertto.go deleted file mode 100644 index b779647..0000000 --- a/utils/convertto/convertto.go +++ /dev/null @@ -1,26 +0,0 @@ -package convertto - -import ( - "github.com/inhies/go-bytesize" -) - -func GBToBytes(gb float64) int64 { - // 将 float64 转换为 bytesize.ByteSize 类型 - size := bytesize.GB * bytesize.ByteSize(gb) - - // 获取字节数 - bytes := int64(size) - - return bytes -} - -func BytesToGB(bytes int64) float64 { - // 将字节数转换成 ByteSize 类型 - size := bytesize.B * bytesize.ByteSize(bytes) - - // 获取 GB 值 - gb := float64(size) - - return gb - -}