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.

types.ts 3.9 kB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * @Author: 赵伟
  3. * @Date: 2024-04-08 09:54:39
  4. * @Description: 定义全局类型,比如无关联的页面都需要要的类型
  5. */
  6. import { ExperimentStatus, TensorBoardStatus } from '@/enums';
  7. import type { Settings as LayoutSettings } from '@ant-design/pro-components';
  8. // 单点登录的客户端信息
  9. export type ClientInfo = {
  10. accessTokenUri: string;
  11. checkTokenUri: string;
  12. clientId: string;
  13. clientSecret: string;
  14. loginPage: string;
  15. logoutUri: string;
  16. redirectUri: string;
  17. userAuthorizationUri: string;
  18. };
  19. // 全局初始状态类型
  20. export type GlobalInitialState = {
  21. settings?: Partial<LayoutSettings>;
  22. currentUser?: API.CurrentUser;
  23. fetchUserInfo?: () => Promise<API.CurrentUser | undefined>;
  24. loading?: boolean;
  25. collapsed?: boolean;
  26. clientInfo?: ClientInfo;
  27. };
  28. export enum PipelineGlobalParamType {
  29. String = 1,
  30. Number = 2,
  31. Boolean = 3,
  32. }
  33. // 流水线全局参数
  34. export type PipelineGlobalParam = {
  35. param_name: string;
  36. description: string;
  37. param_type: PipelineGlobalParamType;
  38. param_value: number | string | boolean;
  39. is_sensitive: number;
  40. };
  41. // 实验实例
  42. export type ExperimentInstance = {
  43. id: number;
  44. experiment_id: number;
  45. workflow_id: number;
  46. create_time: string;
  47. finish_time: string;
  48. update_time: string;
  49. status: string;
  50. argo_ins_name: string;
  51. argo_ins_ns: string;
  52. nodes_result: {
  53. [key: string]: any;
  54. };
  55. node_status: string;
  56. nodes_status: string;
  57. global_param: PipelineGlobalParam[];
  58. tensorBoardStatus?: TensorBoardStatus;
  59. tensorboardUrl?: string;
  60. };
  61. // 流水线节点
  62. export type PipelineNodeModel = {
  63. id: string;
  64. experimentStatus: ExperimentStatus;
  65. label: string;
  66. experimentStartTime: string;
  67. experimentEndTime?: string | null;
  68. control_strategy: Record<string, PipelineNodeModelParameter>;
  69. in_parameters: Record<string, PipelineNodeModelParameter>;
  70. task_info: Record<string, PipelineNodeModelParameter>;
  71. out_parameters: Record<string, PipelineNodeModelParameter>;
  72. component_label: string;
  73. icon_path: string;
  74. workflowId?: string;
  75. message?: string;
  76. };
  77. // 流水线节点模型数据
  78. export type PipelineNodeModelParameter = {
  79. type: string;
  80. item_type: string;
  81. label: string;
  82. value: any;
  83. require?: number;
  84. visible: boolean;
  85. placeholder?: string;
  86. describe?: string;
  87. editable?: boolean;
  88. showValue?: any; // 前端显示用
  89. fromSelect?: boolean; // 前端显示用
  90. activeTab?: string; // ResourceSelectorModal tab
  91. expandedKeys?: string[]; // ResourceSelectorModal expandedKeys
  92. checkedKeys?: string[]; // ResourceSelectorModal checkedKeys
  93. };
  94. // 修改属性类型
  95. export type ChangePropertyType<T, K extends keyof T, NewType> = Omit<T, K> & { [P in K]: NewType };
  96. // 将属性名称首字母大写
  97. export type PascalCaseType<T> = {
  98. [K in keyof T as `${Capitalize<string & K>}`]: T[K];
  99. };
  100. // 将属性名称下划线转换为驼峰
  101. type ToCamelCase<S extends string> = S extends `${infer P}_${infer R}`
  102. ? `${P}${Capitalize<ToCamelCase<R>>}`
  103. : S;
  104. export type KeysToCamelCase<T> = {
  105. [K in keyof T as ToCamelCase<K & string>]: T[K];
  106. };
  107. // 序列化后的流水线节点
  108. export type PipelineNodeModelSerialize = PipelineNodeModel;
  109. // 资源规格
  110. export type ComputingResource = {
  111. id: number;
  112. computing_resource: string;
  113. description: string;
  114. standard: string;
  115. create_by: string;
  116. };
  117. // 实验运行节点状态
  118. export type NodeStatus = {
  119. id: string; // workflow Id
  120. displayName: string;
  121. name: string;
  122. phase: ExperimentStatus;
  123. startedAt: string;
  124. finishedAt: string;
  125. };
  126. // 应用响应
  127. export type AppResponse<T> = {
  128. code: number;
  129. msg: string;
  130. data: T;
  131. };
  132. // 上传文件的响应
  133. export type UploadFileRes = {
  134. fileName: string;
  135. fileSize: number;
  136. url: string;
  137. };
  138. // 定义一个类型,取一个类型的有些字段必须的,其它的是可选
  139. export type CustomPartial<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;