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

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. // 流水线全局参数
  29. export type PipelineGlobalParam = {
  30. param_name: string;
  31. description: string;
  32. param_type: number;
  33. param_value: number | string | boolean;
  34. is_sensitive: number;
  35. };
  36. // 实验实例
  37. export type ExperimentInstance = {
  38. id: number;
  39. experiment_id: number;
  40. workflow_id: number;
  41. create_time: string;
  42. finish_time: string;
  43. update_time: string;
  44. status: string;
  45. argo_ins_name: string;
  46. argo_ins_ns: string;
  47. nodes_result: {
  48. [key: string]: any;
  49. };
  50. node_status: string;
  51. nodes_status: string;
  52. global_param: PipelineGlobalParam[];
  53. tensorBoardStatus?: TensorBoardStatus;
  54. tensorboardUrl?: string;
  55. };
  56. // 流水线节点
  57. export type PipelineNodeModel = {
  58. id: string;
  59. experimentStatus: ExperimentStatus;
  60. label: string;
  61. experimentStartTime: string;
  62. experimentEndTime?: string | null;
  63. control_strategy: string;
  64. in_parameters: string;
  65. out_parameters: string;
  66. component_label: string;
  67. icon_path: string;
  68. workflowId?: string;
  69. message?: string;
  70. };
  71. // 流水线节点模型数据
  72. export type PipelineNodeModelParameter = {
  73. type: string;
  74. item_type: string;
  75. label: string;
  76. value: any;
  77. require?: number;
  78. placeholder?: string;
  79. describe?: string;
  80. fromSelect?: boolean;
  81. showValue?: any;
  82. editable?: number;
  83. activeTab?: string; // ResourceSelectorModal tab
  84. expandedKeys?: string[]; // ResourceSelectorModal expandedKeys
  85. checkedKeys?: string[]; // ResourceSelectorModal checkedKeys
  86. };
  87. // 修改属性类型
  88. export type ChangePropertyType<T, K extends keyof T, NewType> = Omit<T, K> & { [P in K]: NewType };
  89. // 将属性名称首字母大写
  90. export type PascalCaseType<T> = {
  91. [K in keyof T as `${Capitalize<string & K>}`]: T[K];
  92. };
  93. // 将属性名称下划线转换为驼峰
  94. type ToCamelCase<S extends string> = S extends `${infer P}_${infer R}`
  95. ? `${P}${Capitalize<ToCamelCase<R>>}`
  96. : S;
  97. export type KeysToCamelCase<T> = {
  98. [K in keyof T as ToCamelCase<K & string>]: T[K];
  99. };
  100. // 序列化后的流水线节点
  101. export type PipelineNodeModelSerialize = Omit<
  102. PipelineNodeModel,
  103. 'control_strategy' | 'in_parameters' | 'out_parameters'
  104. > & {
  105. control_strategy: Record<string, PipelineNodeModelParameter>;
  106. in_parameters: Record<string, PipelineNodeModelParameter>;
  107. out_parameters: Record<string, PipelineNodeModelParameter>;
  108. };
  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. };