merge conflict

This commit is contained in:
Jake 2025-07-11 10:48:36 +08:00
commit dc7b5e20b8
55 changed files with 2956 additions and 581 deletions

View File

@ -46,6 +46,21 @@ func (f *Filter) Apply(specs Algorithms) Algorithms {
return false
}
// id
if f.id != "" {
if withId := spec.Features().WithId; withId != nil {
id, err := withId()
if err != nil {
return false
}
if id.Id != f.id {
return false
}
} else {
return false
}
}
return true
})
}

View File

@ -23,5 +23,5 @@ type TrainParameter interface {
}
type CreateParameter interface {
CreateParam()
AlgorithmCreateParam()
}

View File

@ -1,29 +1,61 @@
package algorithm
import "gitlink.org.cn/JointCloud/jcs/storagekit/types"
import (
"encoding/json"
"fmt"
"gitlink.org.cn/JointCloud/pcm-participant-ai/common"
)
type CreateParam struct {
Name string `json:"name" binding:"required"`
Desc string `json:"desc"`
Src *Source `json:"src,omitempty"`
Src *common.Source `json:"src,omitempty"`
Param CreateParameter `json:"param,omitempty"`
}
type OpenI struct {
BootFile string `json:"bootFile,omitempty"`
DefaultBranch string `json:"defaultBranch,omitempty"`
Repo1 string `json:"defaultBranch,omitempty"`
}
func (o OpenI) CreateParam() {
func (o OpenI) AlgorithmCreateParam() {
}
type Octopus struct {
}
func (o Octopus) CreateParam() {
func (o Octopus) AlgorithmCreateParam() {
}
type Source struct {
Jcs *types.JcsBase `json:"jcs,omitempty"`
func (cp *CreateParam) UnmarshalJSON(data []byte) error {
// 临时结构体:用于捕获原始 JSON 中的 param 字段数据
type TempCreateParam struct {
Name string `json:"name"`
Desc string `json:"desc"`
Src *common.Source `json:"src,omitempty"`
Param json.RawMessage `json:"param,omitempty"` // 捕获原始 JSON 数据
}
var temp TempCreateParam
if err := json.Unmarshal(data, &temp); err != nil {
return err
}
// 将临时结构体的字段赋值给原结构体(除 Param 外)
cp.Name = temp.Name
cp.Desc = temp.Desc
cp.Src = temp.Src
// 解析 param 字段的原始数据为具体类型
if temp.Param != nil {
// 尝试解析为 OpenI 类型
var openi OpenI
if err := json.Unmarshal(temp.Param, &openi); err == nil {
cp.Param = &openi
return nil
}
return fmt.Errorf("unsupported param type in CreateParam")
}
return nil
}

7
ai/common/types.go Normal file
View File

@ -0,0 +1,7 @@
package common
import "gitlink.org.cn/JointCloud/jcs/storagekit/types"
type Source struct {
Jcs *types.JcsBase `json:"jcs,omitempty"`
}

40
ai/config/config.go Normal file
View File

@ -0,0 +1,40 @@
package config
import (
"fmt"
"gopkg.in/yaml.v3"
"os"
)
var (
Cfg, _ = LoadConfig("../../ai/config/config.yaml")
)
const (
OpenI = "openi"
Octopus = "oct"
Modelarts = "mdlarts"
)
type PlatformConfig struct {
Name string `yaml:"name" json:"name"`
APIKey string `yaml:"api_key" json:"APIKey"`
URL string `yaml:"url" json:"URL"`
Username string `yaml:"username" json:"username"`
Password string `yaml:"password" json:"password"`
DataRepo string `yaml:"data_repo" json:"dataRepo"` //数据仓库名称
}
func LoadConfig(path string) (map[string]PlatformConfig, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
}
cfg := make(map[string]PlatformConfig, 0)
if err := yaml.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("failed to parse config file: %w", err)
}
return cfg, nil
}

18
ai/config/config.yaml Normal file
View File

@ -0,0 +1,18 @@
openi:
name: "OpenI"
api_key: ""
url: ""
username: ""
password: ""
data_repo: "data"
mdlarts:
name: "ModelArts"
api_key: ""
url: ""
oct:
name: "Octopus-189"
username: ""
password: ""
api_key: "1"
url: ""

View File

@ -12,10 +12,10 @@ type Features struct {
IsStoredRemote bool
HasRecommendation bool
Recommended func(ctx context.Context, search *Search) (Datasets, error)
Public func(ctx context.Context, search *Search) (Datasets, error)
Private func(ctx context.Context, search *Search) (Datasets, error)
Preset func(ctx context.Context, search *Search) (Datasets, error)
Recommended func(ctx context.Context) (Datasets, error)
Public func(ctx context.Context) (Datasets, error)
Private func(ctx context.Context) (Datasets, error)
Preset func(ctx context.Context) (Datasets, error)
}
type FeatureSpec struct {
@ -59,19 +59,19 @@ func (ft *FeatureSpec) Fill(ctx context.Context, spec ISpec) *FeatureSpec {
}
type Recommended interface {
Recommended(ctx context.Context, search *Search) (Datasets, error)
Recommended(ctx context.Context) (Datasets, error)
}
type Public interface {
Public(ctx context.Context, search *Search) (Datasets, error)
Public(ctx context.Context) (Datasets, error)
}
type Private interface {
Private(ctx context.Context, search *Search) (Datasets, error)
Private(ctx context.Context) (Datasets, error)
}
type Preset interface {
Preset(ctx context.Context, search *Search) (Datasets, error)
Preset(ctx context.Context) (Datasets, error)
}
// return id

View File

@ -35,15 +35,31 @@ func (f *Filter) Apply(specs Datasets) Datasets {
s, _ := spec.Spec()
if s == nil {
return false
}
// platform type
if s.Platform.Type == "" || (s.Platform.Type != f.pType && f.pType != "") {
return false
} else {
// platform type
if s.Platform.Type == "" || (s.Platform.Type != f.pType && f.pType != "") {
return false
}
// name
if s.Name == "" || (s.Name != f.name && f.name != "") {
return false
}
}
// name
if s.Name == "" || (s.Name != f.name && f.name != "") {
return false
// id
if f.id != "" {
if withId := spec.Features().WithId; withId != nil {
id, err := withId()
if err != nil {
return false
}
if id.Id != f.id {
return false
}
} else {
return false
}
}
return true

View File

@ -19,3 +19,7 @@ type ISpec interface {
type TrainParameter interface {
DatasetParam()
}
type CreateParameter interface {
DatasetCreateParam()
}

View File

@ -1,15 +1,22 @@
package dataset
import "gitlink.org.cn/JointCloud/jcs/storagekit/types"
import (
"gitlink.org.cn/JointCloud/pcm-participant-ai/common"
)
type Search struct {
}
type CreateParam struct {
Name string `json:"name" binding:"required"`
Src *Source `json:"src,omitempty"`
Name string `json:"name" binding:"required"`
Desc string `json:"desc"`
Src *common.Source `json:"src,omitempty"`
Param CreateParameter `json:"param,omitempty"`
}
type Source struct {
Jcs *types.JcsBase `json:"jcs,omitempty"`
type OpenI struct {
Repo string `json:"repo,omitempty"`
}
func (o OpenI) DatasetCreateParam() {
}

View File

@ -46,6 +46,22 @@ func (f *Filter) Apply(specs Images) Images {
if s.Name == "" || (s.Name != f.name && f.name != "") {
return false
}
// id
if f.id != "" {
if withId := spec.Features().WithId; withId != nil {
id, err := withId()
if err != nil {
return false
}
if id.Id != f.id {
return false
}
} else {
return false
}
}
return true
})
}

View File

@ -5,7 +5,7 @@ import (
)
type Features struct {
GetResourceSpecs func(ctx context.Context) (*ResourceSpecs, error)
GetResourceSpecs func(ctx context.Context, resrcType string) (*ResourceSpecs, error)
}
type FeatureSpec struct {
@ -37,7 +37,7 @@ func (ft *FeatureSpec) Fill(ctx context.Context, spec ISpec) *FeatureSpec {
}
type IResourceSpecs interface {
GetResourceSpecs(ctx context.Context) (*ResourceSpecs, error)
GetResourceSpecs(ctx context.Context, resrcType string) (*ResourceSpecs, error)
}
// return id

View File

@ -85,6 +85,21 @@ func (f *Filter) Apply(specs Specs) Specs {
return false
}
// id
if f.id != "" {
if withId := spec.Features().WithId; withId != nil {
id, err := withId()
if err != nil {
return false
}
if id.Id != f.id {
return false
}
} else {
return false
}
}
return true
})
}

View File

@ -9,9 +9,12 @@ const (
)
type ResourceSpecs struct {
Region string `json:"region"`
Resources []interface{} `json:"resources"`
Msg string `json:"msg"`
ClusterId string `json:"clusterID"`
ClusterType string `json:"clusterType"`
Region string `json:"region"`
Tag string `json:"tag"`
Resources []interface{} `json:"resources"`
Msg string `json:"msg"`
}
type ClusterResource struct {

View File

@ -83,7 +83,12 @@ func (a *Algorithm) Create(ctx context.Context, param *algorithm.CreateParam) (i
}
func (a *Algorithm) TrainParam(ctx context.Context, param *AlgorithmParam) (algorithm.TrainParameter, error) {
if param == nil {
return nil, nil
}
filter := algorithm.NewFilter().
SetId(param.Id).
SetName(param.Name)
filtered, err := a.Train(ctx, filter)
@ -91,6 +96,10 @@ func (a *Algorithm) TrainParam(ctx context.Context, param *AlgorithmParam) (algo
return nil, err
}
if len(filtered) != 1 {
return nil, errs.Error_Not_Found_Algorithm
}
var (
chosen = filtered[0]
ftSpecNotFound = true
@ -107,6 +116,12 @@ func (a *Algorithm) TrainParam(ctx context.Context, param *AlgorithmParam) (algo
return nil, err
}
trainParam = version
} else {
id, err := withId()
if err != nil {
return nil, err
}
trainParam = id
}
} else {
id, err := withId()

View File

@ -6,6 +6,8 @@ import (
"github.com/smartystreets/goconvey/convey"
"gitlink.org.cn/JointCloud/jcs/storagekit/types"
"gitlink.org.cn/JointCloud/pcm-participant-ai/algorithm"
aicom "gitlink.org.cn/JointCloud/pcm-participant-ai/common"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
@ -14,11 +16,34 @@ import (
"time"
)
func TestOpenI(t *testing.T) {
convey.Convey("openI Test Algorithm Service", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
func TestGet(t *testing.T) {
convey.Convey(aiconf.Octopus, t, func() {
o, err := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
if err != nil {
fmt.Println(err)
return
}
alg := NewAlgorithm(o.Alg)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("Train", func() {
result, _ := alg.All(ctx, nil)
alg, err := result.Algorithms()
if err != nil {
fmt.Println(err.Error())
}
convey.So(err, convey.ShouldBeNil)
convey.So(alg, convey.ShouldNotBeEmpty)
})
})
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
alg := NewAlgorithm(o.Alg)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
@ -64,36 +89,51 @@ func TestOpenI(t *testing.T) {
func TestCreate(t *testing.T) {
convey.Convey("Create Algorithm", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
//o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
//common.InitClient()
common.InitClient()
alg := NewAlgorithm(o.Alg)
oct, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
alg := NewAlgorithm(oct.Alg)
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
var (
name = "test-123456"
desc = "test-123456"
name = "test123456"
desc = "test123456"
)
src := &algorithm.Source{
src := &aicom.Source{
Jcs: &types.JcsBase{
UserID: 1,
PackageId: 1089,
},
}
convey.Convey("OpenI", func() {
op := &algorithm.OpenI{
BootFile: "123.txt",
DefaultBranch: "master",
}
//convey.Convey("OpenI", func() {
// op := &algorithm.OpenI{
// BootFile: "123.txt",
// DefaultBranch: "master",
// }
// param := &algorithm.CreateParam{
// Name: name,
// Desc: desc,
// Src: src,
// Param: op,
// }
// _, err := alg.Create(ctx, param)
// if err != nil {
// fmt.Println(err.Error())
// }
// convey.So(err, convey.ShouldBeNil)
//})
convey.Convey("octopus", func() {
param := &algorithm.CreateParam{
Name: name,
Desc: desc,
Src: src,
Param: op,
Name: name,
Desc: desc,
Src: src,
}
_, err := alg.Create(ctx, param)
if err != nil {
@ -104,25 +144,3 @@ func TestCreate(t *testing.T) {
})
}
func TestOctopus(t *testing.T) {
convey.Convey("Octopus Test Algorithm Service", t, func() {
o, _ := octopus.New("https://120.220.95.189:50010", "c2net@pcl.ac.cn", "c2net123", platform.Id(456))
alg := NewAlgorithm(o.Alg)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("All", func() {
//f := algorithm.NewFilter().SetName("pytorch-cnn-cifar10-dcu")
result, err := alg.All(ctx, nil)
alg, err := result.Algorithms()
if err != nil {
fmt.Println(err.Error())
}
convey.So(err, convey.ShouldBeNil)
convey.So(alg, convey.ShouldNotBeEmpty)
})
})
}

View File

@ -68,8 +68,22 @@ func (d *Dataset) Infer(ctx context.Context, filter *dataset.Filter) (dataset.Da
return dat, nil
}
func (d *Dataset) Create(ctx context.Context, param *dataset.CreateParam) (interface{}, error) {
dat, err := d.dataset.Create(ctx, param)
if err != nil {
return nil, err
}
return dat, nil
}
func (d *Dataset) TrainParam(ctx context.Context, param *DatasetParam) (dataset.TrainParameter, error) {
if param == nil {
return nil, nil
}
filter := dataset.NewFilter().
SetId(param.Id).
SetName(param.Name)
filtered, err := d.Train(ctx, filter)
@ -77,6 +91,10 @@ func (d *Dataset) TrainParam(ctx context.Context, param *DatasetParam) (dataset.
return nil, err
}
if len(filtered) != 1 {
return nil, errs.Error_Not_Found_Dataset
}
var (
chosen = filtered[0]
ftSpecNotFound = true
@ -93,6 +111,12 @@ func (d *Dataset) TrainParam(ctx context.Context, param *DatasetParam) (dataset.
return nil, err
}
trainParam = version
} else {
id, err := withId()
if err != nil {
return nil, err
}
trainParam = id
}
} else {
id, err := withId()

View File

@ -4,8 +4,12 @@ import (
"context"
"fmt"
"github.com/smartystreets/goconvey/convey"
"gitlink.org.cn/JointCloud/jcs/storagekit/types"
aicom "gitlink.org.cn/JointCloud/pcm-participant-ai/common"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/dataset"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
"gitlink.org.cn/JointCloud/pcm-participant-openi/common"
"testing"
@ -13,18 +17,19 @@ import (
)
func TestDataset(t *testing.T) {
convey.Convey("openI Test Dataset Service", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
ds := NewDataset(o.Ds)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("All", func() {
f := dataset.NewFilter().SetName("cifar-10-batches-test-0314.zip")
result, _ := ds.All(ctx, f)
//f := dataset.NewFilter().SetName("cifar-10-batches-test-0314.zip")
//f := dataset.NewFilter().SetId("6b7ac8e8-9a57-4eaf-bc4d-daad3b42f5ad")
result, _ := ds.All(ctx, nil)
dss, err := result.Datasets()
if err != nil {
fmt.Println(err.Error())
@ -55,4 +60,84 @@ func TestDataset(t *testing.T) {
convey.So(dss, convey.ShouldNotBeNil)
})
})
convey.Convey(aiconf.Octopus, t, func() {
oct, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
ds := NewDataset(oct.Ds)
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
convey.Convey("All", func() {
//f := dataset.NewFilter().SetName("cifar-10-batches-test-0314.zip")
//f := dataset.NewFilter().SetId("6b7ac8e8-9a57-4eaf-bc4d-daad3b42f5ad")
result, _ := ds.All(ctx, nil)
dss, err := result.Datasets()
if err != nil {
fmt.Println(err.Error())
}
convey.So(err, convey.ShouldBeNil)
convey.So(dss, convey.ShouldHaveLength, 1)
})
})
}
func TestCreateDataset(t *testing.T) {
convey.Convey("Create Dataset", t, func() {
//o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
//common.InitClient()
oct, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
ds := NewDataset(oct.Ds)
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
var (
name = "test-123456"
desc = "test-123456"
)
src := &aicom.Source{
Jcs: &types.JcsBase{
UserID: 1,
PackageId: 1089,
},
}
//convey.Convey("OpenI", func() {
// op := &dataset.OpenI{
// Repo: "data",
// }
// param := &dataset.CreateParam{
// Name: name,
// Desc: desc,
// Src: src,
// Param: op,
// }
// _, err := ds.Create(ctx, param)
// if err != nil {
// fmt.Println(err.Error())
// }
// convey.So(err, convey.ShouldBeNil)
//})
convey.Convey("octopus", func() {
param := &dataset.CreateParam{
Name: name,
Desc: desc,
Src: src,
}
_, err := ds.Create(ctx, param)
if err != nil {
fmt.Println(err.Error())
}
convey.So(err, convey.ShouldBeNil)
})
})
}

View File

@ -72,7 +72,12 @@ func (img *Image) Infer(ctx context.Context, filter *image.Filter) (image.Images
}
func (img *Image) TrainParam(ctx context.Context, param *ImageParam) (image.TrainParameter, error) {
if param == nil {
return nil, nil
}
filter := image.NewFilter().
SetId(param.Id).
SetName(param.Name)
filtered, err := img.Train(ctx, filter)
@ -80,6 +85,10 @@ func (img *Image) TrainParam(ctx context.Context, param *ImageParam) (image.Trai
return nil, err
}
if len(filtered) != 1 {
return nil, errs.Error_Not_Found_Image
}
var (
chosen = filtered[0]
ftSpecNotFound = true
@ -96,6 +105,12 @@ func (img *Image) TrainParam(ctx context.Context, param *ImageParam) (image.Trai
return nil, err
}
trainParam = version
} else {
id, err := withId()
if err != nil {
return nil, err
}
trainParam = id
}
} else {
id, err := withId()

View File

@ -4,8 +4,10 @@ import (
"context"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/image"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
"gitlink.org.cn/JointCloud/pcm-participant-openi/common"
"testing"
@ -13,8 +15,8 @@ import (
)
func TestImage(t *testing.T) {
convey.Convey("openI Test Image Service", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
i := NewImage(o.Img)
@ -78,3 +80,25 @@ func TestImage(t *testing.T) {
})
})
}
func TestOctopusImage(t *testing.T) {
convey.Convey(aiconf.Octopus, t, func() {
o, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
i := NewImage(o.Img)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("Train", func() {
_ = image.NewFilter().SetName("ubuntu22.04-cuda11.8.0-py310-torch2.1.0-tf2.14.0")
result, err := i.Train(ctx, nil)
imgs, err := result.Images()
if err != nil {
fmt.Println(err.Error())
}
convey.So(err, convey.ShouldBeNil)
convey.So(imgs, convey.ShouldHaveLength, 4)
})
})
}

View File

@ -11,22 +11,22 @@ type CreateTrainTaskParam struct {
}
type ResourceParam struct {
Id string `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Card string `json:"card" form:"card"`
Id string `json:"id,omitempty" form:"id"`
Name string `json:"name,omitempty" form:"name"`
Card string `json:"card,omitempty" form:"card"`
}
type DatasetParam struct {
Id string `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Id string `json:"id,omitempty" form:"id"`
Name string `json:"name,omitempty" form:"name"`
}
type AlgorithmParam struct {
Id string `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Id string `json:"id,omitempty" form:"id"`
Name string `json:"name,omitempty" form:"name"`
}
type ImageParam struct {
Id string `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Id string `json:"id,omitempty" form:"id"`
Name string `json:"name,omitempty" form:"name"`
}

View File

@ -2,6 +2,7 @@ package service
import (
"context"
"errors"
"gitlink.org.cn/JointCloud/pcm-participant-ai/errs"
"gitlink.org.cn/JointCloud/pcm-participant-ai/resource"
)
@ -14,9 +15,9 @@ func NewResource(resource resource.IResource) *Resource {
return &Resource{resource: resource}
}
func (r *Resource) GetResourcespecs(ctx context.Context) (*resource.ResourceSpecs, error) {
func (r *Resource) GetResourcespecs(ctx context.Context, rtype string) (*resource.ResourceSpecs, error) {
if getResources := r.resource.Features().GetResourceSpecs; getResources != nil {
specs, err := getResources(ctx)
specs, err := getResources(ctx, rtype)
if err != nil {
return nil, err
}
@ -24,11 +25,7 @@ func (r *Resource) GetResourcespecs(ctx context.Context) (*resource.ResourceSpec
return specs, err
}
_, err := r.resource.Train(context.Background())
if err != nil {
return nil, err
}
return nil, nil
return nil, errors.New("not found resource specs implementation")
}
func (r *Resource) GetResources(ctx context.Context) ([]*resource.Spec, error) {
@ -60,7 +57,7 @@ func (r *Resource) All(ctx context.Context, filter *resource.Filter) (resource.S
if filter != nil {
filtered := filter.Apply(specs)
if len(filtered) == 0 {
return nil, errs.Error_Not_Found_Image
return nil, errs.Error_Not_Found_Resources
}
return filtered, nil
}
@ -78,7 +75,7 @@ func (r *Resource) Train(ctx context.Context, filter *resource.Filter) (resource
if filter != nil {
filtered := filter.Apply(specs)
if len(filtered) == 0 {
return nil, errs.Error_Not_Found_Image
return nil, errs.Error_Not_Found_Resources
}
return filtered, nil
}
@ -96,7 +93,7 @@ func (r *Resource) Infer(ctx context.Context, filter *resource.Filter) (resource
if filter != nil {
filtered := filter.Apply(specs)
if len(filtered) == 0 {
return nil, errs.Error_Not_Found_Image
return nil, errs.Error_Not_Found_Resources
}
return filtered, nil
}
@ -104,7 +101,12 @@ func (r *Resource) Infer(ctx context.Context, filter *resource.Filter) (resource
}
func (r *Resource) TrainParam(ctx context.Context, param *ResourceParam) (resource.TrainParameter, error) {
if param == nil {
return nil, nil
}
filter := resource.NewFilter().
SetId(param.Id).
SetName(param.Name)
filtered, err := r.Train(ctx, filter)
@ -112,6 +114,10 @@ func (r *Resource) TrainParam(ctx context.Context, param *ResourceParam) (resour
return nil, err
}
if len(filtered) != 1 {
return nil, errs.Error_Not_Found_Resources
}
var (
chosen = filtered[0]
ftSpecNotFound = true
@ -128,6 +134,12 @@ func (r *Resource) TrainParam(ctx context.Context, param *ResourceParam) (resour
return nil, err
}
trainParam = img
} else {
id, err := specWithId()
if err != nil {
return nil, err
}
trainParam = id
}
} else {
id, err := specWithId()

View File

@ -4,8 +4,10 @@ import (
"context"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-ai/resource"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
"gitlink.org.cn/JointCloud/pcm-participant-openi/common"
"testing"
@ -13,8 +15,8 @@ import (
)
func TestResource(t *testing.T) {
convey.Convey("Test Resource Service", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
res := NewResource(o.Res)
@ -92,3 +94,52 @@ func TestResource(t *testing.T) {
})
}
func TestGetResourceSpecs(t *testing.T) {
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
res := NewResource(o.Res)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("GetResourceSpecs", func() {
specs, err := res.GetResourcespecs(ctx, "Train")
if err != nil {
return
}
convey.So(err, convey.ShouldBeNil)
convey.So(specs.Resources, convey.ShouldHaveLength, 10)
})
})
convey.Convey(aiconf.Octopus, t, func() {
oct, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
res := NewResource(oct.Res)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
convey.Convey("Train", func() {
f := resource.NewFilter().SetId("964fdee2db544928bfea74dac12a924f")
specs, err := res.Train(ctx, f)
if err != nil {
return
}
convey.So(err, convey.ShouldBeNil)
convey.So(specs, convey.ShouldHaveLength, 1)
})
convey.Convey("GetResourceSpecs", func() {
specs, err := res.GetResourcespecs(ctx, "Train")
if err != nil {
return
}
convey.So(err, convey.ShouldBeNil)
convey.So(specs.Resources, convey.ShouldHaveLength, 6)
})
})
}

View File

@ -4,6 +4,7 @@ import (
"context"
"gitlink.org.cn/JointCloud/pcm-participant-ai/algorithm"
"gitlink.org.cn/JointCloud/pcm-participant-ai/common"
"gitlink.org.cn/JointCloud/pcm-participant-ai/dataset"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-ai/resource"
"gitlink.org.cn/JointCloud/pcm-participant-ai/task"
@ -61,16 +62,17 @@ func NewService(platforms ...platform.IPlatform) (*Service, error) {
return &Service{rmap: rmap, amap: amap, imap: imap}, nil
}
func (s *Service) GetResourceSpecs(ctx context.Context, pfId int64) {
func (s *Service) GetResourceSpecs(ctx context.Context, pfId int64, rtype string) (interface{}, error) {
var pid = platform.Id(pfId)
res, found := s.rmap[pid]
if !found {
}
_, err := res.GetResourcespecs(ctx)
specs, err := res.GetResourcespecs(ctx, rtype)
if err != nil {
return
return nil, err
}
return specs, nil
}
func (s *Service) TrainResources(ctx context.Context, pfId int64) ([]*resource.Spec, error) {
@ -195,3 +197,31 @@ func (s *Service) TestFuncRes(ctx context.Context, pfId int64) {
res.TrainParam(context.Background(), nil)
}
func (s *Service) CreateAlgorithm(ctx context.Context, pfId int64, param *algorithm.CreateParam) (interface{}, error) {
var pid = platform.Id(pfId)
alg, found := s.amap[pid]
if !found {
}
resp, err := alg.Create(ctx, param)
if err != nil {
return nil, err
}
return resp, nil
}
func (s *Service) CreateDataset(ctx context.Context, pfId int64, param *dataset.CreateParam) (interface{}, error) {
var pid = platform.Id(pfId)
ds, found := s.dmap[pid]
if !found {
}
resp, err := ds.Create(ctx, param)
if err != nil {
return nil, err
}
return resp, nil
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
json "github.com/json-iterator/go"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
@ -15,8 +16,8 @@ import (
func TestService(t *testing.T) {
convey.Convey("Test Service", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
oct, err := octopus.New("https://120.220.95.189:50010", "c2net@pcl.ac.cn", "c2net123", platform.Id(456))
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
oct, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
common.InitClient()

View File

@ -3,16 +3,18 @@ package service
import (
"context"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-ai/platform"
"gitlink.org.cn/JointCloud/pcm-participant-ai/task"
"gitlink.org.cn/JointCloud/pcm-participant-octopus"
openI "gitlink.org.cn/JointCloud/pcm-participant-openi"
"gitlink.org.cn/JointCloud/pcm-participant-openi/common"
"testing"
)
func TestTask(t *testing.T) {
convey.Convey("openI Test Task Train", t, func() {
o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
func TestOpenITask(t *testing.T) {
convey.Convey(aiconf.OpenI, t, func() {
o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
common.InitClient()
tps := &task.TrainParams{
@ -27,7 +29,7 @@ func TestTask(t *testing.T) {
res := NewResource(o.Res)
tsk := NewTask(o.Task)
convey.Convey("Train task", func() {
convey.Convey("Task", func() {
aParam, err := alg.TrainParam(ctx, &AlgorithmParam{Name: "pytorch-cnn-cifar10-dcu"})
convey.So(err, convey.ShouldBeNil)
convey.So(aParam, convey.ShouldNotBeNil)
@ -55,3 +57,43 @@ func TestTask(t *testing.T) {
})
}
func TestOctopusTask(t *testing.T) {
convey.Convey(aiconf.Octopus, t, func() {
o, _ := octopus.New(aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, platform.Id(123))
tps := &task.TrainParams{
TaskName: "testTask123",
Desc: "testTask123",
}
ctx := context.Background()
_ = NewAlgorithm(o.Alg)
_ = NewDataset(o.Ds)
img := NewImage(o.Img)
res := NewResource(o.Res)
tsk := NewTask(o.Task)
convey.Convey("Task", func() {
cmd := ""
iParam, err := img.TrainParam(ctx, &ImageParam{Id: "b0fc71a054ae416a92b65d1bc5426c20"})
convey.So(err, convey.ShouldBeNil)
convey.So(iParam, convey.ShouldNotBeNil)
tps.Image = iParam
rParam, err := res.TrainParam(ctx, &ResourceParam{Id: "964fdee2db544928bfea74dac12a924f"})
convey.So(err, convey.ShouldBeNil)
convey.So(rParam, convey.ShouldNotBeNil)
tps.Resource = rParam
tps.Algorithm = nil
tps.Dataset = nil
tps.Cmd = cmd
err = tsk.createTrainTask(ctx, tps)
convey.So(err, convey.ShouldBeNil)
})
})
}

View File

@ -8,13 +8,23 @@ type Task interface {
}
type Infer interface {
Infer(ctx context.Context, params *InferParams) (Result, error)
Infer(ctx context.Context, params *InferParams) (interface{}, error)
InferTask(ctx context.Context, taskId string) (interface{}, error)
Stop(ctx context.Context, id string) error
}
type Train interface {
Train(ctx context.Context, params *TrainParams) (Result, error)
Train(ctx context.Context, params *TrainParams) (interface{}, error)
TrainTask(ctx context.Context, taskId string) (interface{}, error)
TrainTaskLog(ctx context.Context, taskId string) (interface{}, error)
ResultToModel(ctx context.Context, param *ResultToModelParam) (interface{}, error)
ResultSync(ctx context.Context, param *ResultSyncParam) error
}
type Result interface {
Get(ctx context.Context, id string) error
type SyncParameter interface {
ResultSyncParam()
}
type ToModelParameter interface {
ResultToModelParam()
}

31
ai/task/option.go Normal file
View File

@ -0,0 +1,31 @@
package task
import "gitlink.org.cn/JointCloud/pcm-participant-ai/common"
type ResultSyncParam struct {
Name string `json:"name" binding:"required"`
Desc string `json:"desc"`
Src *common.Source `json:"src,omitempty"`
Param SyncParameter `json:"param,omitempty"`
}
type ResultToModelParam struct {
Name string `json:"name" binding:"required"`
Desc string `json:"desc"`
Src *common.Source `json:"src,omitempty"`
Param ToModelParameter `json:"param,omitempty"`
}
type OpenI struct {
Id string `json:"id" form:"id" binding:"required"`
RepoName string `json:"repoName" form:"repoName" binding:"required"`
ParentDir string `json:"parentDir" form:"parentDir"`
BootFile string `json:"bootFile,omitempty"`
DefaultBranch string `json:"defaultBranch,omitempty"`
}
func (o OpenI) ResultToModelParam() {
}
func (o OpenI) ResultSyncParam() {
}

View File

@ -10,6 +10,9 @@ import (
type TrainParams struct {
TaskName string
Desc string
Cmd string
Envs []string
Params []string
Resource resource.TrainParameter
Image image.TrainParameter
Dataset dataset.TrainParameter
@ -19,6 +22,9 @@ type TrainParams struct {
type InferParams struct {
TaskName string
Desc string
Cmd string
Envs []string
Params []string
Resource resource.TrainParameter
Image image.TrainParameter
Algorithm algorithm.TrainParameter

View File

@ -1,11 +1,15 @@
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"gitlink.org.cn/JointCloud/pcm-participant-ai/algorithm"
"gitlink.org.cn/JointCloud/pcm-participant-ai/service"
"gitlink.org.cn/JointCloud/pcm-participant-openi/model"
"net/http"
"strconv"
"strings"
"sync"
)
@ -52,15 +56,50 @@ func (a *aiApi) AllTrainAlgorithmsHandler(c *gin.Context) {
model.Response(c, http.StatusOK, "success", algorithms)
}
// GetResourceSpecsHandler 处理获取资源规格的请求
func (a *aiApi) GetResourceSpecsHandler(c *gin.Context) {
// CreateAlgorithmHandler 处理创建算法的请求
func (a *aiApi) CreateAlgorithmHandler(c *gin.Context) {
pfIdStr := c.Query("pfId")
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
if err != nil {
model.Response(c, http.StatusBadRequest, "invalid pfId", nil)
return
}
a.service.GetResourceSpecs(c, pfId)
var param algorithm.CreateParam
if err := c.ShouldBindJSON(&param); err != nil {
if ve, ok := err.(validator.ValidationErrors); ok {
var errorMsg []string
for _, e := range ve {
errorMsg = append(errorMsg, fmt.Sprintf("字段 %s 验证失败: %s", e.Field(), e.Tag()))
}
model.Response(c, http.StatusBadRequest, "请求体格式错误: "+strings.Join(errorMsg, "; "), nil)
} else {
model.Response(c, http.StatusBadRequest, "请求体解析失败: "+err.Error(), nil)
}
return
//model.Response(c, http.StatusBadRequest, "invalid request body", nil)
//return
}
resp, err := a.service.CreateAlgorithm(c.Request.Context(), pfId, &param)
if err != nil {
model.Response(c, http.StatusInternalServerError, "failed to create algorithm", nil)
return
}
model.Response(c, http.StatusOK, "success", resp)
}
// GetResourceSpecsHandler 处理获取资源规格的请求
func (a *aiApi) GetResourceSpecsHandler(c *gin.Context) {
pfIdStr := c.Query("pfId")
rtype := c.Query("rType")
pfId, err := strconv.ParseInt(pfIdStr, 10, 64)
if err != nil {
model.Response(c, http.StatusBadRequest, "invalid pfId", nil)
return
}
a.service.GetResourceSpecs(c, pfId, rtype)
model.Response(c, http.StatusOK, "success", nil)
}

View File

@ -11,6 +11,7 @@ func AIRoutes(server *gin.Engine) {
{
ai.GET("/algorithm/get", aiApi.TrainAlgorithmsHandler)
ai.GET("/algorithm/list", aiApi.AllTrainAlgorithmsHandler)
ai.POST("/algorithm/create", aiApi.CreateAlgorithmHandler)
// 资源相关路由
ai.GET("/resource/specs", aiApi.GetResourceSpecsHandler)

View File

@ -58,7 +58,7 @@ func (m *PooledJobManager) SubmitJob(ctx context.Context, job *hpc.SubmitRequest
jobDir = filepath.Join(baseDir, fmt.Sprintf("%s_%d_%d", jobName, time.Now().Unix(), rand.Intn(1000)))
case !strings.HasPrefix(jobDir, m.workDir):
// 确保目录在workDir下
jobDir = filepath.Join(baseDir, jobDir)
jobDir = filepath.Join(m.workDir, jobDir)
}
}

View File

@ -1,4 +1,4 @@
platforms:
name: "JCS"
api_key: ""
url: ""
url: "http://121.36.5.116:32010"

View File

@ -1,10 +1,6 @@
package common
const (
Ip = "https://120.220.95.189:50010"
User = "c2net@pcl.ac.cn"
Pwd = "c2net123"
IPADDR = "addr"
ACCESSTOKEN = "token"
Forward_Slash = "/"

View File

@ -0,0 +1,65 @@
package common
import (
"fmt"
"math/rand"
"reflect"
"strings"
)
const (
CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
TIMEFORMAT = "20060102150405"
)
func GetJSONTag(structObj interface{}, fieldName string) (string, error) {
// 获取结构体的反射类型
t := reflect.TypeOf(structObj)
// 确保传入的是结构体
if t.Kind() != reflect.Struct {
return "", fmt.Errorf("expected a struct, got %T", structObj)
}
// 查找字段
field, found := t.FieldByName(fieldName)
if !found {
return "", fmt.Errorf("field '%s' not found", fieldName)
}
// 获取 `json` 标签
jsonTag := field.Tag.Get("json")
if jsonTag == "" {
return field.Name, nil // 默认使用字段名(小写)
}
// 去掉可能的 `omitempty` 等选项
return strings.Split(jsonTag, ",")[0], nil
}
func RandomString(n int) string {
sb := strings.Builder{}
sb.Grow(n)
for i := 0; i < n; i++ {
sb.WriteByte(CHARSET[rand.Intn(len(CHARSET))])
}
return sb.String()
}
func ConcatMultipleSlices[T any](slices [][]T) []T {
var totalLen int
for _, s := range slices {
totalLen += len(s)
}
result := make([]T, totalLen)
var i int
for _, s := range slices {
i += copy(result[i:], s)
}
return result
}

View File

@ -1 +1,4 @@
module gitlink.org.cn/JointCloud/pcm-participant-octopus
module gitlink.org.cn/JointCloud/pcm-participant-octopus
go 1.22.0

View File

@ -21,6 +21,20 @@ type ResourceSpec struct {
Error interface{} `json:"error"`
}
type OctResourceSpecs struct {
MapResourceSpecIdList struct {
Debug struct {
ResourceSpecs []interface{} `json:"resourceSpecs"`
} `json:"debug"`
Deploy struct {
ResourceSpecs []interface{} `json:"resourceSpecs"`
} `json:"deploy"`
Train struct {
ResourceSpecs []interface{} `json:"resourceSpecs"`
} `json:"train"`
} `json:"mapResourceSpecIdList"`
}
type Spec struct {
Id string `json:"id"`
Name string `json:"name"`

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
@ -17,7 +18,7 @@ var (
func TestCreateAlgorithm(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -30,7 +31,7 @@ func TestCreateAlgorithm(t *testing.T) {
AlgorithmName: "testAlgorithm123",
ModelName: "testAlgorithm123",
}
alg, err := CreateMyAlgorithm(common.Ip, token,
alg, err := CreateMyAlgorithm(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -57,10 +58,10 @@ func TestCreateAlgorithm(t *testing.T) {
param := &model.UploadMyAlgorithmParam{
AlgorithmId: algorithmId,
Version: algorithmversion,
Domain: common.Ip,
Domain: aiconf.Cfg[aiconf.OpenI].URL,
FileName: algorithmfilename,
}
alg, err := UploadMyAlgorithm(common.Ip, token,
alg, err := UploadMyAlgorithm(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -87,7 +88,7 @@ func TestCreateAlgorithm(t *testing.T) {
func TestUploadConfirmAlgorithm(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -101,7 +102,7 @@ func TestUploadConfirmAlgorithm(t *testing.T) {
Version: "V1",
FileName: filename,
}
alg, err := AlgorithmUploadConfirm(common.Ip, token,
alg, err := AlgorithmUploadConfirm(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -124,7 +125,7 @@ func TestUploadConfirmAlgorithm(t *testing.T) {
}
func TestAlgorithm(t *testing.T) {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -141,7 +142,7 @@ func TestAlgorithm(t *testing.T) {
PageSize: 100,
},
}
list, err := GetMyAlgorithmList(common.Ip, token,
list, err := GetMyAlgorithmList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -175,7 +176,7 @@ func TestAlgorithm(t *testing.T) {
PageSize: 10,
},
}
list, err := GetAlgorithmApplyList(common.Ip, token,
list, err := GetAlgorithmApplyList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -206,7 +207,7 @@ func TestAlgorithm(t *testing.T) {
PageSize: 10,
},
}
list, err := GetAlgorithmFrameworkList(common.Ip, token,
list, err := GetAlgorithmFrameworkList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())

View File

@ -3,13 +3,14 @@ package service
import (
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"testing"
)
func TestBilling(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
@ -17,7 +18,7 @@ var (
func TestCreateDataset(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -27,7 +28,7 @@ func TestCreateDataset(t *testing.T) {
param := &model.CreateDatasetParam{
Name: "asd123",
}
dst, err := CreateDataset(common.Ip, token,
dst, err := CreateDataset(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -54,10 +55,10 @@ func TestCreateDataset(t *testing.T) {
param := &model.UploadDatasetParam{
DatasetId: datasetId,
Version: datasetversion,
Domain: common.Ip,
Domain: aiconf.Cfg[aiconf.OpenI].URL,
FileName: filename,
}
udst, err := UploadDataset(common.Ip, token,
udst, err := UploadDataset(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -83,7 +84,7 @@ func TestCreateDataset(t *testing.T) {
}
func TestUploadConfirmDataset(t *testing.T) {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -95,7 +96,7 @@ func TestUploadConfirmDataset(t *testing.T) {
Version: "V1",
FileName: filename,
}
uc, err := DatasetUploadConfirm(common.Ip, token,
uc, err := DatasetUploadConfirm(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -120,7 +121,7 @@ func TestUploadConfirmDataset(t *testing.T) {
func TestDataset(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -134,7 +135,7 @@ func TestDataset(t *testing.T) {
PageSize: 100,
},
}
list, err := GetDatasetVersionList(common.Ip, token,
list, err := GetDatasetVersionList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -168,7 +169,7 @@ func TestDataset(t *testing.T) {
PageSize: 100,
},
}
list, err := GetMyDatasetList(common.Ip, token,
list, err := GetMyDatasetList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
@ -11,7 +12,7 @@ import (
func TestImage(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -26,7 +27,7 @@ func TestImage(t *testing.T) {
PageSize: 100,
},
}
list, err := GetMyImageList(common.Ip, token,
list, err := GetMyImageList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -61,7 +62,7 @@ func TestImage(t *testing.T) {
PageSize: 100,
},
}
list, err := GetPublicImageList(common.Ip, token,
list, err := GetPublicImageList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())
@ -96,7 +97,7 @@ func TestImage(t *testing.T) {
PageSize: 100,
},
}
list, err := GetPresetImageList(common.Ip, token,
list, err := GetPresetImageList(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())

View File

@ -3,6 +3,7 @@ package service
import (
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
@ -11,7 +12,7 @@ import (
func TestModel(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -24,7 +25,7 @@ func TestModel(t *testing.T) {
PageSize: 100,
},
}
list, err := GetMyModelList(common.Ip, token, param)
list, err := GetMyModelList(aiconf.Cfg[aiconf.OpenI].URL, token, param)
if err != nil {
fmt.Println(err.Error())
}
@ -48,7 +49,7 @@ func TestModel(t *testing.T) {
PageSize: 100,
},
}
list, err := GetModelVersionList(common.Ip, token, param)
list, err := GetModelVersionList(aiconf.Cfg[aiconf.OpenI].URL, token, param)
if err != nil {
fmt.Println(err.Error())
}
@ -68,9 +69,9 @@ func TestModel(t *testing.T) {
param := &model.ModelDownloadParam{
ModelId: "36ac2eff8261415c8f31b6908ea0e375",
Version: "V1",
Domain: common.Ip,
Domain: aiconf.Cfg[aiconf.OpenI].URL,
}
download, err := DownloadModelVersion(common.Ip, token, param)
download, err := DownloadModelVersion(aiconf.Cfg[aiconf.OpenI].URL, token, param)
if err != nil {
fmt.Println(err.Error())
}

View File

@ -3,20 +3,21 @@ package service
import (
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"testing"
)
func TestPlatformStat(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
token, err := tsvc.Get()
convey.Convey("GetPlatformStat", func() {
list, err := GetPlatformStat(common.Ip, token)
list, err := GetPlatformStat(aiconf.Cfg[aiconf.OpenI].URL, token)
if err != nil {
fmt.Println(err.Error())
}

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
@ -11,7 +12,7 @@ import (
func TestResource(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -21,7 +22,7 @@ func TestResource(t *testing.T) {
param := &model.ResourceSpecParam{
ResourcePool: "common-pool",
}
list, err := GetResourcespecs(common.Ip, token,
list, err := GetResourcespecs(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())

View File

@ -2,6 +2,7 @@ package service
import (
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
)
@ -11,10 +12,10 @@ func TestToken(t *testing.T) {
convey.Convey("GetResourcespecs", func() {
param := &model.TokenParam{
User: "c2net@pcl.ac.cn",
Pwd: "c2net123",
User: aiconf.Cfg[aiconf.OpenI].Username,
Pwd: aiconf.Cfg[aiconf.OpenI].Password,
}
token, err := GetToken("https://120.220.95.189:50010", param)
token, err := GetToken(aiconf.Cfg[aiconf.OpenI].URL, param)
convey.So(err, convey.ShouldBeNil)
convey.So(token, convey.ShouldNotEqual, "")

View File

@ -3,6 +3,7 @@ package service
import (
"fmt"
"github.com/smartystreets/goconvey/convey"
aiconf "gitlink.org.cn/JointCloud/pcm-participant-ai/config"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/common"
"gitlink.org.cn/JointCloud/pcm-participant-octopus/model"
"testing"
@ -10,7 +11,7 @@ import (
func TestGet(t *testing.T) {
convey.Convey("Get Methods", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -26,7 +27,7 @@ func TestGet(t *testing.T) {
PageSize: 100,
},
}
resp, err := GetTrainJobList("https://120.220.95.189:50010", token, param)
resp, err := GetTrainJobList(aiconf.Cfg[aiconf.OpenI].URL, token, param)
convey.So(err, convey.ShouldBeNil)
convey.So(resp.Payload.TotalSize, convey.ShouldEqual, 103)
@ -37,7 +38,7 @@ func TestGet(t *testing.T) {
param := &model.TrainJobDetailParam{
JobId: "n8421ab76ae84bdfa1b4069335c22f96",
}
resp, err := TrainJobDetail("https://120.220.95.189:50010", token, param)
resp, err := TrainJobDetail(aiconf.Cfg[aiconf.OpenI].URL, token, param)
convey.So(err, convey.ShouldBeNil)
convey.So(resp.Payload.TrainJob, convey.ShouldNotBeNil)
@ -48,7 +49,7 @@ func TestGet(t *testing.T) {
func TestPost(t *testing.T) {
convey.Convey("Test Service", t, func() {
tsvc, err := common.NewToken(common.Ip, common.User, common.Pwd)
tsvc, err := common.NewToken(aiconf.Cfg[aiconf.OpenI].URL, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password)
if err != nil {
fmt.Println(err.Error())
}
@ -71,7 +72,7 @@ func TestPost(t *testing.T) {
Name: "tesTrainjob123",
ResourcePool: "common-pool",
}
job, err := CreateTrainJob(common.Ip, token,
job, err := CreateTrainJob(aiconf.Cfg[aiconf.OpenI].URL, token,
param)
if err != nil {
fmt.Println(err.Error())

View File

@ -4,7 +4,6 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-resty/resty/v2"
json "github.com/json-iterator/go"
"gitlink.org.cn/JointCloud/pcm-participant-openi/common"
"gitlink.org.cn/JointCloud/pcm-participant-openi/model"
"gitlink.org.cn/JointCloud/pcm-participant-openi/service"
@ -155,46 +154,24 @@ func CreateLocalModel(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.MODELLOCALCREATE
//reqUrl := common.OPENIPREFIX + common.MODELLOCALCREATE
var resp model.CreateLocalModel
var isPrivate string
if param.IsPrivate {
isPrivate = "true"
} else {
isPrivate = "false"
}
req := common.GetRestyRequest(common.TIMEOUT)
res, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetFormData(map[string]string{
"formdata": param.FormData,
"name": param.Name,
"version": param.Version,
"engine": strconv.Itoa(param.Engine),
"label": param.Label,
"isPrivate": isPrivate,
"description": param.Description,
"type": strconv.Itoa(param.Type),
}).
SetResult(&resp).
Post(reqUrl)
//var resp model.CreateLocalModel
resp, err := ModelApi.CreateLocalModel(token, &param)
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
return
}
if res != nil {
if res.StatusCode() != 200 {
errStr := json.Get(res.Body(), "message").ToString()
model.Response(ctx, 500, errStr, nil)
return
}
}
//
//if res != nil {
// if res.StatusCode() != 200 {
// errStr := json.Get(res.Body(), "message").ToString()
// model.Response(ctx, 500, errStr, nil)
// return
// }
//}
if resp.Code != "0" {
model.Response(ctx, 500, resp.Msg, nil)

View File

@ -7,9 +7,7 @@ import (
"gitlink.org.cn/JointCloud/pcm-participant-openi/service"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
func GetTaskCreationRequired(ctx *gin.Context) {
@ -106,9 +104,6 @@ func GetTaskList(ctx *gin.Context) {
func GetTaskDetail(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.TASKDETAIL
var resp model.TaskDetail
var param model.TaskDetailParam
if err := ctx.BindJSON(&param); err != nil {
@ -116,14 +111,10 @@ func GetTaskDetail(ctx *gin.Context) {
return
}
req := common.GetRestyRequest(common.TIMEOUT)
_, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetResult(&resp).
Get(reqUrl)
resp, err := service.GetTaskDetail(token, &param)
if err != nil {
return
}
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
@ -182,25 +173,13 @@ func StopTask(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.TASKSTOP
var resp model.StopTask
req := common.GetRestyRequest(common.TIMEOUT)
_, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetResult(&resp).
Post(reqUrl)
resp, err := service.StopTask(token, &param)
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
return
}
if (resp == model.StopTask{}) {
if (*resp == model.StopTask{}) {
model.Response(ctx, 500, common.INVOKEERROR, nil)
return
}
@ -218,22 +197,17 @@ func GetLog(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.TASKLOGDOWNLOAD
req := common.GetRestyRequest(common.TIMEOUT)
rp, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
Get(reqUrl)
log, err := service.GetLog(token, &param)
if err != nil {
return
}
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
return
}
model.Response(ctx, http.StatusOK, common.SUCCESS, string(rp.Body()))
model.Response(ctx, http.StatusOK, common.SUCCESS, log)
}
func DownloadAllById(ctx *gin.Context) {
@ -245,31 +219,21 @@ func DownloadAllById(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.TASKRESULTDOWNLOAD
reqUrl = strings.Replace(reqUrl, "{username}", param.UserName, -1)
reqUrl = strings.Replace(reqUrl, "{reponame}", param.RepoName, -1)
var client http.Client
params := url.Values{}
params.Add("id", param.Id)
params.Add("access_token", token)
resp, err := client.Get(reqUrl + common.QUESTION_MARK + params.Encode())
resp, err := service.DownloadAllById(token, &param)
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
return
}
if resp.StatusCode != http.StatusOK {
model.Response(ctx, resp.StatusCode, resp.Status, nil)
if resp.StatusCode() != http.StatusOK {
model.Response(ctx, resp.StatusCode(), resp.Status, nil)
return
}
defer resp.Body.Close()
ctx.Writer.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
ctx.Writer.Header().Set("Content-Disposition", resp.Header.Get("Content-Disposition"))
ctx.Writer.Header().Set("Content-Type", resp.Header().Get("Content-Type"))
ctx.Writer.Header().Set("Content-Disposition", resp.Header().Get("Content-Disposition"))
io.Copy(ctx.Writer, resp.Body)
io.Copy(ctx.Writer, resp.RawResponse.Body)
}
func GetTaskOutput(ctx *gin.Context) {
@ -322,19 +286,7 @@ func GetTaskOnlineUrl(ctx *gin.Context) {
token := ctx.Query(common.ACCESSTOKEN)
reqUrl := common.OPENIPREFIX + common.SelfEndpointUrl
var resp model.SelfEndpointUrlResp
req := common.GetRestyRequest(common.TIMEOUT)
rp, err := req.
SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetResult(&resp).
Get(reqUrl)
resp, err := service.GetTaskOnlineUrl(token, &param)
if err != nil {
model.Response(ctx, 500, common.INVOKEERROR, err)
return
@ -345,9 +297,5 @@ func GetTaskOnlineUrl(ctx *gin.Context) {
return
}
if rp.StatusCode() != http.StatusOK {
model.Response(ctx, rp.StatusCode(), rp.Status(), nil)
return
}
model.Response(ctx, http.StatusOK, common.SUCCESS, resp.Data)
}

View File

@ -287,3 +287,12 @@ type AllModelDataResp struct {
DerivativeCount int `json:"derivativeCount"`
} `json:"data"`
}
type CreateModelResp struct {
Code int `json:"code"`
Data struct {
Code string `json:"code"`
Id string `json:"id"`
} `json:"data"`
Msg string `json:"msg"`
}

View File

@ -3,7 +3,8 @@ package model
import "time"
type GetRepo struct {
Page int `json:"page" form:"page"`
Page int `json:"page" form:"page"`
Limit int `json:"limit" form:"limit"`
}
type Repo struct {

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ func NewModelService() *ModelService {
return &ModelService{}
}
func (r ModelService) CreateLocalModel(token string, param model.CreateLocalModelParam) (resp model.CreateLocalModel, err error) {
func (r ModelService) CreateLocalModel(token string, param *model.CreateLocalModelParam) (resp model.CreateLocalModel, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.MODELLOCALCREATE, http.MethodPost, func(req *resty.Request) {
req.SetPathParam("username", param.UserName).

View File

@ -80,6 +80,7 @@ func (r RepoService) GetRepos(token string, param *model.GetRepo) (resp []model.
_, err = common.Request(common.REPO, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("page", strconv.Itoa(param.Page)).
SetQueryParam("limit", strconv.Itoa(param.Limit)).
SetResult(&resp).SetError(&respErr)
})
if err != nil {

View File

@ -55,3 +55,83 @@ func CreateTask(token string, param *model.CreateTaskReq) (resp *model.CreateTas
}
return
}
func StopTask(token string, param *model.StopTaskParam) (resp *model.StopTask, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.TASKSTOP, http.MethodPost, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return nil, err
}
return
}
func GetLog(token string, param *model.GetLogParam) (resp string, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.TASKLOGDOWNLOAD, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return "", err
}
return
}
func GetTaskDetail(token string, param *model.TaskDetailParam) (resp *model.TaskDetail, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.TASKDETAIL, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return nil, err
}
return
}
func GetTaskOnlineUrl(token string, param *model.TaskDetailParam) (resp *model.SelfEndpointUrlResp, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.SelfEndpointUrl, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return nil, err
}
return
}
func DownloadAllById(token string, param *model.DownloadAllParam) (resp *resty.Response, err error) {
respErr := &model.RespErr{}
_, err = common.Request(common.TASKRESULTDOWNLOAD, http.MethodGet, func(req *resty.Request) {
req.SetQueryParam(common.ACCESSTOKEN, token).
SetQueryParam("id", param.Id).
SetPathParam("username", param.UserName).
SetPathParam("reponame", param.RepoName).
SetError(&respErr).
SetResult(&resp)
})
if err != nil {
return nil, err
}
return
}