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.

models.go 23 kB

1 year ago
1 year ago
6 months ago
6 months ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. package schsdk
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/types"
  4. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  5. "gitlink.org.cn/cloudream/common/utils/serder"
  6. )
  7. const (
  8. JobTypeNormal = "Normal"
  9. JobTypePCM = "PCM"
  10. JobTypeResource = "Resource"
  11. JobTypeInstance = "Instance"
  12. JobTypeFinetuning = "Finetuning"
  13. JobTypeDataPreprocess = "DataPreprocess"
  14. JobTypeDataReturn = "DataReturn"
  15. JobTypeReport = "Report"
  16. FileInfoTypePackage = "Package"
  17. FileInfoTypeLocalFile = "LocalFile"
  18. FileInfoTypeResource = "Resource"
  19. FileInfoTypeImage = "Image"
  20. FILE = "file"
  21. FOLDER = "folder"
  22. MemoryUtilization = "MemoryUtilization"
  23. GPUUtilization = "GPUUtilization"
  24. CPUUtilization = "CPUUtilization"
  25. MethodPost = "post"
  26. MethodGet = "get"
  27. CodeSuccess = 200
  28. )
  29. type JobID string
  30. type JobSetID string
  31. type DataID int64
  32. type ImageID int64
  33. // 计算中心ID
  34. type CCID int64
  35. type ModelID string
  36. type ModelName string
  37. type ECSInstanceID string
  38. type NodeID int64
  39. type Address string
  40. type ClusterID string
  41. type JobSetInfo struct {
  42. Jobs []JobInfo `json:"jobs"`
  43. }
  44. type JobInfo interface {
  45. GetLocalJobID() string
  46. GetTargetLocalJobIDs() []string
  47. SetTargetLocalJob(info TargetJobInfo)
  48. GetTargetInputParams(targetID string) map[string]string
  49. }
  50. var JobInfoTypeUnion = types.NewTypeUnion[JobInfo](
  51. (*NormalJobInfo)(nil),
  52. (*DataReturnJobInfo)(nil),
  53. (*MultiInstanceJobInfo)(nil),
  54. (*InstanceJobInfo)(nil),
  55. (*UpdateMultiInstanceJobInfo)(nil),
  56. (*FinetuningJobInfo)(nil),
  57. (*DataPreprocessJobInfo)(nil),
  58. (*AIJobInfo)(nil),
  59. (*HPCJobInfo)(nil),
  60. (*BindingJobInfo)(nil),
  61. (*PCMInferenceJobInfo)(nil),
  62. (*CompleteJobInfo)(nil),
  63. (*StartJobInfo)(nil),
  64. (*NotifyJobInfo)(nil),
  65. (*StopInferenceJobInfo)(nil),
  66. (*UploadJobInfo)(nil),
  67. (*BroadcastWaitInfo)(nil),
  68. (*CloudJobInfo)(nil),
  69. )
  70. var _ = serder.UseTypeUnionInternallyTagged(&JobInfoTypeUnion, "type")
  71. type JobInfoBase struct {
  72. LocalJobID string `json:"localJobID"`
  73. TargetJob []TargetJobInfo `json:"targetJob"`
  74. TargetJobType TargetJobType `json:"targetJobType"`
  75. }
  76. type TargetJobType struct {
  77. JobType string `json:"jobType"`
  78. InputParams map[string]string `json:"inputParams"`
  79. }
  80. type TargetJobInfo struct {
  81. TargetJobID string `json:"targetJobID"`
  82. InputParams map[string]string `json:"inputParams"`
  83. }
  84. func (i *JobInfoBase) GetLocalJobID() string {
  85. return i.LocalJobID
  86. }
  87. func (i *JobInfoBase) GetTargetInputParams(targetID string) map[string]string {
  88. for _, v := range i.TargetJob {
  89. if v.TargetJobID == targetID {
  90. return v.InputParams
  91. }
  92. }
  93. return nil
  94. }
  95. func (i *JobInfoBase) GetTargetLocalJobIDs() []string {
  96. var IDs []string
  97. for _, v := range i.TargetJob {
  98. IDs = append(IDs, v.TargetJobID)
  99. }
  100. return IDs
  101. }
  102. func (i *JobInfoBase) SetTargetLocalJob(info TargetJobInfo) {
  103. for _, target := range i.TargetJob {
  104. // 已经存在,则不用再添加
  105. if target.TargetJobID == info.TargetJobID {
  106. return
  107. }
  108. }
  109. i.TargetJob = append(i.TargetJob, info)
  110. }
  111. type NormalJobInfo struct {
  112. serder.Metadata `union:"Normal"`
  113. JobInfoBase
  114. Type string `json:"type"`
  115. Files JobFilesInfo `json:"files"`
  116. Runtime JobRuntimeInfo `json:"runtime"`
  117. Resources JobResourcesInfo `json:"resources"`
  118. Services JobServicesInfo `json:"services"`
  119. ModelJobInfo ModelJobInfo `json:"modelJobInfo"`
  120. }
  121. type PCMInferenceJobInfo struct {
  122. serder.Metadata `union:"PCM_Inference"`
  123. JobInfoBase
  124. Type string `json:"type"`
  125. Name string `json:"name"`
  126. Description string `json:"description"`
  127. Files JobFilesInfo `json:"files"`
  128. JobResources JobResources `json:"jobResources"`
  129. BindingID DataID `json:"bindingID"`
  130. ResourceChoice ResourceChoice `json:"resourceChoice"`
  131. }
  132. type StopInferenceJobInfo struct {
  133. serder.Metadata `union:"StopInference"`
  134. JobInfoBase
  135. Type string `json:"type"`
  136. Url string `json:"url"`
  137. }
  138. type AIJobInfo struct {
  139. serder.Metadata `union:"AI"`
  140. JobInfoBase
  141. Type string `json:"type"`
  142. Name string `json:"name"`
  143. Description string `json:"description"`
  144. OnlyCreate bool `json:"onlyCreate"`
  145. Files JobFilesInfo `json:"files"`
  146. JobResources JobResources `json:"jobResources"`
  147. ResourceChoice ResourceChoice `json:"resourceChoice"`
  148. }
  149. type CompleteJobInfo struct {
  150. serder.Metadata `union:"Complete"`
  151. JobInfoBase
  152. Type string `json:"type"`
  153. }
  154. type StartJobInfo struct {
  155. serder.Metadata `union:"Start"`
  156. JobInfoBase
  157. Type string `json:"type"`
  158. }
  159. type UploadJobInfo struct {
  160. serder.Metadata `union:"Upload"`
  161. JobInfoBase
  162. Type string `json:"type"`
  163. DataType string `json:"dataType"`
  164. }
  165. type BroadcastWaitInfo struct {
  166. serder.Metadata `union:"BroadcastWait"`
  167. JobInfoBase
  168. Type string `json:"type"`
  169. HandleType string `json:"handleType"`
  170. Broadcast []Broadcast `json:"broadcast"`
  171. Wait []Wait `json:"wait"`
  172. }
  173. type Broadcast struct {
  174. NextJobSetID JobSetID `json:"nextJobSetID"`
  175. NextLocalJobID string `json:"nextLocalJobID"`
  176. }
  177. type Wait struct {
  178. WaitJobID string `json:"waitJobID"`
  179. }
  180. type CloudJobInfo struct {
  181. serder.Metadata `union:"CLOUD"`
  182. JobInfoBase
  183. Type string `json:"type"`
  184. ClusterID ClusterID `json:"clusterID,omitempty"`
  185. ContainerGroupName string `json:"containerGroupName"`
  186. Name string `json:"name"`
  187. Image string `json:"image"`
  188. Cpu string `json:"cpu,omitempty"`
  189. Memory string `json:"memory,omitempty"`
  190. Port int32 `json:"port,omitempty"`
  191. NodePort int32 `json:"nodePort,omitempty"`
  192. MountPath string `json:"mountPath,omitempty"`
  193. Args []string `json:"args,omitempty"`
  194. Envs []interface{} `json:"envs,omitempty"`
  195. Capacity int32 `json:"capacity,omitempty"`
  196. }
  197. type NotifyJobInfo struct {
  198. serder.Metadata `union:"Notify"`
  199. JobInfoBase
  200. Type string `json:"type"`
  201. RequestType string `json:"requestType"`
  202. Url string `json:"url"`
  203. Body any `json:"body"`
  204. Headers map[string]string `json:"headers"`
  205. }
  206. type ResourceChoice struct {
  207. Type string `json:"type"`
  208. ResourceScopes []ResourceScope `json:"resourceScopes"`
  209. }
  210. type ResourceScope struct {
  211. Name string `json:"name"`
  212. Min float64 `json:"min"`
  213. Max float64 `json:"max"`
  214. }
  215. type BindingJobInfo struct {
  216. serder.Metadata `union:"Binding"`
  217. JobInfoBase
  218. Type string `json:"type"`
  219. Info DataBinding `json:"info"`
  220. // 下面参数用于工作流输入
  221. PackageID cdssdk.PackageID `json:"packageID"`
  222. ClusterID ClusterID `json:"clusterID"`
  223. Output string `json:"output"`
  224. }
  225. type HPCJobInfo struct {
  226. serder.Metadata `union:"HPC"`
  227. JobInfoBase
  228. Type string `json:"type"`
  229. Name string `json:"name"`
  230. Description string `json:"description"`
  231. ClusterID ClusterID `json:"clusterID"`
  232. Backend string `json:"backend"`
  233. App string `json:"app"`
  234. OperateType string `json:"operateType"`
  235. ScriptContent string `json:"scriptContent"`
  236. Parameters HPCParameter `json:"parameters"`
  237. CustomParams map[string]string `json:"customParams"`
  238. }
  239. type HPCParameter struct {
  240. JobName string `json:"jobName"`
  241. JobDir string `json:"jobDir"`
  242. Partition string `json:"partition"`
  243. Ntasks string `json:"ntasks"`
  244. Nodes string `json:"nodes"`
  245. BamFile string `json:"bamFile"`
  246. HashType string `json:"hashType"`
  247. AttackMode string `json:"attackMode"`
  248. HashInput string `json:"hashInput"`
  249. Mask string `json:"mask"`
  250. Dictionary string `json:"dictionary"`
  251. Dictionary2 string `json:"dictionary2"`
  252. //ScriptDir string `json:"scriptDir"`
  253. HPCBindingFiles []HPCBindingFile `json:"hpcBindingFiles"`
  254. }
  255. type HPCBindingFile struct {
  256. ParamName string `json:"paramName"`
  257. Resource HPCFile `json:"resource"`
  258. }
  259. type HPCFile interface {
  260. Noop()
  261. }
  262. var HPCFileTypeUnion = types.NewTypeUnion[HPCFile](
  263. (*HPCObject)(nil),
  264. (*HPCPath)(nil),
  265. )
  266. var _ = serder.UseTypeUnionInternallyTagged(&HPCFileTypeUnion, "type")
  267. type HPCFileBase struct{}
  268. func (d *HPCFileBase) Noop() {}
  269. type HPCObject struct {
  270. serder.Metadata `union:"object"`
  271. HPCFileBase
  272. Type string `json:"type"`
  273. ObjectID cdssdk.ObjectID `json:"objectID"`
  274. }
  275. type HPCPath struct {
  276. serder.Metadata `union:"path"`
  277. HPCFileBase
  278. Type string `json:"type"`
  279. PackageID cdssdk.PackageID `json:"packageID"`
  280. Path string `json:"path"`
  281. }
  282. type JobResources struct {
  283. //任务分配策略:负载均衡、积分优先、随机分配等,dataLocality, leastLoadFirst
  284. ScheduleStrategy string `json:"scheduleStrategy"`
  285. Clusters []ClusterInfo `json:"clusters"`
  286. }
  287. type ClusterInfo struct {
  288. ClusterID ClusterID `json:"clusterID"`
  289. Resources []JobResource `json:"resources"`
  290. //Files JobFilesInfo `json:"files"`
  291. Code JobFileInfo `json:"code"`
  292. Runtime PCMJobRuntimeInfo `json:"runtime"`
  293. }
  294. type PCMJobRuntimeInfo struct {
  295. Command string `json:"command"`
  296. Envs map[string]interface{} `json:"envs"`
  297. Params map[string]interface{} `json:"params"`
  298. }
  299. //type Resource struct {
  300. // Resource []JobResource `json:"resource"`
  301. //}
  302. type JobResource interface {
  303. Noop()
  304. }
  305. var JobResourceTypeUnion = types.NewTypeUnion[JobResource](
  306. (*CPU)(nil),
  307. (*GPU)(nil),
  308. (*NPU)(nil),
  309. (*MLU)(nil),
  310. (*DCU)(nil),
  311. (*MEMORY)(nil),
  312. (*PRICE)(nil),
  313. (*STORAGE)(nil),
  314. (*GCU)(nil),
  315. (*ILUVATAR_GPGPU)(nil),
  316. )
  317. var _ = serder.UseTypeUnionInternallyTagged(&JobResourceTypeUnion, "type")
  318. type JobResourceBase struct{}
  319. func (d *JobResourceBase) Noop() {}
  320. type CPU struct {
  321. serder.Metadata `union:"CPU"`
  322. JobResourceBase
  323. Type string `json:"type"`
  324. Name string `json:"name"`
  325. Number int64 `json:"number"`
  326. }
  327. type STORAGE struct {
  328. serder.Metadata `union:"STORAGE"`
  329. JobResourceBase
  330. Type string `json:"type"`
  331. Name string `json:"name"`
  332. Number int64 `json:"number"`
  333. }
  334. type GPU struct {
  335. serder.Metadata `union:"GPU"`
  336. JobResourceBase
  337. Type string `json:"type"`
  338. Name string `json:"name"`
  339. Number int64 `json:"number"`
  340. }
  341. type NPU struct {
  342. serder.Metadata `union:"NPU"`
  343. JobResourceBase
  344. Type string `json:"type"`
  345. Name string `json:"name"`
  346. Number int64 `json:"number"`
  347. }
  348. type MEMORY struct {
  349. serder.Metadata `union:"MEMORY"`
  350. JobResourceBase
  351. Type string `json:"type"`
  352. Name string `json:"name"`
  353. Number int64 `json:"number"`
  354. }
  355. type DCU struct {
  356. serder.Metadata `union:"DCU"`
  357. JobResourceBase
  358. Type string `json:"type"`
  359. Name string `json:"name"`
  360. Number int64 `json:"number"`
  361. }
  362. type MLU struct {
  363. serder.Metadata `union:"MLU"`
  364. JobResourceBase
  365. Type string `json:"type"`
  366. Name string `json:"name"`
  367. Number int64 `json:"number"`
  368. }
  369. type GCU struct {
  370. serder.Metadata `union:"GCU"`
  371. JobResourceBase
  372. Type string `json:"type"`
  373. Name string `json:"name"`
  374. Number int64 `json:"number"`
  375. }
  376. type ILUVATAR_GPGPU struct {
  377. serder.Metadata `union:"ILUVATAR-GPGPU"`
  378. JobResourceBase
  379. Type string `json:"type"`
  380. Name string `json:"name"`
  381. Number int64 `json:"number"`
  382. }
  383. type PRICE struct {
  384. serder.Metadata `union:"PRICE"`
  385. JobResourceBase
  386. Type string `json:"type"`
  387. Name string `json:"name"`
  388. Number int64 `json:"number"`
  389. }
  390. // FinetuningJobInfo 模型微调
  391. type FinetuningJobInfo struct {
  392. serder.Metadata `union:"Finetuning"`
  393. JobInfoBase
  394. Type string `json:"type"`
  395. Files JobFilesInfo `json:"files"`
  396. Runtime JobRuntimeInfo `json:"runtime"`
  397. Resources JobResourcesInfo `json:"resources"`
  398. Services JobServicesInfo `json:"services"`
  399. ModelJobInfo ModelJobInfo `json:"modelJobInfo"`
  400. }
  401. // DataPreprocessJobInfo 数据预处理
  402. type DataPreprocessJobInfo struct {
  403. serder.Metadata `union:"DataPreprocess"`
  404. JobInfoBase
  405. Type string `json:"type"`
  406. Files JobFilesInfo `json:"files"`
  407. Runtime JobRuntimeInfo `json:"runtime"`
  408. Resources JobResourcesInfo `json:"resources"`
  409. Services JobServicesInfo `json:"services"`
  410. }
  411. type DataReturnJobInfo struct {
  412. serder.Metadata `union:"DataReturn"`
  413. JobInfoBase
  414. Type string `json:"type"`
  415. BucketID cdssdk.BucketID `json:"bucketID"`
  416. TargetLocalJobID string `json:"targetLocalJobID"`
  417. // 下面是工作流的参数
  418. ClusterID ClusterID `json:"clusterID"`
  419. Output string `json:"output"`
  420. PackageName string `json:"packageName"`
  421. }
  422. // MultiInstanceJobInfo 多实例(推理任务)
  423. type MultiInstanceJobInfo struct {
  424. serder.Metadata `union:"MultiInstance"`
  425. JobInfoBase
  426. Type string `json:"type"`
  427. Files JobFilesInfo `json:"files"`
  428. Runtime JobRuntimeInfo `json:"runtime"`
  429. Resources JobResourcesInfo `json:"resources"`
  430. ModelJobInfo ModelJobInfo `json:"modelJobInfo"`
  431. }
  432. // UpdateMultiInstanceJobInfo 更新模型
  433. type UpdateMultiInstanceJobInfo struct {
  434. serder.Metadata `union:"UpdateModel"`
  435. JobInfoBase
  436. Type string `json:"type"`
  437. Files JobFilesInfo `json:"files"`
  438. Runtime JobRuntimeInfo `json:"runtime"`
  439. MultiInstanceJobSetID JobSetID `json:"multiInstanceJobSetID"`
  440. UpdateType string `json:"updateType"`
  441. SubJobs []JobID `json:"subJobs"`
  442. Operate string `json:"operate"`
  443. }
  444. type ModelJobInfo struct {
  445. Type string `json:"type"`
  446. ModelID ModelID `json:"modelID"`
  447. CustomModelName ModelName `json:"customModelName"`
  448. Command string `json:"command"`
  449. }
  450. // InstanceJobInfo 单实例(推理任务)
  451. type InstanceJobInfo struct {
  452. serder.Metadata `union:"Instance"`
  453. JobInfoBase
  454. Type string `json:"type"`
  455. LocalJobID string `json:"multiInstJobID"`
  456. Files JobFilesInfo `json:"files"`
  457. Runtime JobRuntimeInfo `json:"runtime"`
  458. Resources JobResourcesInfo `json:"resources"`
  459. ModelJobInfo ModelJobInfo `json:"modelJobInfo"`
  460. }
  461. type JobFilesInfo struct {
  462. Dataset JobFileInfo `json:"dataset"`
  463. Code JobFileInfo `json:"code"`
  464. Image JobFileInfo `json:"image"`
  465. Model JobFileInfo `json:"model"`
  466. }
  467. type JobFileInfo interface {
  468. Noop()
  469. }
  470. var FileInfoTypeUnion = types.NewTypeUnion[JobFileInfo](
  471. (*PackageJobFileInfo)(nil),
  472. (*LocalJobFileInfo)(nil),
  473. (*DataReturnJobFileInfo)(nil),
  474. (*ImageJobFileInfo)(nil),
  475. (*BindingJobFileInfo)(nil),
  476. )
  477. var _ = serder.UseTypeUnionInternallyTagged(&FileInfoTypeUnion, "type")
  478. type JobFileInfoBase struct{}
  479. func (i *JobFileInfoBase) Noop() {}
  480. type BindingJobFileInfo struct {
  481. serder.Metadata `union:"Binding"`
  482. JobFileInfoBase
  483. Type string `json:"type"`
  484. BindingID int64 `json:"bindingID"`
  485. // 用于参数回显
  486. BindingName string `json:"bindingName"`
  487. }
  488. type PackageJobFileInfo struct {
  489. serder.Metadata `union:"Package"`
  490. JobFileInfoBase
  491. Type string `json:"type"`
  492. PackageID cdssdk.PackageID `json:"packageID"`
  493. }
  494. type LocalJobFileInfo struct {
  495. serder.Metadata `union:"LocalFile"`
  496. JobFileInfoBase
  497. Type string `json:"type"`
  498. LocalPath string `json:"localPath"`
  499. }
  500. type DataReturnJobFileInfo struct {
  501. serder.Metadata `union:"DataReturn"`
  502. JobFileInfoBase
  503. Type string `json:"type"`
  504. DataReturnLocalJobID string `json:"dataReturnLocalJobID"`
  505. }
  506. type ImageJobFileInfo struct {
  507. serder.Metadata `union:"Image"`
  508. JobFileInfoBase
  509. Type string `json:"type"`
  510. ImageID ImageID `json:"imageID"`
  511. // 用于参数回显
  512. ImageName string `json:"imageName"`
  513. }
  514. type JobRuntimeInfo struct {
  515. Command string `json:"command"`
  516. Envs []KVPair `json:"envs"`
  517. Params []KVPair `json:"params"`
  518. }
  519. type KVPair struct {
  520. Key string `json:"key"`
  521. Value string `json:"value"`
  522. }
  523. // CPU、GPU、NPU、MLU单位为:核
  524. // Storage、Memory单位为:字节
  525. type JobResourcesInfo struct {
  526. CPU float64 `json:"cpu"`
  527. GPU float64 `json:"gpu"`
  528. NPU float64 `json:"npu"`
  529. MLU float64 `json:"mlu"`
  530. Storage int64 `json:"storage"`
  531. Memory int64 `json:"memory"`
  532. }
  533. type JobSetFilesUploadScheme struct {
  534. LocalFileSchemes []LocalFileUploadScheme `json:"localFileUploadSchemes"`
  535. }
  536. type JobFilesUploadScheme struct {
  537. LocalFileSchemes []LocalFileUploadScheme `json:"localFileUploadSchemes"`
  538. }
  539. type LocalFileUploadScheme struct {
  540. LocalPath string `json:"localPath"`
  541. UploadToCDStorageID cdssdk.StorageID `json:"uploadToCDSStorageID"`
  542. }
  543. type JobServicesInfo struct {
  544. ServicePortInfos []ServicePortInfo `json:"servicePortInfos"`
  545. }
  546. type ServicePortInfo struct {
  547. Name string `json:"name"`
  548. Port int64 `json:"port"`
  549. }
  550. type JobSetServiceInfo struct {
  551. Name string `json:"name"`
  552. Port int64 `json:"port"`
  553. CDSStorageID cdssdk.StorageID `json:"cdsStorageID"`
  554. LocalJobID string `json:"localJobID"`
  555. }
  556. type Bootstrap interface {
  557. GetBootstrapType() string
  558. }
  559. type DirectBootstrap struct {
  560. serder.Metadata `union:"Direct"`
  561. Type string `json:"type"`
  562. }
  563. type NoEnvBootstrap struct {
  564. serder.Metadata `union:"NoEnv"`
  565. Type string `json:"type"`
  566. ScriptPackageID cdssdk.PackageID `json:"scriptPackageID"`
  567. ScriptFileName string `json:"scriptFileName"`
  568. }
  569. var BootstrapTypeUnion = types.NewTypeUnion[Bootstrap](
  570. (*DirectBootstrap)(nil),
  571. (*NoEnvBootstrap)(nil),
  572. )
  573. var _ = serder.UseTypeUnionInternallyTagged(&BootstrapTypeUnion, "type")
  574. func (b *DirectBootstrap) GetBootstrapType() string {
  575. return b.Type
  576. }
  577. func (b *NoEnvBootstrap) GetBootstrapType() string {
  578. return b.Type
  579. }
  580. const (
  581. JobDataInEnv = "SCH_DATA_IN"
  582. JobDataOutEnv = "SCH_DATA_OUT"
  583. FinetuningOutEnv = "FINETUNING_OUT"
  584. AccessPath = "ACCESS_PATH"
  585. )
  586. type Rclone struct {
  587. CDSRcloneID string `json:"cds_rcloneID"`
  588. CDSRcloneConfigID string `json:"cds_rcloneConfigID"`
  589. }
  590. type InferencePlatform struct {
  591. PlatformName string `json:"platformName"`
  592. ApiBaseUrl string `json:"apiBaseUrl"`
  593. ApiKey string `json:"apiKey"`
  594. ApiProxy string `json:"apiProxy"`
  595. LlmModel string `json:"llmModel"`
  596. EmbedModel string `json:"embedModel"`
  597. ChunkMaxLength string `json:"chunkMaxLength"`
  598. StartChunkThreshold string `json:"startChunkThreshold"`
  599. SimilarityThreshold string `json:"similarityThreshold"`
  600. EntriesPerFile string `json:"entriesPerFile"`
  601. }
  602. type JobOutput interface {
  603. Output2()
  604. }
  605. var JobOutputTypeUnion = types.NewTypeUnion[JobOutput](
  606. (*AIJobOutput)(nil),
  607. (*BindingJobOutput)(nil),
  608. (*UploadJobOutput)(nil),
  609. (*HPCJobOutput)(nil),
  610. (*NotifyJobOutput)(nil),
  611. (*DataReturnJobOutput)(nil),
  612. (*PublicOutput)(nil),
  613. (*PCMInferenceJobOutput)(nil),
  614. (*BroadcastWaitOutput)(nil),
  615. (*CloudJobOutput)(nil),
  616. )
  617. var _ = serder.UseTypeUnionInternallyTagged(&JobOutputTypeUnion, "type")
  618. type JobOutputBase struct{}
  619. func (d *JobOutputBase) Output2() {}
  620. type PublicOutput struct {
  621. serder.Metadata `union:"object"`
  622. JobOutputBase
  623. Type string `json:"type"`
  624. Output string `json:"output"`
  625. }
  626. type PCMInferenceJobOutput struct {
  627. serder.Metadata `union:"PCM_Inference"`
  628. JobOutputBase
  629. Type string `json:"type"`
  630. URL string `json:"url"`
  631. ID string `json:"id"`
  632. AdapterID string `json:"adapterId"`
  633. ClusterID ClusterID `json:"clusterId"`
  634. InstanceID string `json:"instanceId"`
  635. }
  636. type NotifyJobOutput struct {
  637. serder.Metadata `union:"Notify"`
  638. JobOutputBase
  639. Type string `json:"type"`
  640. Output string `json:"output"`
  641. }
  642. type HPCJobOutput struct {
  643. serder.Metadata `union:"HPCSlurm"`
  644. JobOutputBase
  645. Type string `json:"type"`
  646. Name string `json:"name"`
  647. Output string `json:"output"`
  648. ClusterID ClusterID `json:"clusterID"`
  649. }
  650. type AIJobOutput struct {
  651. serder.Metadata `union:"AI"`
  652. JobOutputBase
  653. Type string `json:"type"`
  654. Name string `json:"name"`
  655. Output string `json:"output"`
  656. ClusterID ClusterID `json:"clusterID"`
  657. }
  658. type BindingJobOutput struct {
  659. serder.Metadata `union:"binding"`
  660. JobOutputBase
  661. Type string `json:"type"`
  662. BindingID DataID `json:"bindingID"`
  663. }
  664. type BroadcastWaitOutput struct {
  665. serder.Metadata `union:"BroadcastWait"`
  666. JobOutputBase
  667. Type string `json:"type"`
  668. Output JobOutput `json:"output"`
  669. // 下面是工作流的参数
  670. WaitIDs []Wait `json:"waitIDs"`
  671. }
  672. type UploadJobOutput struct {
  673. serder.Metadata `union:"upload"`
  674. JobOutputBase
  675. Type string `json:"type"`
  676. PackageID cdssdk.PackageID `json:"packageID"`
  677. }
  678. type DataReturnJobOutput struct {
  679. serder.Metadata `union:"DataReturn"`
  680. JobOutputBase
  681. Type string `json:"type"`
  682. //ReportMessage TrainJobStatusReport `json:"report"`
  683. PackageID cdssdk.PackageID `json:"packageID"`
  684. }
  685. type CloudJobOutput struct {
  686. serder.Metadata `union:"CLOUD"`
  687. JobOutputBase
  688. Type string `json:"type"`
  689. Command interface{} `json:"Command"`
  690. Args []string `json:"args"`
  691. ContainerPorts map[string]interface{} `json:"containerPorts"`
  692. Image string `json:"image"`
  693. Limits map[string]interface{} `json:"limits"`
  694. Name string `json:"name"`
  695. }
  696. type JobStatusReport interface {
  697. Report()
  698. }
  699. var JobStatusReportTypeUnion = types.NewTypeUnion[JobStatusReport](
  700. (*TrainJobStatusReport)(nil),
  701. (*InferenceJobStatusReport)(nil),
  702. )
  703. var _ = serder.UseTypeUnionInternallyTagged(&JobStatusReportTypeUnion, "type")
  704. type JobStatusReportBase struct{}
  705. func (d *JobStatusReportBase) Report() {}
  706. type TrainJobStatusReport struct {
  707. serder.Metadata `union:"Train"`
  708. JobStatusReportBase
  709. Type string `json:"type"`
  710. TaskName string `json:"taskName"`
  711. TaskID string `json:"taskID"`
  712. Status bool `json:"status"`
  713. Message string `json:"message"`
  714. ClusterID ClusterID `json:"clusterID"`
  715. Output string `json:"output"`
  716. }
  717. type InferenceJobStatusReport struct {
  718. serder.Metadata `union:"Inference"`
  719. JobStatusReportBase
  720. Type string `json:"type"`
  721. TaskName string `json:"taskName"`
  722. TaskID string `json:"taskID"`
  723. Status bool `json:"status"`
  724. Message string `json:"message"`
  725. URL string `json:"url"`
  726. ID string `json:"id"`
  727. AdapterID string `json:"adapterId"`
  728. ClusterID ClusterID `json:"clusterId"`
  729. InstanceID string `json:"instanceId"`
  730. }