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