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 22 kB

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