Merge pull request 'update config' (#39) from tzwang/pcm-participant:master into master
This commit is contained in:
commit
1ebb9c67d4
|
@ -28,7 +28,7 @@ var (
|
|||
func TestGet(t *testing.T) {
|
||||
|
||||
convey.Convey(aiconf.Octopus, t, func() {
|
||||
o, err := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
o, err := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
|
@ -51,7 +51,7 @@ func TestGet(t *testing.T) {
|
|||
})
|
||||
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
alg := NewAlgorithm(o.Alg)
|
||||
|
@ -102,7 +102,7 @@ func TestCreate(t *testing.T) {
|
|||
//o, _ := openI.New("nudt-ysz", "", "8cff1d2db9171462c02901d086d13221389fd082", platform.Id(123), "data")
|
||||
//common.InitClient()
|
||||
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
alg := NewAlgorithm(oct.Alg)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func TestDataset(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
ds := NewDataset(o.Ds)
|
||||
|
@ -62,7 +62,7 @@ func TestDataset(t *testing.T) {
|
|||
})
|
||||
|
||||
convey.Convey(aiconf.Octopus, t, func() {
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
ds := NewDataset(oct.Ds)
|
||||
|
||||
|
@ -90,7 +90,7 @@ func TestCreateDataset(t *testing.T) {
|
|||
//o, _ := openI.New(aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
//common.InitClient()
|
||||
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
ds := NewDataset(oct.Ds)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
func TestImage(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
|
||||
common.InitClient()
|
||||
i := NewImage(o.Img)
|
||||
|
@ -83,7 +83,7 @@ func TestImage(t *testing.T) {
|
|||
|
||||
func TestOctopusImage(t *testing.T) {
|
||||
convey.Convey(aiconf.Octopus, t, func() {
|
||||
o, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
o, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
i := NewImage(o.Img)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
func TestCreateModel(t *testing.T) {
|
||||
|
||||
convey.Convey("Create Model", t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
mdl := NewModel(o.Mdl)
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
func TestResource(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
|
||||
common.InitClient()
|
||||
res := NewResource(o.Res)
|
||||
|
@ -97,7 +97,7 @@ func TestResource(t *testing.T) {
|
|||
|
||||
func TestGetResourceSpecs(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
|
||||
common.InitClient()
|
||||
res := NewResource(o.Res)
|
||||
|
@ -116,7 +116,7 @@ func TestGetResourceSpecs(t *testing.T) {
|
|||
})
|
||||
|
||||
convey.Convey(aiconf.Octopus, t, func() {
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
oct, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
res := NewResource(oct.Res)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ func NewService(platforms ...platform.IPlatform) (*Service, error) {
|
|||
s := &Service{}
|
||||
for _, pf := range platforms {
|
||||
if err := s.registerPlatform(pf); err != nil {
|
||||
return nil, fmt.Errorf("failed to register platform %d: %w", pf.Id(), err)
|
||||
return nil, fmt.Errorf("failed to register platform %s: %w", pf.Id(), err)
|
||||
}
|
||||
}
|
||||
return s, nil
|
||||
|
@ -107,7 +107,7 @@ func (s *Service) AllTrainResources(ctx context.Context) ([]*resource.Spec, erro
|
|||
defer mu.Unlock()
|
||||
|
||||
if err != nil {
|
||||
errList = append(errList, fmt.Errorf("platform %d: %w", id, err))
|
||||
errList = append(errList, fmt.Errorf("platform %s: %w", id, err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -324,12 +324,12 @@ func loadFromSyncMap[T any](m *sync.Map, id platform.Id, resourceType string) (T
|
|||
var zero T
|
||||
val, ok := m.Load(id)
|
||||
if !ok {
|
||||
return zero, fmt.Errorf("%s for platform ID %d not found", resourceType, id)
|
||||
return zero, fmt.Errorf("%s for platform ID %s not found", resourceType, id)
|
||||
}
|
||||
|
||||
result, ok := val.(T)
|
||||
if !ok {
|
||||
return zero, fmt.Errorf("invalid %s type for platform ID %d", resourceType, id)
|
||||
return zero, fmt.Errorf("invalid %s type for platform ID %s", resourceType, id)
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
func TestAlgorithm_Train(t *testing.T) {
|
||||
convey.Convey("Test Service", t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, 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(456))
|
||||
|
||||
common.InitClient()
|
||||
|
@ -71,10 +71,10 @@ func TestAlgorithm_Train(t *testing.T) {
|
|||
|
||||
func TestService(t *testing.T) {
|
||||
convey.Convey("Test Service", t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
o1, err := octopus.New(nil, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(456))
|
||||
o1, err := octopus.New(nil, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("456"))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
func TestOpenITask(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
tps := &task.TrainParams{
|
||||
|
@ -64,7 +64,7 @@ func TestOpenITask(t *testing.T) {
|
|||
|
||||
func TestResultSync(t *testing.T) {
|
||||
convey.Convey(aiconf.OpenI, t, func() {
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id(123), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
o, _ := openI.New(Jcs, aiconf.Cfg[aiconf.OpenI].Username, aiconf.Cfg[aiconf.OpenI].Password, aiconf.Cfg[aiconf.OpenI].APIKey, aiconf.OpenI, platform.Id("123"), aiconf.Cfg[aiconf.OpenI].DataRepo)
|
||||
common.InitClient()
|
||||
|
||||
src := &aicom.Source{
|
||||
|
@ -99,7 +99,7 @@ func TestResultSync(t *testing.T) {
|
|||
|
||||
func TestOctopusTask(t *testing.T) {
|
||||
convey.Convey(aiconf.Octopus, t, func() {
|
||||
o, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id(123))
|
||||
o, _ := octopus.New(Jcs, aiconf.Cfg[aiconf.Octopus].URL, aiconf.Cfg[aiconf.Octopus].Username, aiconf.Cfg[aiconf.Octopus].Password, aiconf.Octopus, platform.Id("123"))
|
||||
|
||||
tps := &task.TrainParams{
|
||||
TaskName: "testTask123",
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package common
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/JCCE-nudt/apigw-go-sdk/core"
|
||||
json "github.com/json-iterator/go"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -70,3 +71,11 @@ func SendRequestHttp(method, url string, in io.Reader, Platform string) ([]byte,
|
|||
fmt.Println(string(body))
|
||||
return body, nil
|
||||
}
|
||||
|
||||
func ToIOReader(p interface{}) (io.Reader, error) {
|
||||
data, err := json.Marshal(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bytes.NewReader(data), nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package common
|
||||
|
||||
const (
|
||||
Forward_Slash = "/"
|
||||
// algorithm
|
||||
Algorithm = "/v2/{project_id}/algorithms"
|
||||
AlgorithmDetail = "/v2/{project_id}/algorithms/{algorithm_id}"
|
||||
Algorithm = "v2/{project_id}/algorithms"
|
||||
AlgorithmDetail = "v2/{project_id}/algorithms/{algorithm_id}"
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func Test123(t *testing.T) {
|
||||
func TestSign(t *testing.T) {
|
||||
a := "https://modelarts.cn-south-222.ai.pcl.cn/v2/d18190e28e3f45a281ef0b0696ec9d52/algorithms"
|
||||
body, err := SendRequestHttp(http.MethodGet, a, nil, "")
|
||||
if err != nil {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package model
|
||||
|
||||
type AlgorithmListParam struct {
|
||||
Offset int `json:"offset,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
SortBy string `json:"sort_by,omitempty"`
|
||||
Order string `json:"order,omitempty"`
|
||||
GroupBy string `json:"group_by,omitempty"`
|
||||
Searches string `json:"searches,omitempty"`
|
||||
WorkspaceId string `json:"workspace_id,omitempty"`
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-participant-modelarts/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-participant-modelarts/model"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AlgorithmList(ip, projectId string, param *model.AlgorithmListParam) (interface{}, error) {
|
||||
var reqUrl = ip + common.Forward_Slash + common.Algorithm
|
||||
|
||||
reqUrl = strings.Replace(reqUrl, "{project_id}", projectId, -1)
|
||||
|
||||
reader, err := common.ToIOReader(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := common.SendRequestHttp(http.MethodGet, reqUrl, reader, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/smartystreets/goconvey/convey"
|
||||
"gitlink.org.cn/JointCloud/pcm-participant-modelarts/model"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAlgorithm(t *testing.T) {
|
||||
url := ""
|
||||
projectId := ""
|
||||
convey.Convey("AlgorithmList", t, func() {
|
||||
param := &model.AlgorithmListParam{}
|
||||
list, err := AlgorithmList(url, projectId, param)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
convey.So(err, convey.ShouldBeNil)
|
||||
convey.So(list, convey.ShouldNotBeEmpty)
|
||||
|
||||
})
|
||||
|
||||
convey.Convey("AlgorithmList", t, func() {
|
||||
|
||||
})
|
||||
|
||||
}
|
Loading…
Reference in New Issue