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

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. };
  69. // 流水线节点模型数据
  70. export type PipelineNodeModelParameter = {
  71. type: string;
  72. item_type: string;
  73. label: string;
  74. value: any;
  75. require?: number;
  76. placeholder?: string;
  77. describe?: string;
  78. fromSelect?: boolean;
  79. showValue?: any;
  80. editable?: number;
  81. activeTab?: string; // ResourceSelectorModal tab
  82. expandedKeys?: string[]; // ResourceSelectorModal expandedKeys
  83. checkedKeys?: string[]; // ResourceSelectorModal checkedKeys
  84. };
  85. // 修改属性类型
  86. export type ChangePropertyType<T, K extends keyof T, NewType> = Omit<T, K> & { [P in K]: NewType };
  87. // 将属性名称首字母大写
  88. export type PascalCaseType<T> = {
  89. [K in keyof T as `${Capitalize<string & K>}`]: T[K];
  90. };
  91. // 将属性名称下划线转换为驼峰
  92. type ToCamelCase<S extends string> = S extends `${infer P}_${infer R}`
  93. ? `${P}${Capitalize<ToCamelCase<R>>}`
  94. : S;
  95. export type KeysToCamelCase<T> = {
  96. [K in keyof T as ToCamelCase<K & string>]: T[K];
  97. };
  98. // 序列化后的流水线节点
  99. export type PipelineNodeModelSerialize = Omit<
  100. PipelineNodeModel,
  101. 'control_strategy' | 'in_parameters' | 'out_parameters'
  102. > & {
  103. control_strategy: Record<string, PipelineNodeModelParameter>;
  104. in_parameters: Record<string, PipelineNodeModelParameter>;
  105. out_parameters: Record<string, PipelineNodeModelParameter>;
  106. };
  107. // 资源规格
  108. export type ComputingResource = {
  109. id: number;
  110. computing_resource: string;
  111. description: string;
  112. standard: string;
  113. create_by: string;
  114. };
  115. // 实验运行节点状态
  116. export type NodeStatus = {
  117. id: string; // workflow Id
  118. displayName: string;
  119. name: string;
  120. phase: ExperimentStatus;
  121. startedAt: string;
  122. finishedAt: string;
  123. };