You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

getadaptersbymodellogic.go 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package inference
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type GetAdaptersByModelLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewGetAdaptersByModelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAdaptersByModelLogic {
  14. return &GetAdaptersByModelLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *GetAdaptersByModelLogic) GetAdaptersByModel(req *types.GetAdaptersByModelReq) (resp *types.GetAdaptersByModelResp, err error) {
  21. resp = &types.GetAdaptersByModelResp{}
  22. adapterList, err := l.svcCtx.Scheduler.AiStorages.GetAdaptersByType("1")
  23. if err != nil {
  24. return nil, err
  25. }
  26. for _, adapter := range adapterList {
  27. var clusterAvail []*types.ClusterAvail
  28. clusters, err := l.svcCtx.Scheduler.AiStorages.GetClustersByAdapterId(adapter.Id)
  29. if err != nil {
  30. return nil, err
  31. }
  32. for _, cluster := range clusters.List {
  33. cmap, found := l.svcCtx.Scheduler.AiService.InferenceAdapterMap[adapter.Id]
  34. if !found {
  35. continue
  36. }
  37. iCluster, found := cmap[cluster.Id]
  38. if !found {
  39. continue
  40. }
  41. exist := iCluster.CheckModelExistence(l.ctx, req.ModelName, req.ModelType)
  42. if exist {
  43. c := &types.ClusterAvail{
  44. ClusterId: cluster.Id,
  45. ClusterName: cluster.Name,
  46. }
  47. clusterAvail = append(clusterAvail, c)
  48. }
  49. }
  50. if len(clusterAvail) == 0 {
  51. continue
  52. }
  53. adapterAvail := &types.AdapterAvail{
  54. AdapterId: adapter.Id,
  55. AdapterName: adapter.Name,
  56. Clusters: clusterAvail,
  57. }
  58. resp.Adapters = append(resp.Adapters, adapterAvail)
  59. }
  60. return resp, nil
  61. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.