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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. nodes_status: string;
  51. global_param: PipelineGlobalParam[];
  52. tensorBoardStatus?: TensorBoardStatus;
  53. tensorboardUrl?: string;
  54. };
  55. // 流水线节点
  56. export type PipelineNodeModel = {
  57. id: string;
  58. experimentStatus: ExperimentStatus;
  59. label: string;
  60. experimentStartTime: string;
  61. experimentEndTime?: string | null;
  62. control_strategy: string;
  63. in_parameters: string;
  64. out_parameters: string;
  65. component_label: string;
  66. icon_path: string;
  67. workflowId?: string;
  68. message?: string;
  69. };
  70. // 流水线节点模型数据
  71. export type PipelineNodeModelParameter = {
  72. type: string;
  73. item_type: string;
  74. label: string;
  75. value: any;
  76. require?: number;
  77. placeholder?: string;
  78. describe?: string;
  79. fromSelect?: boolean;
  80. showValue?: any;
  81. editable?: number;
  82. activeTab?: string; // ResourceSelectorModal tab
  83. expandedKeys?: string[]; // ResourceSelectorModal expandedKeys
  84. checkedKeys?: string[]; // ResourceSelectorModal checkedKeys
  85. };
  86. // 修改属性类型
  87. export type ChangePropertyType<T, K extends keyof T, NewType> = Omit<T, K> & { [P in K]: NewType };
  88. // 将属性名称首字母大写
  89. export type PascalCaseType<T> = {
  90. [K in keyof T as `${Capitalize<string & K>}`]: T[K];
  91. };
  92. // 将属性名称下划线转换为驼峰
  93. type ToCamelCase<S extends string> = S extends `${infer P}_${infer R}`
  94. ? `${P}${Capitalize<ToCamelCase<R>>}`
  95. : S;
  96. export type KeysToCamelCase<T> = {
  97. [K in keyof T as ToCamelCase<K & string>]: T[K];
  98. };
  99. // 序列化后的流水线节点
  100. export type PipelineNodeModelSerialize = Omit<
  101. PipelineNodeModel,
  102. 'control_strategy' | 'in_parameters' | 'out_parameters'
  103. > & {
  104. control_strategy: Record<string, PipelineNodeModelParameter>;
  105. in_parameters: Record<string, PipelineNodeModelParameter>;
  106. out_parameters: Record<string, PipelineNodeModelParameter>;
  107. };
  108. // 资源规格
  109. export type ComputingResource = {
  110. id: number;
  111. computing_resource: string;
  112. description: string;
  113. standard: string;
  114. create_by: string;
  115. };
  116. // 实验运行节点状态
  117. export type NodeStatus = {
  118. id: string; // workflow Id
  119. displayName: string;
  120. name: string;
  121. phase: ExperimentStatus;
  122. startedAt: string;
  123. finishedAt: string;
  124. };
  125. // 应用响应
  126. export type AppResponse<T> = {
  127. code: number;
  128. msg: string;
  129. data: T;
  130. };
  131. // 上传文件的响应
  132. export type UploadFileRes = {
  133. fileName: string;
  134. fileSize: number;
  135. url: string;
  136. };