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

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