Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c6e1839fe |
@@ -97,38 +97,6 @@ const handleBChange = (b) => {
|
||||
};
|
||||
```
|
||||
|
||||
## 4. Controlled input with derived fields
|
||||
|
||||
When a controlled field's value comes from **both** user input and a programmatic default (e.g. a percentage picked on a slider, and a default seeded on select / mode-switch), funnel both through **one commit function** — don't duplicate "write field + recompute derived" per call site.
|
||||
|
||||
- The `Form.Item`-bound input's `onChange(value)` forwards the value to the commit fn (the field is antd-bound, but pass the value explicitly so the default path can reuse the same fn instead of reading the store).
|
||||
- Seed defaults by calling the **same** commit fn with the computed value.
|
||||
- Separate the **commit action** (write field + recompute dependents) from the **render-derive** (read the field → recompute dependents). Keeping the derive standalone lets it re-run on reload/edit where there's no user event.
|
||||
|
||||
```ts
|
||||
// commit action — slider onChange AND default both call this
|
||||
const commitRatio = (value: number) => {
|
||||
form.setFieldsValue({ spec: { resources: { ratio: value, cores: 100 } } });
|
||||
rescaleDerived(); // reads ratio from the form, sets the disabled cpu/ram
|
||||
};
|
||||
|
||||
// render-derive — also called from the edit/reload effect
|
||||
const rescaleDerived = () => {
|
||||
const ratio = form.getFieldValue(['spec', 'resources', 'ratio']);
|
||||
form.setFieldsValue({
|
||||
spec: {
|
||||
resources: {
|
||||
cpu: floorScale(unit.cpu, ratio),
|
||||
ram: floorScale(unit.ram, ratio)
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// default seeding reuses the commit fn — one path, not a second copy
|
||||
const applyDefaults = (item) => commitRatio(Math.min(10, item.maxRatio) || 10);
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- Module/file structure for forms lives in the **create-crud-page** skill (section 3).
|
||||
|
||||
@@ -124,24 +124,13 @@ Always check `@gpustack/core-ui` first. Frequently reused:
|
||||
- **Form fields**: `BaseSelect`, `Input` (labeled).
|
||||
- **Text overflow**: `AutoTooltip`.
|
||||
- **Icons**: `IconFont`.
|
||||
- **Tags & status** (4 variants): see the section below.
|
||||
- **Status display** (success/failed/processing/warning): `StatusTag`.
|
||||
- **Permission-gated visibility**: `Access` / `useAccess`.
|
||||
- **Request hooks**: `useRequest` / `useQueryData` / `useQueryDataList`.
|
||||
- **Table data fetching**: `useTableFetch`.
|
||||
- **Submit guard** (prevent double-submit): `useSubmitLock`.
|
||||
- **Tabbed forms**: `ScrollSpyTabs`.
|
||||
|
||||
# Tags & status indicators
|
||||
|
||||
Four core-ui components cover tag/status display in tables and lists. Pick by **what the value means**, not by how it looks — don't reach for a generic antd `Tag`:
|
||||
|
||||
- **`StatusTag`** — semantic status with a **dynamic message/detail** (tooltip, download, extra content). Use when a row's status carries variable text, e.g. a failed job with an error message. Colors come from `StatusColorMap` (error/warning/transitioning/success/inactive).
|
||||
- **`StatusDot`** — colored dot + short label, **no message**. Use for a plain status/type cell where the value is a fixed enum (e.g. an event-type or log column). Same `StatusColorMap` palette; `inactive` dot is quaternary. If the status needs dynamic text, use `StatusTag` instead.
|
||||
- **`ThemeTag`** — a **standalone category label** (independent content, e.g. a permission scope or a model name). Default neutral; wraps antd `Tag`.
|
||||
- **`TextAttribute`** — a small neutral pill that is a **subordinate annotation following a primary text** (e.g. `key-name [custom]`), not a standalone tag. Manages its own leading margin. Two variants: `filled` (default) and `outlined`. Ref the name column in `src/pages/api-keys/hooks/use-keys-columns.tsx`.
|
||||
|
||||
Rule of thumb: semantic + dynamic text → `StatusTag`; semantic + fixed enum → `StatusDot`; independent category → `ThemeTag`; annotation of nearby text → `TextAttribute`.
|
||||
|
||||
# Dynamic add-item form fields
|
||||
|
||||
When building a form, select the add-item component from the **shape of the field's data** (its schema). Match the schema, don't hand-roll a list UI:
|
||||
|
||||
@@ -211,16 +211,6 @@ const baseRoutes = [
|
||||
defaultIcon: 'icon-cloud-outlined',
|
||||
component: './gpu-service/instances'
|
||||
},
|
||||
{
|
||||
name: 'instanceTypes',
|
||||
path: '/gpu-service/instance-types',
|
||||
key: 'gpuServiceInstanceTypes',
|
||||
icon: 'icon-outline-gpu',
|
||||
access: 'canSeeOrgAdmin',
|
||||
selectedIcon: 'icon-filled-gpu',
|
||||
defaultIcon: 'icon-outline-gpu',
|
||||
component: './gpu-service/instance-types'
|
||||
},
|
||||
{
|
||||
name: 'templates',
|
||||
path: '/gpu-service/templates',
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
"@ant-design/pro-components": "3.1.0-0",
|
||||
"@antv/g6": "^5.0.51",
|
||||
"@braintree/sanitize-url": "^7.1.1",
|
||||
"@gpustack/core-ui": "^1.0.42",
|
||||
"@gpustack/core-ui": "^1.0.39",
|
||||
"@huggingface/gguf": "^0.1.7",
|
||||
"@huggingface/hub": "^0.15.1",
|
||||
"@huggingface/tasks": "^0.11.6",
|
||||
|
||||
Generated
+5
-5
@@ -24,8 +24,8 @@ importers:
|
||||
specifier: ^7.1.1
|
||||
version: 7.1.2
|
||||
'@gpustack/core-ui':
|
||||
specifier: ^1.0.42
|
||||
version: 1.0.42(czdvzceysqw7iv6pct2ucnb23e)
|
||||
specifier: ^1.0.39
|
||||
version: 1.0.39(czdvzceysqw7iv6pct2ucnb23e)
|
||||
'@huggingface/gguf':
|
||||
specifier: ^0.1.7
|
||||
version: 0.1.18
|
||||
@@ -1481,8 +1481,8 @@ packages:
|
||||
resolution: {integrity: sha512-KWk80UPIzPmUg+P0rKh6TqspRw0G6eux1PuJr+zz47ftMaZ9QDwbGzHZbtzWkl5hgayM/qrKRutllRC7D/vVXQ==, tarball: https://registry.npmjs.org/@formatjs/intl-utils/-/intl-utils-2.3.0.tgz}
|
||||
deprecated: the package is rather renamed to @formatjs/ecma-abstract with some changes in functionality (primarily selectUnit is removed and we don't plan to make any further changes to this package
|
||||
|
||||
'@gpustack/core-ui@1.0.42':
|
||||
resolution: {integrity: sha512-upMClTHU+xAqd8dlx0w1S9XWHlog5g1hcOCulTk2rmMXqgl66QHfqhEFhJnWIGe1xc8tEj6rW3r5Sirif+qswA==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.42.tgz}
|
||||
'@gpustack/core-ui@1.0.39':
|
||||
resolution: {integrity: sha512-6NS0TDkBFHK6RipfvLwvDnLZlAoa/yFbHV+xeERAnUb+4t0mDyIQFqvYAeDgrUW/JIZ6WScrm31FDZe2sKiuaw==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.39.tgz}
|
||||
peerDependencies:
|
||||
'@ant-design/icons': ^6.1.0
|
||||
'@ant-design/pro-components': 3.1.0-0
|
||||
@@ -10802,7 +10802,7 @@ snapshots:
|
||||
|
||||
'@formatjs/intl-utils@2.3.0': {}
|
||||
|
||||
'@gpustack/core-ui@1.0.42(czdvzceysqw7iv6pct2ucnb23e)':
|
||||
'@gpustack/core-ui@1.0.39(czdvzceysqw7iv6pct2ucnb23e)':
|
||||
dependencies:
|
||||
'@ant-design/icons': 6.2.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
'@ant-design/pro-components': 3.1.0-0(antd@6.3.7(date-fns@2.30.0)(moment@2.30.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
.ant-alert-with-description .ant-alert-title {
|
||||
line-height: 1;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
@import './table.less';
|
||||
@import './alert.less';
|
||||
|
||||
.m-b-20 {
|
||||
margin-bottom: 20px;
|
||||
|
||||
@@ -43,10 +43,6 @@ export default {
|
||||
DatePicker: {
|
||||
fontSizeLG: 14
|
||||
},
|
||||
Alert: {
|
||||
withDescriptionPadding: '12px 16px',
|
||||
withDescriptionIconSize: 18
|
||||
},
|
||||
Menu: {
|
||||
iconSize: 16,
|
||||
iconMarginInlineEnd: 12,
|
||||
|
||||
@@ -26,8 +26,8 @@ export default {
|
||||
cellPaddingInline: 16,
|
||||
cellPaddingBlock: 6,
|
||||
cellFontSize: 14,
|
||||
rowSelectedHoverBg: 'rgb(247 247 247)',
|
||||
rowHoverBg: 'rgb(247 247 247)',
|
||||
rowSelectedHoverBg: 'rgb(249 249 249)',
|
||||
rowHoverBg: 'rgb(249 249 249)',
|
||||
rowSelectedBg: 'transparent',
|
||||
headerSortActiveBg: 'transparent',
|
||||
headerSortHoverBg: 'transparent',
|
||||
@@ -47,13 +47,6 @@ export default {
|
||||
DatePicker: {
|
||||
fontSizeLG: 14
|
||||
},
|
||||
Alert: {
|
||||
withDescriptionPadding: '12px 16px',
|
||||
withDescriptionIconSize: 18
|
||||
},
|
||||
Card: {
|
||||
headerHeight: 50
|
||||
},
|
||||
Menu: {
|
||||
iconSize: 16,
|
||||
iconMarginInlineEnd: 12,
|
||||
@@ -123,7 +116,7 @@ export default {
|
||||
borderRadiusLG: 6,
|
||||
borderRadius: 4,
|
||||
borderRadiusSM: 3,
|
||||
colorBgContainer: '#fdfdfd',
|
||||
colorBgContainer: '#fff',
|
||||
fontSize: 14,
|
||||
motion: true
|
||||
}
|
||||
|
||||
+15
-1
@@ -21,6 +21,8 @@ html {
|
||||
--color-fill-sider: #f4f5f4;
|
||||
--color-bg-1: #f4f5f4;
|
||||
--color-scroll-bg: #d9d9d9;
|
||||
--color-fill-2: #fff;
|
||||
--color-fill-3: #f3f6fa;
|
||||
--color-logs-bg: #1e1e1e;
|
||||
--color-logs-text: #d4d4d4;
|
||||
--layout-content-blockpadding: 24px;
|
||||
@@ -74,6 +76,7 @@ html {
|
||||
--ant-rate-star-color: #fadb14;
|
||||
--color-fill-spin-bg: rgba(255, 255, 255, 15%);
|
||||
--width-tooltip-max: 420px;
|
||||
--color-bg-tooltip: '#fff';
|
||||
--color-modal-content-bg: rgba(255, 255, 255, 90%);
|
||||
--color-modal-box-shadow: 0 4px 16px rgba(0, 0, 0, 10%);
|
||||
--color-spotlight-bg: rgba(255, 255, 255, 100%);
|
||||
@@ -98,6 +101,7 @@ html[data-theme='realDark'] {
|
||||
--color-editor-dark: #00101f;
|
||||
--color-editor-light: #fafafa;
|
||||
--color-fill-spin-bg: rgba(55, 55, 55, 50%);
|
||||
--color-bg-tooltip: #424242;
|
||||
--color-editor-header-bg: #292929;
|
||||
--color-progress-text: rgba(255, 255, 255, 80%);
|
||||
--color-modal-content-bg: #1f1f1f;
|
||||
@@ -112,9 +116,19 @@ html[data-theme='realDark'] {
|
||||
.ant-result-image {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.ant-pro-page-container-affix .ant-pro-page-container-warp {
|
||||
background-color: #292929 !important;
|
||||
transition: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
html[data-theme='light'] {
|
||||
.ant-pro-page-container-affix .ant-pro-page-container-warp {
|
||||
background-color: #fff !important;
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
background-color: #f4f5f6;
|
||||
}
|
||||
|
||||
@@ -197,7 +211,7 @@ body {
|
||||
|
||||
tr > td {
|
||||
border-bottom: none;
|
||||
height: var(--seal-table-row-min-height);
|
||||
height: 68px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,34 +119,12 @@ export default {
|
||||
'No available GPU resources, please choose another instance type.',
|
||||
'gpuservice.instance.gpuCount.zero':
|
||||
'CPU-only setup for environment preparation.',
|
||||
'gpuservice.instance.mode.whole': 'Full GPU',
|
||||
'gpuservice.instance.mode.sliced': 'By Ratio',
|
||||
'gpuservice.instance.slice.memoryPercentage': 'VRAM Percentage (%)',
|
||||
'gpuservice.instance.slice.fullCores': '100% Compute',
|
||||
'gpuservice.instance.slice.percentage.required':
|
||||
'Please select or enter a percentage',
|
||||
'gpuservice.instance.slice.percentage.max':
|
||||
'The ratio must be between 1% and {count}%',
|
||||
'gpuservice.instance.stock': 'Stock',
|
||||
'gpuservice.instance.sliced': 'Sliced',
|
||||
'gpuservice.instance.sliceable': 'Sliceable',
|
||||
'gpuservice.instance.memory': 'VRAM',
|
||||
'gpuservice.instance.ram': 'RAM',
|
||||
'gpuservice.instance.os': 'OS',
|
||||
'gpuservice.instance.arch': 'Arch',
|
||||
'gpuservice.instanceType': 'GPU Instance Type',
|
||||
'gpuservice.instanceType.add': 'Add Instance Type',
|
||||
'gpuservice.instanceType.flavor': 'Flavor',
|
||||
'gpuservice.instanceType.flavor.required': 'Please select an instance type flavor',
|
||||
'gpuservice.instanceType.product': 'Product',
|
||||
'gpuservice.instanceType.unitCpu': 'Unit CPU',
|
||||
'gpuservice.instanceType.unitCpu.tip': 'CPU allocated per GPU',
|
||||
'gpuservice.instanceType.unitRam': 'Unit RAM',
|
||||
'gpuservice.instanceType.unitRam.tip': 'RAM allocated per GPU',
|
||||
'gpuservice.instanceType.localStorage': 'Storage',
|
||||
'gpuservice.instanceType.localStorage.tip': 'Maximum available disk',
|
||||
'gpuservice.instanceType.notSliceable': 'Not Sliceable',
|
||||
'gpuservice.instanceType.filter.name': 'Search by name',
|
||||
'gpuservice.instance.disk': 'Disk',
|
||||
'gpuservice.table.count': 'Count',
|
||||
'gpuservice.instance.disk.system': 'System Disk',
|
||||
|
||||
@@ -47,7 +47,6 @@ export default {
|
||||
'menu.models.backendsList': 'Inference Backends',
|
||||
'menu.gpuService': 'GPU Service',
|
||||
'menu.gpuService.instances': 'GPU Instances',
|
||||
'menu.gpuService.instanceTypes': 'Instance Types',
|
||||
'menu.gpuService.templates': 'Instance Templates',
|
||||
'menu.gpuService.storage': 'Storage',
|
||||
'menu.gpuService.storageTypes': 'Storage Types',
|
||||
|
||||
@@ -68,10 +68,6 @@ export default {
|
||||
'noresult.gpuservice.storage.title': 'No Storage',
|
||||
'noresult.gpuservice.storage.subTitle': 'No storage has been added yet.',
|
||||
'noresult.gpuservice.storage.nofound': 'No matching storage found.',
|
||||
'noresult.gpuservice.instanceType.title': 'No Instance Types',
|
||||
'noresult.gpuservice.instanceType.subTitle':
|
||||
'Create an instance type to get started',
|
||||
'noresult.gpuservice.instanceType.nofound': 'No instance types found',
|
||||
'noresult.gpuservice.storageType.title': 'No Storage Types',
|
||||
'noresult.gpuservice.storageType.subTitle':
|
||||
'No storage types have been added yet.',
|
||||
|
||||
@@ -118,34 +118,12 @@ export default {
|
||||
'gpuservice.instance.gpuCount.noAvailable':
|
||||
'利用可能な GPU リソースがありません。別のインスタンスタイプを選択してください。',
|
||||
'gpuservice.instance.gpuCount.zero': 'CPU のみを使用し、環境準備用です。',
|
||||
'gpuservice.instance.mode.whole': 'GPU 全体',
|
||||
'gpuservice.instance.mode.sliced': '比率で',
|
||||
'gpuservice.instance.slice.memoryPercentage': 'VRAM の割合(%)',
|
||||
'gpuservice.instance.slice.fullCores': '100% コンピュート',
|
||||
'gpuservice.instance.slice.percentage.required':
|
||||
'パーセンテージを選択または入力してください',
|
||||
'gpuservice.instance.slice.percentage.max':
|
||||
'比率は 1% から {count}% の間で指定してください',
|
||||
'gpuservice.instance.stock': '在庫',
|
||||
'gpuservice.instance.sliced': '分割',
|
||||
'gpuservice.instance.sliceable': '分割可能',
|
||||
'gpuservice.instance.memory': 'VRAM',
|
||||
'gpuservice.instance.ram': 'RAM',
|
||||
'gpuservice.instance.os': 'OS',
|
||||
'gpuservice.instance.arch': 'アーキテクチャ',
|
||||
'gpuservice.instanceType': 'GPU Instance Type',
|
||||
'gpuservice.instanceType.add': 'Add Instance Type',
|
||||
'gpuservice.instanceType.flavor': 'Flavor',
|
||||
'gpuservice.instanceType.flavor.required': 'Please select an instance type flavor',
|
||||
'gpuservice.instanceType.product': 'Product',
|
||||
'gpuservice.instanceType.unitCpu': 'Unit CPU',
|
||||
'gpuservice.instanceType.unitCpu.tip': 'CPU allocated per GPU',
|
||||
'gpuservice.instanceType.unitRam': 'Unit RAM',
|
||||
'gpuservice.instanceType.unitRam.tip': 'RAM allocated per GPU',
|
||||
'gpuservice.instanceType.localStorage': 'Storage',
|
||||
'gpuservice.instanceType.localStorage.tip': 'Maximum available disk',
|
||||
'gpuservice.instanceType.notSliceable': 'Not Sliceable',
|
||||
'gpuservice.instanceType.filter.name': 'Search by name',
|
||||
'gpuservice.instance.disk': 'ディスク',
|
||||
'gpuservice.table.count': '数量',
|
||||
'gpuservice.instance.disk.system': 'システムディスク',
|
||||
|
||||
@@ -47,7 +47,6 @@ export default {
|
||||
'menu.models.backendsList': 'Inference Backends',
|
||||
'menu.gpuService': 'GPU Service',
|
||||
'menu.gpuService.instances': 'GPU Instances',
|
||||
'menu.gpuService.instanceTypes': 'Instance Types',
|
||||
'menu.gpuService.templates': 'Instance Templates',
|
||||
'menu.gpuService.storage': 'Storage',
|
||||
'menu.gpuService.storageTypes': 'ストレージタイプ',
|
||||
|
||||
@@ -70,10 +70,6 @@ export default {
|
||||
'noresult.gpuservice.storage.subTitle':
|
||||
'ストレージはまだ追加されていません。',
|
||||
'noresult.gpuservice.storage.nofound': '一致するストレージが見つかりません。',
|
||||
'noresult.gpuservice.instanceType.title': 'No Instance Types',
|
||||
'noresult.gpuservice.instanceType.subTitle':
|
||||
'Create an instance type to get started',
|
||||
'noresult.gpuservice.instanceType.nofound': 'No instance types found',
|
||||
'noresult.gpuservice.storageType.title': 'ストレージタイプなし',
|
||||
'noresult.gpuservice.storageType.subTitle':
|
||||
'ストレージタイプはまだ追加されていません。',
|
||||
|
||||
@@ -117,34 +117,12 @@ export default {
|
||||
'gpuservice.instance.gpuCount.noAvailable':
|
||||
'Нет доступных ресурсов GPU, выберите другой тип экземпляра.',
|
||||
'gpuservice.instance.gpuCount.zero': 'Только CPU, для подготовки окружения.',
|
||||
'gpuservice.instance.mode.whole': 'Весь GPU',
|
||||
'gpuservice.instance.mode.sliced': 'По доле',
|
||||
'gpuservice.instance.slice.memoryPercentage': 'Доля VRAM (%)',
|
||||
'gpuservice.instance.slice.fullCores': '100% вычислений',
|
||||
'gpuservice.instance.slice.percentage.required':
|
||||
'Выберите или введите процент',
|
||||
'gpuservice.instance.slice.percentage.max':
|
||||
'Доля должна быть от 1% до {count}%',
|
||||
'gpuservice.instance.stock': 'Остаток',
|
||||
'gpuservice.instance.sliced': 'Разделено',
|
||||
'gpuservice.instance.sliceable': 'Делимый',
|
||||
'gpuservice.instance.memory': 'VRAM',
|
||||
'gpuservice.instance.ram': 'RAM',
|
||||
'gpuservice.instance.os': 'ОС',
|
||||
'gpuservice.instance.arch': 'Архитектура',
|
||||
'gpuservice.instanceType': 'GPU Instance Type',
|
||||
'gpuservice.instanceType.add': 'Add Instance Type',
|
||||
'gpuservice.instanceType.flavor': 'Flavor',
|
||||
'gpuservice.instanceType.flavor.required': 'Please select an instance type flavor',
|
||||
'gpuservice.instanceType.product': 'Product',
|
||||
'gpuservice.instanceType.unitCpu': 'Unit CPU',
|
||||
'gpuservice.instanceType.unitCpu.tip': 'CPU allocated per GPU',
|
||||
'gpuservice.instanceType.unitRam': 'Unit RAM',
|
||||
'gpuservice.instanceType.unitRam.tip': 'RAM allocated per GPU',
|
||||
'gpuservice.instanceType.localStorage': 'Storage',
|
||||
'gpuservice.instanceType.localStorage.tip': 'Maximum available disk',
|
||||
'gpuservice.instanceType.notSliceable': 'Not Sliceable',
|
||||
'gpuservice.instanceType.filter.name': 'Search by name',
|
||||
'gpuservice.instance.disk': 'Диск',
|
||||
'gpuservice.table.count': 'Количество',
|
||||
'gpuservice.instance.disk.system': 'Системный диск',
|
||||
|
||||
@@ -47,7 +47,6 @@ export default {
|
||||
'menu.settings': 'Settings',
|
||||
'menu.gpuService': 'GPU Service',
|
||||
'menu.gpuService.instances': 'GPU Instances',
|
||||
'menu.gpuService.instanceTypes': 'Instance Types',
|
||||
'menu.gpuService.templates': 'Instance Templates',
|
||||
'menu.gpuService.storage': 'Storage',
|
||||
'menu.gpuService.storageTypes': 'Типы хранилищ',
|
||||
|
||||
@@ -69,10 +69,6 @@ export default {
|
||||
'noresult.gpuservice.storage.title': 'Нет хранилищ',
|
||||
'noresult.gpuservice.storage.subTitle': 'Хранилища ещё не добавлены.',
|
||||
'noresult.gpuservice.storage.nofound': 'Подходящие хранилища не найдены.',
|
||||
'noresult.gpuservice.instanceType.title': 'No Instance Types',
|
||||
'noresult.gpuservice.instanceType.subTitle':
|
||||
'Create an instance type to get started',
|
||||
'noresult.gpuservice.instanceType.nofound': 'No instance types found',
|
||||
'noresult.gpuservice.storageType.title': 'Нет типов хранилищ',
|
||||
'noresult.gpuservice.storageType.subTitle': 'Типы хранилищ ещё не добавлены.',
|
||||
'noresult.gpuservice.storageType.nofound':
|
||||
|
||||
@@ -113,34 +113,12 @@ export default {
|
||||
'gpuservice.instance.gpuCount.noAvailable':
|
||||
'Kullanılabilir GPU kaynağı yok, lütfen başka bir örnek türü seçin.',
|
||||
'gpuservice.instance.gpuCount.zero': 'Yalnızca CPU, ortam hazırlığı için.',
|
||||
'gpuservice.instance.mode.whole': 'Tam GPU',
|
||||
'gpuservice.instance.mode.sliced': 'Orana Göre',
|
||||
'gpuservice.instance.slice.memoryPercentage': 'VRAM Yüzdesi (%)',
|
||||
'gpuservice.instance.slice.fullCores': '%100 İşlem Gücü',
|
||||
'gpuservice.instance.slice.percentage.required':
|
||||
'Lütfen bir yüzde seçin veya girin',
|
||||
'gpuservice.instance.slice.percentage.max':
|
||||
'Oran %1 ile %{count} arasında olmalıdır',
|
||||
'gpuservice.instance.stock': 'Stok',
|
||||
'gpuservice.instance.sliced': 'Bölünmüş',
|
||||
'gpuservice.instance.sliceable': 'Bölünebilir',
|
||||
'gpuservice.instance.memory': 'VRAM',
|
||||
'gpuservice.instance.ram': 'RAM',
|
||||
'gpuservice.instance.os': 'OS',
|
||||
'gpuservice.instance.arch': 'Mimari',
|
||||
'gpuservice.instanceType': 'GPU Instance Type',
|
||||
'gpuservice.instanceType.add': 'Add Instance Type',
|
||||
'gpuservice.instanceType.flavor': 'Flavor',
|
||||
'gpuservice.instanceType.flavor.required': 'Please select an instance type flavor',
|
||||
'gpuservice.instanceType.product': 'Product',
|
||||
'gpuservice.instanceType.unitCpu': 'Unit CPU',
|
||||
'gpuservice.instanceType.unitCpu.tip': 'CPU allocated per GPU',
|
||||
'gpuservice.instanceType.unitRam': 'Unit RAM',
|
||||
'gpuservice.instanceType.unitRam.tip': 'RAM allocated per GPU',
|
||||
'gpuservice.instanceType.localStorage': 'Storage',
|
||||
'gpuservice.instanceType.localStorage.tip': 'Maximum available disk',
|
||||
'gpuservice.instanceType.notSliceable': 'Not Sliceable',
|
||||
'gpuservice.instanceType.filter.name': 'Search by name',
|
||||
'gpuservice.instance.disk': 'Disk',
|
||||
'gpuservice.table.count': 'Sayı',
|
||||
'gpuservice.instance.disk.system': 'Sistem Diski',
|
||||
|
||||
@@ -47,7 +47,6 @@ export default {
|
||||
'menu.settings': 'Settings',
|
||||
'menu.gpuService': 'GPU Service',
|
||||
'menu.gpuService.instances': 'GPU Instances',
|
||||
'menu.gpuService.instanceTypes': 'Instance Types',
|
||||
'menu.gpuService.templates': 'Instance Templates',
|
||||
'menu.gpuService.storage': 'Storage',
|
||||
'menu.gpuService.storageTypes': 'Depolama Türleri',
|
||||
|
||||
@@ -67,10 +67,6 @@ export default {
|
||||
'noresult.gpuservice.storage.title': 'Depolama Yok',
|
||||
'noresult.gpuservice.storage.subTitle': 'Henüz depolama eklenmedi.',
|
||||
'noresult.gpuservice.storage.nofound': 'Eşleşen depolama bulunamadı.',
|
||||
'noresult.gpuservice.instanceType.title': 'No Instance Types',
|
||||
'noresult.gpuservice.instanceType.subTitle':
|
||||
'Create an instance type to get started',
|
||||
'noresult.gpuservice.instanceType.nofound': 'No instance types found',
|
||||
'noresult.gpuservice.storageType.title': 'Depolama Türü Yok',
|
||||
'noresult.gpuservice.storageType.subTitle': 'Henüz depolama türü eklenmedi.',
|
||||
'noresult.gpuservice.storageType.nofound':
|
||||
|
||||
@@ -108,32 +108,12 @@ export default {
|
||||
'gpuservice.instance.gpuCount.noAvailable':
|
||||
'没有可用的 GPU 资源,请选择其他实例类型。',
|
||||
'gpuservice.instance.gpuCount.zero': '仅使用 CPU,用于环境准备。',
|
||||
'gpuservice.instance.mode.whole': '整卡',
|
||||
'gpuservice.instance.mode.sliced': '按比例',
|
||||
'gpuservice.instance.slice.memoryPercentage': '显存占比(%)',
|
||||
'gpuservice.instance.slice.fullCores': '100% 算力',
|
||||
'gpuservice.instance.slice.percentage.required': '请选择或输入百分比',
|
||||
'gpuservice.instance.slice.percentage.max': '比例需在 1% 到 {count}% 之间',
|
||||
'gpuservice.instance.stock': '库存',
|
||||
'gpuservice.instance.sliced': '切分',
|
||||
'gpuservice.instance.sliceable': '可切分',
|
||||
'gpuservice.instance.memory': '显存',
|
||||
'gpuservice.instance.ram': '内存',
|
||||
'gpuservice.instance.os': '系统',
|
||||
'gpuservice.instance.arch': '架构',
|
||||
'gpuservice.instanceType': 'GPU 实例类型',
|
||||
'gpuservice.instanceType.add': '添加实例类型',
|
||||
'gpuservice.instanceType.flavor': '规格',
|
||||
'gpuservice.instanceType.flavor.required': '请选择实例类型规格',
|
||||
'gpuservice.instanceType.product': '商品',
|
||||
'gpuservice.instanceType.unitCpu': '单位 CPU',
|
||||
'gpuservice.instanceType.unitCpu.tip': '每 GPU 对应多少 CPU',
|
||||
'gpuservice.instanceType.unitRam': '单位内存',
|
||||
'gpuservice.instanceType.unitRam.tip': '每 GPU 对应多少内存',
|
||||
'gpuservice.instanceType.localStorage': '存储',
|
||||
'gpuservice.instanceType.localStorage.tip': '最大可用磁盘',
|
||||
'gpuservice.instanceType.notSliceable': '不可切分',
|
||||
'gpuservice.instanceType.filter.name': '按名称搜索',
|
||||
'gpuservice.instance.disk': '磁盘',
|
||||
'gpuservice.table.count': '数量',
|
||||
'gpuservice.instance.disk.system': '系统盘',
|
||||
|
||||
@@ -47,7 +47,6 @@ export default {
|
||||
'menu.models.backendsList': '推理后端',
|
||||
'menu.gpuService': 'GPU 服务',
|
||||
'menu.gpuService.instances': 'GPU 实例',
|
||||
'menu.gpuService.instanceTypes': '实例类型',
|
||||
'menu.gpuService.templates': '实例模板',
|
||||
'menu.gpuService.storage': '存储',
|
||||
'menu.gpuService.storageTypes': '存储类型',
|
||||
|
||||
@@ -63,9 +63,6 @@ export default {
|
||||
'noresult.gpuservice.storage.title': '暂无存储',
|
||||
'noresult.gpuservice.storage.subTitle': '尚未添加任何存储。',
|
||||
'noresult.gpuservice.storage.nofound': '未找到匹配的存储',
|
||||
'noresult.gpuservice.instanceType.title': '暂无实例类型',
|
||||
'noresult.gpuservice.instanceType.subTitle': '创建一个实例类型以开始使用',
|
||||
'noresult.gpuservice.instanceType.nofound': '未找到实例类型',
|
||||
'noresult.gpuservice.storageType.title': '暂无存储类型',
|
||||
'noresult.gpuservice.storageType.subTitle': '尚未添加任何存储类型。',
|
||||
'noresult.gpuservice.storageType.nofound': '未找到匹配的存储类型',
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
import { convertFileSize } from '@/utils';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Flex, Popover, theme } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import type { GlobalToken } from 'antd/es/theme';
|
||||
import React from 'react';
|
||||
|
||||
export interface DualArcGaugeItem {
|
||||
index: number;
|
||||
label?: string;
|
||||
memory: {
|
||||
total: number; // bytes
|
||||
used: number; // bytes — outer arc (semantic color)
|
||||
allocated: number; // bytes — inner arc (blue)
|
||||
};
|
||||
}
|
||||
|
||||
interface DualArcGaugeProps {
|
||||
data: DualArcGaugeItem[];
|
||||
}
|
||||
|
||||
// guage external radius: 20, internal radius: 16, stroke width: 2
|
||||
const CX = 25;
|
||||
const CY = 24;
|
||||
const R_OUT = 20;
|
||||
const R_IN = 16;
|
||||
const SW = 2.5;
|
||||
const L_OUT = Math.PI * R_OUT;
|
||||
const L_IN = Math.PI * R_IN;
|
||||
const arcPath = (r: number) =>
|
||||
`M ${CX - r} ${CY} A ${r} ${r} 0 0 1 ${CX + r} ${CY}`;
|
||||
const P_OUT = arcPath(R_OUT);
|
||||
const P_IN = arcPath(R_IN);
|
||||
|
||||
const clamp01 = (n: number) => Math.min(Math.max(n, 0), 1);
|
||||
|
||||
// Used color: green < 75%, yellow < 90%, red >= 90%
|
||||
const usedColor = (ratio: number, token: GlobalToken) => {
|
||||
if (ratio >= 0.9) return token.colorError;
|
||||
if (ratio >= 0.75) return token.colorWarning;
|
||||
return token.colorSuccess;
|
||||
};
|
||||
|
||||
const useStyles = createStyles(({ css, token }) => ({
|
||||
row: css`
|
||||
width: fit-content;
|
||||
padding: 3px 6px;
|
||||
border-radius: ${token.borderRadius}px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s;
|
||||
&:hover {
|
||||
background-color: ${token.colorFillTertiary};
|
||||
}
|
||||
`,
|
||||
index: css`
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: ${token.colorTextSecondary};
|
||||
border-bottom: 1px dashed var(--ant-blue-6);
|
||||
padding-bottom: 3px;
|
||||
line-height: 1.2;
|
||||
`,
|
||||
popTitle: css`
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: ${token.colorText};
|
||||
margin-bottom: 6px;
|
||||
`,
|
||||
popList: css`
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
`,
|
||||
metric: css`
|
||||
white-space: nowrap;
|
||||
`,
|
||||
dot: css`
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
`,
|
||||
value: css`
|
||||
min-width: 64px;
|
||||
text-align: right;
|
||||
font-weight: 500;
|
||||
color: ${token.colorText};
|
||||
`,
|
||||
label: css`
|
||||
color: ${token.colorTextTertiary};
|
||||
`
|
||||
}));
|
||||
|
||||
const DualArcGauge: React.FC<DualArcGaugeProps> = ({ data }) => {
|
||||
const intl = useIntl();
|
||||
const { styles } = useStyles();
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const trackColor = token.colorFillSecondary;
|
||||
const allocColor = 'var(--ant-blue-6)';
|
||||
|
||||
return (
|
||||
<Flex vertical gap={2} style={{ width: 'fit-content' }}>
|
||||
{data.map((item) => {
|
||||
const { total = 0, used = 0, allocated = 0 } = item.memory || {};
|
||||
const usedR = total > 0 ? clamp01(used / total) : 0;
|
||||
const allocR = total > 0 ? clamp01(allocated / total) : 0;
|
||||
const pct = Math.round(usedR * 100);
|
||||
const uc = usedColor(usedR, token);
|
||||
// set dim color for allocated if used is 0, otherwise use the same color as used
|
||||
const allocDotColor =
|
||||
allocated > 0 ? allocColor : token.colorTextQuaternary;
|
||||
|
||||
const content = (
|
||||
<div>
|
||||
<div className={styles.popTitle}>
|
||||
[{item.index}]{item.label ? ` ${item.label}` : ''} ·{' '}
|
||||
{convertFileSize(total)}
|
||||
</div>
|
||||
<Flex vertical gap={4} className={styles.popList}>
|
||||
<Flex align="center" gap={6} className={styles.metric}>
|
||||
<span className={styles.dot} style={{ background: uc }} />
|
||||
<span className={styles.value}>{convertFileSize(used)}</span>
|
||||
<span className={styles.label}>
|
||||
{intl.formatMessage({ id: 'resources.table.used' })}
|
||||
</span>
|
||||
</Flex>
|
||||
<Flex align="center" gap={6} className={styles.metric}>
|
||||
<span
|
||||
className={styles.dot}
|
||||
style={{ background: allocDotColor }}
|
||||
/>
|
||||
<span className={styles.value}>
|
||||
{convertFileSize(allocated)}
|
||||
</span>
|
||||
<span className={styles.label}>
|
||||
{intl.formatMessage({ id: 'resources.table.allocated' })}
|
||||
</span>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover
|
||||
key={item.index}
|
||||
content={content}
|
||||
placement="right"
|
||||
trigger={['hover', 'click']}
|
||||
>
|
||||
<Flex align="center" gap={6} className={styles.row}>
|
||||
<svg
|
||||
viewBox="0 0 50 28"
|
||||
width={54}
|
||||
height={30}
|
||||
style={{ overflow: 'visible', flexShrink: 0 }}
|
||||
>
|
||||
<path
|
||||
d={P_OUT}
|
||||
fill="none"
|
||||
strokeWidth={SW}
|
||||
stroke={trackColor}
|
||||
/>
|
||||
<path
|
||||
d={P_IN}
|
||||
fill="none"
|
||||
strokeWidth={SW}
|
||||
stroke={trackColor}
|
||||
/>
|
||||
{usedR > 0 && (
|
||||
<path
|
||||
d={P_OUT}
|
||||
fill="none"
|
||||
strokeWidth={SW}
|
||||
stroke={uc}
|
||||
strokeDasharray={`${(usedR * L_OUT).toFixed(1)} ${L_OUT.toFixed(1)}`}
|
||||
/>
|
||||
)}
|
||||
{allocR > 0 && (
|
||||
<path
|
||||
d={P_IN}
|
||||
fill="none"
|
||||
strokeWidth={SW}
|
||||
style={{ stroke: allocColor }}
|
||||
strokeDasharray={`${(allocR * L_IN).toFixed(1)} ${L_IN.toFixed(1)}`}
|
||||
/>
|
||||
)}
|
||||
<text
|
||||
x={CX}
|
||||
y={CY - 0.5}
|
||||
textAnchor="middle"
|
||||
fontSize={9.5}
|
||||
fontWeight={500}
|
||||
fill={uc}
|
||||
style={{ fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
{pct}%
|
||||
</text>
|
||||
</svg>
|
||||
{<span className={styles.index}>[{item.index}]</span>}
|
||||
</Flex>
|
||||
</Popover>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default DualArcGauge;
|
||||
@@ -60,8 +60,7 @@ const ModelTag: React.FC<ModelTagProps> = ({ categoryKey, size }) => {
|
||||
opacity: 1,
|
||||
paddingInline: 8,
|
||||
borderRadius: 12,
|
||||
transform: 'scale(0.9)',
|
||||
backgroundColor: 'transparent'
|
||||
transform: 'scale(0.9)'
|
||||
}}
|
||||
color={config.color}
|
||||
>
|
||||
|
||||
@@ -23,11 +23,6 @@ interface NumberSelectionProps {
|
||||
labelExtra?: React.ReactNode;
|
||||
maxCount?: number;
|
||||
tips?: string;
|
||||
// Explicit preset tick values (e.g. [10,20,...,100] for percentage slicing).
|
||||
// Overrides the default 1..maxCount sequence.
|
||||
presetValues?: number[];
|
||||
// Force the free-input box to show regardless of max/maxCount.
|
||||
alwaysShowInput?: boolean;
|
||||
onChange?: (value: number) => void;
|
||||
}
|
||||
|
||||
@@ -44,18 +39,17 @@ const NumberSelection: React.FC<NumberSelectionProps> = ({
|
||||
className,
|
||||
maxCount = 8,
|
||||
tips,
|
||||
presetValues,
|
||||
alwaysShowInput,
|
||||
style,
|
||||
onChange
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
const showCustomInput = alwaysShowInput || max > maxCount;
|
||||
const presetItems =
|
||||
presetValues ??
|
||||
Array.from({ length: Math.max(0, maxCount) }, (_, i) => i + 1);
|
||||
if (!presetValues && min <= 0) {
|
||||
const showCustomInput = max > maxCount;
|
||||
const presetItems = Array.from(
|
||||
{ length: Math.max(0, maxCount) },
|
||||
(_, i) => i + 1
|
||||
);
|
||||
if (min <= 0) {
|
||||
presetItems.unshift(0);
|
||||
}
|
||||
const items = presetItems;
|
||||
|
||||
@@ -39,20 +39,9 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 12px;
|
||||
padding-right: 2px;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
white-space: nowrap;
|
||||
padding-block: 6px;
|
||||
width: 100%;
|
||||
|
||||
// Spread the label and its labelExtra (e.g. the whole/sliced Segmented)
|
||||
// to opposite ends of the row.
|
||||
:global(.label-text) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.contentWrapper {
|
||||
width: 100%;
|
||||
|
||||
@@ -6,12 +6,10 @@ import {
|
||||
AutoTooltip,
|
||||
DropdownButtons,
|
||||
IconFont,
|
||||
icons,
|
||||
TextAttribute,
|
||||
ThemeTag
|
||||
icons
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { MenuProps, Tooltip } from 'antd';
|
||||
import { MenuProps, Tag, Tooltip } from 'antd';
|
||||
import { ColumnsType } from 'antd/lib/table';
|
||||
import dayjs from 'dayjs';
|
||||
import { useMemo } from 'react';
|
||||
@@ -141,14 +139,23 @@ const useModelsColumns = ({
|
||||
key: 'name',
|
||||
sorter: tableSorter(1),
|
||||
render: (text: string, record: ListItem) => (
|
||||
<span className="flex items-center gap-8">
|
||||
<span className="flex items-center">
|
||||
<AutoTooltip ghost style={{ maxWidth: 400 }} title={text}>
|
||||
<span className="text-primary">{text}</span>
|
||||
</AutoTooltip>
|
||||
{record.is_custom && (
|
||||
<TextAttribute>
|
||||
<Tag
|
||||
style={{
|
||||
marginLeft: 8,
|
||||
borderRadius: 12,
|
||||
color: 'var(--ant-color-text-tertiary)',
|
||||
borderColor: 'var(--ant-color-split)',
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
variant="outlined"
|
||||
>
|
||||
{intl.formatMessage({ id: 'playground.params.custom' })}
|
||||
</TextAttribute>
|
||||
</Tag>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
@@ -196,13 +203,26 @@ const useModelsColumns = ({
|
||||
)}
|
||||
{(record.scope?.includes('inference') ||
|
||||
record.scope?.includes('*')) && (
|
||||
<ThemeTag>
|
||||
<div
|
||||
style={{
|
||||
border: '1px solid var(--ant-color-split)',
|
||||
color: 'var(--ant-color-text-tertiary)',
|
||||
backgroundColor: 'var(--ant-color-fill-quaternary)',
|
||||
borderRadius: 4,
|
||||
fontSize: 13,
|
||||
paddingInline: 8,
|
||||
flexGrow: 0,
|
||||
maxWidth: '100%',
|
||||
width: 'max-content',
|
||||
display: 'flex'
|
||||
}}
|
||||
>
|
||||
<AutoTooltip ghost>
|
||||
{record.allowed_model_names?.length
|
||||
? record.allowed_model_names.join(', ')
|
||||
: intl.formatMessage({ id: 'apikeys.models.all' })}
|
||||
</AutoTooltip>
|
||||
</ThemeTag>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -120,11 +120,6 @@ const CommunityBackends: React.FC<{
|
||||
|
||||
const renderItem = (item: ListItem) => {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'var(--ant-color-bg-container)'
|
||||
}}
|
||||
>
|
||||
<BackendCard
|
||||
active={currentData?.id === item.id}
|
||||
data={item}
|
||||
@@ -132,7 +127,6 @@ const CommunityBackends: React.FC<{
|
||||
onClick={handleOnClickItem}
|
||||
actionsRenderer={actionsRenderer}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const Title = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background-color: var(--ant-color-bg-elevated);
|
||||
background-color: var(--ant-color-bg-container);
|
||||
font-weight: 600;
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
|
||||
@@ -176,7 +176,6 @@ const useClusterColumns = (
|
||||
dataIndex: 'provider',
|
||||
sorter: tableSorter(2),
|
||||
span: spans.provider,
|
||||
minWidth: 110,
|
||||
render: (value: string) => (
|
||||
<AutoTooltip ghost minWidth={20}>
|
||||
{ProviderLabelMap[value]}
|
||||
@@ -188,21 +187,20 @@ const useClusterColumns = (
|
||||
dataIndex: 'gpus',
|
||||
span: 2,
|
||||
sorter: tableSorter(3),
|
||||
width: 100,
|
||||
render: (value: number) => <span>{value}</span>
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'clusters.table.deployments' }),
|
||||
dataIndex: 'models',
|
||||
sorter: tableSorter(4),
|
||||
width: 100,
|
||||
span: spans.deployments,
|
||||
render: (value: number) => <span>{value}</span>
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'resources.nodes' }),
|
||||
dataIndex: 'workers',
|
||||
sorter: tableSorter(5),
|
||||
width: 100,
|
||||
span: spans.workers,
|
||||
render: (value: number, record: ClusterListItem) => (
|
||||
<span>
|
||||
{record.ready_workers} / {record.workers}
|
||||
@@ -213,7 +211,6 @@ const useClusterColumns = (
|
||||
title: intl.formatMessage({ id: 'common.table.status' }),
|
||||
dataIndex: 'state',
|
||||
span: spans.status,
|
||||
align: 'center',
|
||||
render: (value: number, record: ClusterListItem) => (
|
||||
<StatusTag
|
||||
statusValue={{
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import { request } from '@umijs/max';
|
||||
import { FlavorItem, FormData, ListItem } from '../config/types';
|
||||
|
||||
export const GPU_INSTANCE_TYPES_API = '/gpu-instance-types';
|
||||
|
||||
export const GPU_INSTANCE_TYPE_FLAVORS_API = '/gpu-instance-type-flavors';
|
||||
|
||||
// GET /gpu-instance-types?cluster_id — instance types defined on a cluster.
|
||||
export async function queryGPUInstanceTypes(
|
||||
params: { cluster_id: number },
|
||||
options?: any
|
||||
) {
|
||||
return request<{ items: ListItem[] }>(GPU_INSTANCE_TYPES_API, {
|
||||
method: 'GET',
|
||||
params,
|
||||
cancelToken: options?.token
|
||||
});
|
||||
}
|
||||
|
||||
// GET /gpu-instance-type-flavors?cluster_id — the hardware flavors a new
|
||||
// instance type can be based on.
|
||||
export async function queryGPUInstanceTypeFlavors(
|
||||
params: { cluster_id: number },
|
||||
options?: any
|
||||
) {
|
||||
return request<{ items: FlavorItem[] }>(GPU_INSTANCE_TYPE_FLAVORS_API, {
|
||||
method: 'GET',
|
||||
params,
|
||||
cancelToken: options?.token
|
||||
});
|
||||
}
|
||||
|
||||
// POST /gpu-instance-types?cluster_id (GPUInstanceTypeCreate).
|
||||
export async function createGPUInstanceType(params: {
|
||||
cluster_id: number;
|
||||
data: FormData;
|
||||
}) {
|
||||
return request<ListItem>(GPU_INSTANCE_TYPES_API, {
|
||||
method: 'POST',
|
||||
params: { cluster_id: params.cluster_id },
|
||||
data: params.data
|
||||
});
|
||||
}
|
||||
|
||||
// DELETE /gpu-instance-types/{name}?cluster_id.
|
||||
export async function deleteGPUInstanceType(params: {
|
||||
name: string;
|
||||
cluster_id: number;
|
||||
}) {
|
||||
return request(`${GPU_INSTANCE_TYPES_API}/${params.name}`, {
|
||||
method: 'DELETE',
|
||||
params: { cluster_id: params.cluster_id }
|
||||
});
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
import useSubmitLock from '@/hooks/use-submit-lock';
|
||||
import Separator from '@/pages/llmodels/components/separator';
|
||||
import { ColumnWrapper, GSDrawer, ModalFooter } from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Typography, message } from 'antd';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { FlavorItem, FormData } from '../config/types';
|
||||
import GPUServiceInstanceTypeForm from '../forms';
|
||||
import useQueryFlavors from '../services/use-query-flavors';
|
||||
import styles from '../styles/instance-types.module.less';
|
||||
import FlavorList from './flavor-list';
|
||||
|
||||
type AddInstanceTypeModalProps = {
|
||||
title: string;
|
||||
open: boolean;
|
||||
clusterId?: number;
|
||||
onOk: (values: FormData) => void;
|
||||
onCancel: () => void;
|
||||
};
|
||||
|
||||
const ColTitle: React.FC<{
|
||||
children: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
}> = ({ children, style }) => (
|
||||
<Typography.Title
|
||||
level={3}
|
||||
style={{
|
||||
fontSize: 14,
|
||||
paddingTop: 10,
|
||||
paddingBottom: 16,
|
||||
margin: 0,
|
||||
position: 'sticky',
|
||||
top: 0,
|
||||
zIndex: 100,
|
||||
backgroundColor: 'var(--ant-color-bg-elevated)',
|
||||
...style
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Typography.Title>
|
||||
);
|
||||
|
||||
const AddInstanceTypeModal: React.FC<AddInstanceTypeModalProps> = ({
|
||||
title,
|
||||
open,
|
||||
clusterId,
|
||||
onOk,
|
||||
onCancel
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const form = useRef<any>(null);
|
||||
const { loading, guard, run, release } = useSubmitLock();
|
||||
const [selectedFlavor, setSelectedFlavor] = useState<FlavorItem | null>(null);
|
||||
const {
|
||||
dataList: flavorList,
|
||||
loading: flavorLoading,
|
||||
fetchFlavors
|
||||
} = useQueryFlavors();
|
||||
|
||||
// Fetch flavors when the drawer opens and auto-select the first one, so the
|
||||
// form's flavor-derived fields (group / acceleratable) are always set.
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
setSelectedFlavor(null);
|
||||
return;
|
||||
}
|
||||
if (!clusterId) return;
|
||||
const load = async () => {
|
||||
const list = await fetchFlavors(clusterId);
|
||||
setSelectedFlavor(list?.[0] ?? null);
|
||||
};
|
||||
load();
|
||||
}, [open, clusterId]);
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!selectedFlavor) {
|
||||
message.warning(
|
||||
intl.formatMessage({ id: 'gpuservice.instanceType.flavor.required' })
|
||||
);
|
||||
return;
|
||||
}
|
||||
guard(() => form.current?.submit());
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
form.current?.resetFields();
|
||||
onCancel();
|
||||
};
|
||||
|
||||
const onFinish = async (values: FormData) => {
|
||||
await run(() => onOk({ ...values }));
|
||||
};
|
||||
|
||||
return (
|
||||
<GSDrawer
|
||||
title={title}
|
||||
open={open}
|
||||
onClose={handleCancel}
|
||||
destroyOnHidden
|
||||
closeIcon={false}
|
||||
mask={{ closable: false }}
|
||||
keyboard={false}
|
||||
styles={{
|
||||
wrapper: { width: 'min(900px, calc(100vw - 220px))' },
|
||||
body: { overflowY: 'hidden' }
|
||||
}}
|
||||
footer={false}
|
||||
>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.colWrapper}>
|
||||
<ColumnWrapper styles={{ container: { paddingBlock: 0 } }}>
|
||||
<div className={styles.panelBody}>
|
||||
<div className={styles.stickyHead}>
|
||||
<ColTitle
|
||||
style={{
|
||||
paddingBottom: 0
|
||||
}}
|
||||
>
|
||||
{intl.formatMessage({ id: 'gpuservice.instanceType.flavor' })}
|
||||
</ColTitle>
|
||||
</div>
|
||||
<FlavorList
|
||||
value={selectedFlavor?.name}
|
||||
dataList={flavorList}
|
||||
loading={flavorLoading}
|
||||
onChange={setSelectedFlavor}
|
||||
/>
|
||||
</div>
|
||||
</ColumnWrapper>
|
||||
<Separator />
|
||||
</div>
|
||||
<div className={styles.formWrapper}>
|
||||
<ColumnWrapper
|
||||
styles={{ container: { paddingBlock: 0 } }}
|
||||
footer={
|
||||
<ModalFooter
|
||||
onOk={handleSubmit}
|
||||
onCancel={handleCancel}
|
||||
loading={loading}
|
||||
style={{
|
||||
padding: '16px 24px 8px',
|
||||
display: 'flex',
|
||||
justifyContent: 'flex-end'
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ColTitle>
|
||||
{intl.formatMessage({ id: 'common.title.config' })}
|
||||
</ColTitle>
|
||||
<GPUServiceInstanceTypeForm
|
||||
ref={form}
|
||||
open={open}
|
||||
selectedFlavor={selectedFlavor}
|
||||
onFinish={onFinish}
|
||||
onFinishFailed={release}
|
||||
/>
|
||||
</ColumnWrapper>
|
||||
</div>
|
||||
</div>
|
||||
</GSDrawer>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddInstanceTypeModal;
|
||||
@@ -1,129 +0,0 @@
|
||||
import { FileSkeletonRows } from '@/pages/llmodels/components/model-source/file-skeleton';
|
||||
import {
|
||||
AutoTooltip,
|
||||
IconFont,
|
||||
TemplateCard,
|
||||
ThemeTag
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Empty, Flex, Spin, Typography } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { formatMemoryDisplay } from '../../instances/config';
|
||||
import { manufactureColorMap } from '../../templates/config';
|
||||
import { FlavorItem } from '../config/types';
|
||||
import styles from '../styles/instance-types.module.less';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
interface FlavorListProps {
|
||||
value?: string;
|
||||
dataList: FlavorItem[];
|
||||
loading?: boolean;
|
||||
onChange?: (item: FlavorItem) => void;
|
||||
}
|
||||
|
||||
const MetaItem: React.FC<{
|
||||
icon: string;
|
||||
label: string;
|
||||
value?: React.ReactNode;
|
||||
}> = ({ icon, label, value }) => {
|
||||
return (
|
||||
<span className={styles.metaLabel}>
|
||||
<IconFont className="icon" type={icon} />
|
||||
{label}: <span className={styles.metaValue}>{value ?? '-'}</span>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
const FlavorList: React.FC<FlavorListProps> = ({
|
||||
value,
|
||||
dataList,
|
||||
loading,
|
||||
onChange
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
if (!dataList.length) {
|
||||
if (loading) {
|
||||
return (
|
||||
<Spin spinning size="middle">
|
||||
<Flex vertical gap={16} style={{ minHeight: 200 }}>
|
||||
{_.times(6, (index: number) => (
|
||||
<FileSkeletonRows key={index} counts={2} itemHeight={96} />
|
||||
))}
|
||||
</Flex>
|
||||
</Spin>
|
||||
);
|
||||
}
|
||||
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex vertical gap={16}>
|
||||
{dataList.map((item) => {
|
||||
const spec = item.spec || {};
|
||||
const manufacturer = spec.manufacturer || '';
|
||||
const color = manufactureColorMap[manufacturer] ?? 'purple';
|
||||
// A generic (no product, no/`generic` manufacturer) flavor is shown as
|
||||
// "CPU-only" instead of falling back to the raw flavor name.
|
||||
const isCpuOnly =
|
||||
!spec.acceleratable &&
|
||||
!spec.product &&
|
||||
(!manufacturer || manufacturer.toLowerCase() === 'generic');
|
||||
const title = isCpuOnly ? 'CPU-only' : spec.product || item.name || '-';
|
||||
return (
|
||||
<TemplateCard
|
||||
key={item.name}
|
||||
className={styles.flavorCard}
|
||||
clickable
|
||||
ghost
|
||||
hoverable
|
||||
active={value === item.name}
|
||||
onClick={() => onChange?.(item)}
|
||||
>
|
||||
<Flex vertical gap={12} style={{ width: '100%' }}>
|
||||
<Flex align="center" justify="space-between" gap={8}>
|
||||
<div style={{ minWidth: 0, fontWeight: 500 }}>
|
||||
<AutoTooltip ghost minWidth={20}>
|
||||
<Text>{title}</Text>
|
||||
</AutoTooltip>
|
||||
</div>
|
||||
{manufacturer && (
|
||||
<ThemeTag color={color} style={{ fontWeight: 400 }}>
|
||||
{manufacturer.toUpperCase()}
|
||||
</ThemeTag>
|
||||
)}
|
||||
</Flex>
|
||||
{/* Memory / sliceable only apply to accelerator (GPU) flavors;
|
||||
a non-acceleratable (generic) flavor has neither. */}
|
||||
{spec.acceleratable && (
|
||||
<Flex wrap gap={16}>
|
||||
<MetaItem
|
||||
icon="icon-ram-02"
|
||||
label={intl.formatMessage({
|
||||
id: 'gpuservice.instance.memory'
|
||||
})}
|
||||
value={formatMemoryDisplay(spec.memory ?? undefined) ?? '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
icon="icon-sliced"
|
||||
label={intl.formatMessage({
|
||||
id: 'gpuservice.instance.sliceable'
|
||||
})}
|
||||
value={
|
||||
spec.sliceable
|
||||
? intl.formatMessage({ id: 'common.table.yes' })
|
||||
: intl.formatMessage({ id: 'common.table.no' })
|
||||
}
|
||||
/>
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
</TemplateCard>
|
||||
);
|
||||
})}
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default FlavorList;
|
||||
@@ -1,147 +0,0 @@
|
||||
import {
|
||||
AutoTooltip,
|
||||
DropdownActions,
|
||||
IconFont,
|
||||
StatusTag,
|
||||
TemplateCard,
|
||||
ThemeTag
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Button } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { formatMemoryDisplay } from '../../instances/config';
|
||||
import { manufactureColorMap } from '../../templates/config';
|
||||
import { ceilMilliToCore, parseQuantityToGi } from '../../utils';
|
||||
import {
|
||||
InstanceTypePhaseLabelMap,
|
||||
status as phaseStatusMap,
|
||||
rowActionList
|
||||
} from '../config';
|
||||
import { ListItem } from '../config/types';
|
||||
import styles from '../styles/instance-types.module.less';
|
||||
|
||||
interface InstanceTypeCardProps {
|
||||
data: ListItem;
|
||||
onDelete?: (record: ListItem) => void;
|
||||
}
|
||||
|
||||
const InstanceTypeCard: React.FC<InstanceTypeCardProps> = ({
|
||||
data,
|
||||
onDelete
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const spec = data.spec || {};
|
||||
const unit = spec.unitResources || {};
|
||||
const phase = data.status?.phase || '';
|
||||
const manufacturer = spec.manufacturer || '';
|
||||
const manufacturerColor = manufactureColorMap[manufacturer] ?? 'purple';
|
||||
|
||||
const memoryText = formatMemoryDisplay(spec.memory ?? undefined);
|
||||
|
||||
// Base resources, formatted into a single "·"-separated line. Falsy parts
|
||||
// (e.g. a CPU-only type without VRAM) drop out rather than showing "-".
|
||||
const cpuCores = ceilMilliToCore(unit.cpu ?? null)?.cores;
|
||||
const ramGi = parseQuantityToGi(unit.ram ?? null)?.value;
|
||||
const storageGi = parseQuantityToGi(spec.localStorage ?? null)?.value;
|
||||
const osLabel = _.capitalize(spec.os || '');
|
||||
const archLabel = _.toUpper(spec.arch || '');
|
||||
const storageWord = intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.localStorage'
|
||||
});
|
||||
const footerParts = [
|
||||
cpuCores != null ? `${cpuCores} vCPU` : null,
|
||||
ramGi != null ? `${ramGi} GiB RAM` : null,
|
||||
storageGi != null ? `${storageGi} GiB ${storageWord}` : null,
|
||||
osLabel ? `${osLabel}${archLabel ? ` (${archLabel})` : ''}` : null
|
||||
].filter(Boolean) as string[];
|
||||
|
||||
const handleAction = (item: any) => {
|
||||
if (item.key === 'delete') {
|
||||
onDelete?.(data);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<TemplateCard
|
||||
className={styles.listCard}
|
||||
clickable={false}
|
||||
hoverable
|
||||
ghost
|
||||
header={
|
||||
<div className={styles.header}>
|
||||
<span className={styles.product}>
|
||||
<AutoTooltip ghost minWidth={20}>
|
||||
{spec.product || data.name || '-'}
|
||||
</AutoTooltip>
|
||||
</span>
|
||||
<span className={styles.headerRight}>
|
||||
<span onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownActions
|
||||
menu={{ items: rowActionList, onClick: handleAction }}
|
||||
>
|
||||
<Button
|
||||
icon={<IconFont type="icon-more" />}
|
||||
size="small"
|
||||
type="text"
|
||||
/>
|
||||
</DropdownActions>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.hero}>
|
||||
<span className={styles.name}>
|
||||
<AutoTooltip ghost minWidth={20}>
|
||||
{data.name || '-'}
|
||||
</AutoTooltip>
|
||||
</span>
|
||||
<span className={styles.memory}>{memoryText || '—'}</span>
|
||||
</div>
|
||||
|
||||
<div className={styles.subline}>
|
||||
{manufacturer && (
|
||||
<ThemeTag color={manufacturerColor} style={{ fontWeight: 400 }}>
|
||||
{manufacturer.toUpperCase()}
|
||||
</ThemeTag>
|
||||
)}
|
||||
{phase ? (
|
||||
<StatusTag
|
||||
statusValue={{
|
||||
status: phaseStatusMap[phase],
|
||||
text: InstanceTypePhaseLabelMap[phase] || phase,
|
||||
message: data.status?.phaseMessage || ''
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{spec.clockSpeed ? <span>{spec.clockSpeed}</span> : null}
|
||||
<span
|
||||
className={`${styles.tag} ${
|
||||
spec.sliceable ? styles.tagSliceable : styles.tagPlain
|
||||
}`}
|
||||
>
|
||||
{spec.sliceable
|
||||
? intl.formatMessage({ id: 'gpuservice.instance.sliceable' })
|
||||
: intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.notSliceable'
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className={styles.divider} />
|
||||
|
||||
<div className={styles.footer}>
|
||||
{footerParts.map((part, index) => (
|
||||
<span key={part}>
|
||||
{index > 0 && <span className={styles.dotSep}>·</span>}
|
||||
{part}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</TemplateCard>
|
||||
);
|
||||
};
|
||||
|
||||
export default InstanceTypeCard;
|
||||
@@ -1,31 +0,0 @@
|
||||
import { ResizeContainer } from '@gpustack/core-ui';
|
||||
import { Spin } from 'antd';
|
||||
import { ListItem } from '../config/types';
|
||||
import InstanceTypeCard from './instance-type-card';
|
||||
|
||||
interface InstanceTypeListProps {
|
||||
dataList: ListItem[];
|
||||
loading: boolean;
|
||||
onDelete?: (record: ListItem) => void;
|
||||
}
|
||||
|
||||
const InstanceTypeList: React.FC<InstanceTypeListProps> = ({
|
||||
dataList,
|
||||
loading,
|
||||
onDelete
|
||||
}) => {
|
||||
return (
|
||||
<Spin spinning={loading} size="middle">
|
||||
<ResizeContainer
|
||||
defaultSpan={8}
|
||||
resizable
|
||||
dataList={dataList}
|
||||
renderItem={(item: ListItem) => (
|
||||
<InstanceTypeCard data={item} onDelete={onDelete} />
|
||||
)}
|
||||
/>
|
||||
</Spin>
|
||||
);
|
||||
};
|
||||
|
||||
export default InstanceTypeList;
|
||||
@@ -1,47 +0,0 @@
|
||||
import { StatusMaps } from '@/config';
|
||||
import { StatusType } from '@/config/types';
|
||||
import { icons } from '@gpustack/core-ui';
|
||||
|
||||
// os is fixed to lowercase "linux" on the wire; the form only ever shows Linux.
|
||||
export const GPU_INSTANCE_TYPE_OS = 'linux';
|
||||
|
||||
export const InstanceTypePhaseValueMap = {
|
||||
Active: 'Active',
|
||||
Inactive: 'Inactive',
|
||||
Preparing: 'Preparing'
|
||||
};
|
||||
|
||||
export const InstanceTypePhaseLabelMap: Record<string, string> = {
|
||||
[InstanceTypePhaseValueMap.Active]: 'Active',
|
||||
[InstanceTypePhaseValueMap.Inactive]: 'Inactive',
|
||||
[InstanceTypePhaseValueMap.Preparing]: 'Preparing'
|
||||
};
|
||||
|
||||
export const status: Record<string, StatusType> = {
|
||||
[InstanceTypePhaseValueMap.Active]: StatusMaps.success,
|
||||
[InstanceTypePhaseValueMap.Inactive]: StatusMaps.inactive,
|
||||
[InstanceTypePhaseValueMap.Preparing]: StatusMaps.transitioning
|
||||
};
|
||||
|
||||
export const ArchOptions = [
|
||||
{ label: 'amd64', value: 'amd64' },
|
||||
{ label: 'arm64', value: 'arm64' }
|
||||
];
|
||||
|
||||
// ``icon`` is narrowed to ``any`` so the inferred type doesn't reach into
|
||||
// the antd icon component's internal path.
|
||||
export const rowActionList: Array<{
|
||||
label: string;
|
||||
key: string;
|
||||
locale: boolean;
|
||||
icon: any;
|
||||
danger?: boolean;
|
||||
}> = [
|
||||
{
|
||||
label: 'common.button.delete',
|
||||
key: 'delete',
|
||||
locale: true,
|
||||
icon: icons.DeleteOutlined,
|
||||
danger: true
|
||||
}
|
||||
];
|
||||
@@ -1,65 +0,0 @@
|
||||
export interface UnitResources {
|
||||
cpu?: string | null;
|
||||
ram?: string | null;
|
||||
}
|
||||
|
||||
export interface InstanceTypeSpec {
|
||||
manufacturer?: string | null;
|
||||
product?: string | null;
|
||||
family?: string | null;
|
||||
memory?: string | null;
|
||||
cores?: string | null;
|
||||
clockSpeed?: string | null;
|
||||
sliceable?: boolean;
|
||||
os?: string | null;
|
||||
arch?: string | null;
|
||||
acceleratable?: boolean;
|
||||
acceleratorGroup?: string | null;
|
||||
generalGroup?: string | null;
|
||||
unitResources?: UnitResources | null;
|
||||
localStorage?: string | null;
|
||||
}
|
||||
|
||||
export interface InstanceTypeStatus {
|
||||
phase?: string | null;
|
||||
phaseMessage?: string | null;
|
||||
}
|
||||
|
||||
// Row shape for the management list (GET /gpu-instance-types).
|
||||
export interface ListItem {
|
||||
name: string;
|
||||
spec: InstanceTypeSpec;
|
||||
status?: InstanceTypeStatus;
|
||||
}
|
||||
|
||||
// Selectable flavor shown in the create drawer's first column
|
||||
// (GET /gpu-instance-type-flavors). Its acceleratorGroup / generalGroup /
|
||||
// acceleratable are copied into the created instance type.
|
||||
export interface FlavorItem {
|
||||
name: string;
|
||||
spec: {
|
||||
manufacturer?: string | null;
|
||||
product?: string | null;
|
||||
family?: string | null;
|
||||
memory?: string | null;
|
||||
cores?: string | null;
|
||||
sliceable?: boolean;
|
||||
acceleratable?: boolean;
|
||||
acceleratorGroup?: string | null;
|
||||
generalGroup?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
// Body for POST /gpu-instance-types (GPUInstanceTypeCreate).
|
||||
export interface FormData {
|
||||
name: string;
|
||||
spec: {
|
||||
acceleratorGroup?: string | null;
|
||||
generalGroup?: string | null;
|
||||
acceleratable?: boolean;
|
||||
os: string;
|
||||
arch?: string | null;
|
||||
unitResources?: UnitResources;
|
||||
localStorage?: string | null;
|
||||
};
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
import { validateLabelNameRegxFor63 } from '@/config';
|
||||
import {
|
||||
Input as CInput,
|
||||
InputNumber,
|
||||
Select as SealSelect,
|
||||
useAppUtils
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
||||
import { ArchOptions, GPU_INSTANCE_TYPE_OS } from '../config';
|
||||
import { FlavorItem, FormData } from '../config/types';
|
||||
|
||||
// RAM / storage are entered as a plain number in GB but stored/submitted as a
|
||||
// "Gi" quantity string. These drive the FormItem's submit (`normalize`) and
|
||||
// display (`getValueProps`) conversions.
|
||||
const giNormalize = (value?: number | string | null) =>
|
||||
value ? `${value}Gi` : undefined;
|
||||
const giValueProps = (value?: string | null) => ({
|
||||
value: value ? String(value).replace(/Gi$/i, '') : ''
|
||||
});
|
||||
|
||||
interface InstanceTypeFormProps {
|
||||
ref?: any;
|
||||
open: boolean;
|
||||
// The flavor picked in the drawer's first column. Its acceleratorGroup /
|
||||
// generalGroup / acceleratable are copied into the created instance type.
|
||||
selectedFlavor?: FlavorItem | null;
|
||||
onFinish: (values: FormData) => Promise<void>;
|
||||
onFinishFailed?: (errorInfo: any) => void;
|
||||
}
|
||||
|
||||
const GPUServiceInstanceTypeForm: React.FC<InstanceTypeFormProps> = forwardRef(
|
||||
(props, ref) => {
|
||||
const { open, selectedFlavor, onFinish, onFinishFailed } = props;
|
||||
const intl = useIntl();
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const [form] = Form.useForm<FormData>();
|
||||
|
||||
// A non-acceleratable (generic) flavor has no per-GPU concept, so unit CPU
|
||||
// is fixed to 1 and the field is disabled.
|
||||
const acceleratable = !!selectedFlavor?.spec?.acceleratable;
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
form.resetFields();
|
||||
return;
|
||||
}
|
||||
form.setFieldsValue({
|
||||
spec: {
|
||||
arch: ArchOptions[0].value
|
||||
}
|
||||
} as any);
|
||||
}, [open, form]);
|
||||
|
||||
// Force unit CPU to 1 whenever the picked flavor is not acceleratable.
|
||||
useEffect(() => {
|
||||
if (!open || acceleratable) return;
|
||||
form.setFieldValue(['spec', 'unitResources', 'cpu'], 1);
|
||||
}, [open, acceleratable, form]);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
submit: () => {
|
||||
form.submit();
|
||||
},
|
||||
resetFields: () => {
|
||||
form.resetFields();
|
||||
}
|
||||
}));
|
||||
|
||||
const handleFinish = async (values: FormData) => {
|
||||
// The hardware group / acceleratable flags are not user-editable; they
|
||||
// come from the chosen flavor. os is fixed to lowercase "linux". ram /
|
||||
// localStorage already carry the "Gi" suffix from the FormItem normalize.
|
||||
const cpu = values.spec?.unitResources?.cpu;
|
||||
await onFinish({
|
||||
name: values.name,
|
||||
spec: {
|
||||
acceleratorGroup: selectedFlavor?.spec?.acceleratorGroup ?? null,
|
||||
generalGroup: selectedFlavor?.spec?.generalGroup ?? null,
|
||||
acceleratable: selectedFlavor?.spec?.acceleratable ?? false,
|
||||
os: GPU_INSTANCE_TYPE_OS,
|
||||
arch: values.spec?.arch ?? null,
|
||||
unitResources: {
|
||||
cpu: cpu != null && cpu !== '' ? String(cpu) : null,
|
||||
ram: values.spec?.unitResources?.ram ?? null
|
||||
},
|
||||
localStorage: values.spec?.localStorage ?? null
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form
|
||||
name="gpuServiceInstanceTypeForm"
|
||||
form={form}
|
||||
onFinish={handleFinish}
|
||||
onFinishFailed={onFinishFailed}
|
||||
preserve={false}
|
||||
>
|
||||
<Form.Item<FormData>
|
||||
name="name"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'common.table.name')
|
||||
},
|
||||
{
|
||||
pattern: validateLabelNameRegxFor63,
|
||||
message: intl.formatMessage({ id: 'gpuservice.form.rule.name' })
|
||||
}
|
||||
]}
|
||||
>
|
||||
<CInput.Input
|
||||
label={intl.formatMessage({ id: 'common.table.name' })}
|
||||
required
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<CInput.Input
|
||||
disabled
|
||||
value="Linux"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.os' })}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'arch']}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('select', 'gpuservice.instance.arch')
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealSelect
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.arch' })}
|
||||
required
|
||||
options={ArchOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'unitResources', 'cpu']}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'gpuservice.instanceType.unitCpu'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
disabled={!acceleratable}
|
||||
style={{ width: '100%' }}
|
||||
label={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitCpu'
|
||||
})}
|
||||
description={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitCpu.tip'
|
||||
})}
|
||||
required
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'unitResources', 'ram']}
|
||||
normalize={giNormalize}
|
||||
getValueProps={giValueProps}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'gpuservice.instanceType.unitRam'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
style={{ width: '100%' }}
|
||||
label={`${intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitRam'
|
||||
})} (GB)`}
|
||||
description={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitRam.tip'
|
||||
})}
|
||||
required
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'localStorage']}
|
||||
normalize={giNormalize}
|
||||
getValueProps={giValueProps}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'gpuservice.instanceType.localStorage'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<InputNumber
|
||||
min={0}
|
||||
style={{ width: '100%' }}
|
||||
label={`${intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.localStorage'
|
||||
})} (GB)`}
|
||||
description={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.localStorage.tip'
|
||||
})}
|
||||
required
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
export default GPUServiceInstanceTypeForm;
|
||||
@@ -1,37 +0,0 @@
|
||||
import useBodyScroll from '@/hooks/use-body-scroll';
|
||||
import { useState } from 'react';
|
||||
|
||||
const useCreateInstanceTypeModal = () => {
|
||||
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
|
||||
const [openModalStatus, setOpenModalStatus] = useState<{
|
||||
open: boolean;
|
||||
title: string;
|
||||
}>({
|
||||
open: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const openModal = (title: string) => {
|
||||
setOpenModalStatus({
|
||||
open: true,
|
||||
title
|
||||
});
|
||||
saveScrollHeight();
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
setOpenModalStatus({
|
||||
open: false,
|
||||
title: ''
|
||||
});
|
||||
restoreScrollHeight();
|
||||
};
|
||||
|
||||
return {
|
||||
openInstanceTypeModalStatus: openModalStatus,
|
||||
openInstanceTypeModal: openModal,
|
||||
closeInstanceTypeModal: closeModal
|
||||
};
|
||||
};
|
||||
|
||||
export default useCreateInstanceTypeModal;
|
||||
@@ -1,224 +0,0 @@
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
AutoTooltip,
|
||||
DropdownButtons,
|
||||
icons,
|
||||
StatusTag,
|
||||
ThemeTag
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Space, Tooltip } from 'antd';
|
||||
import type { ColumnsType } from 'antd/lib/table';
|
||||
import _ from 'lodash';
|
||||
import { useMemo } from 'react';
|
||||
import { formatMemoryDisplay } from '../../instances/config';
|
||||
import { manufactureColorMap } from '../../templates/config';
|
||||
import {
|
||||
ceilMilliToCore,
|
||||
formatManufacturer,
|
||||
parseQuantityToGi
|
||||
} from '../../utils';
|
||||
import { InstanceTypePhaseLabelMap, status as phaseStatusMap } from '../config';
|
||||
import { ListItem } from '../config/types';
|
||||
|
||||
interface ColumnsHookProps {
|
||||
handleSelect: (val: string, record: ListItem) => void;
|
||||
}
|
||||
|
||||
// DropdownButtons reads `locale` / `props` at runtime; its `items` prop is
|
||||
// typed as antd's MenuProps['items'], so cast the config to satisfy it.
|
||||
const rowActions = [
|
||||
{
|
||||
label: 'common.button.delete',
|
||||
key: 'delete',
|
||||
locale: true,
|
||||
icon: icons.DeleteOutlined,
|
||||
props: { danger: true }
|
||||
}
|
||||
] as any;
|
||||
|
||||
// Column header with an info tooltip (used for the per-GPU resource columns).
|
||||
const TitleWithTip: React.FC<{ title: string; tip: string }> = ({
|
||||
title,
|
||||
tip
|
||||
}) => (
|
||||
<Space size={4}>
|
||||
<span>{title}</span>
|
||||
<Tooltip title={tip}>
|
||||
<QuestionCircleOutlined
|
||||
style={{ color: 'var(--ant-color-text-tertiary)' }}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Space>
|
||||
);
|
||||
|
||||
const useInstanceTypeColumns = ({
|
||||
handleSelect
|
||||
}: ColumnsHookProps): ColumnsType<ListItem> => {
|
||||
const intl = useIntl();
|
||||
|
||||
return useMemo(() => {
|
||||
return [
|
||||
{
|
||||
title: intl.formatMessage({ id: 'common.table.name' }),
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (text: string) => (
|
||||
<AutoTooltip ghost maxWidth={240} title={text}>
|
||||
<span className="text-primary">{text || '-'}</span>
|
||||
</AutoTooltip>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'gpuservice.instanceType.product' }),
|
||||
dataIndex: ['spec', 'product'],
|
||||
key: 'product',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (text: string) => (
|
||||
<AutoTooltip ghost maxWidth={200}>
|
||||
{text || '-'}
|
||||
</AutoTooltip>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'resources.table.vendor' }),
|
||||
dataIndex: ['spec', 'manufacturer'],
|
||||
key: 'manufacturer',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (value: string) =>
|
||||
value ? (
|
||||
<ThemeTag
|
||||
color={manufactureColorMap[value] ?? 'purple'}
|
||||
style={{ fontWeight: 400, width: 'fit-content' }}
|
||||
>
|
||||
{formatManufacturer(value)}
|
||||
</ThemeTag>
|
||||
) : (
|
||||
'-'
|
||||
)
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'gpuservice.instance.memory' }),
|
||||
dataIndex: ['spec', 'memory'],
|
||||
key: 'memory',
|
||||
ellipsis: { showTitle: false },
|
||||
// Non-acceleratable (generic) types have no VRAM concept → N/A.
|
||||
render: (value: string, record: ListItem) =>
|
||||
record.spec?.acceleratable
|
||||
? formatMemoryDisplay(value ?? undefined) || '-'
|
||||
: 'N/A'
|
||||
},
|
||||
// {
|
||||
// title: intl.formatMessage({ id: 'gpuservice.instance.sliceable' }),
|
||||
// dataIndex: ['spec', 'sliceable'],
|
||||
// key: 'sliceable',
|
||||
// ellipsis: { showTitle: false },
|
||||
// render: (value: boolean) =>
|
||||
// value
|
||||
// ? intl.formatMessage({ id: 'common.table.yes' })
|
||||
// : intl.formatMessage({ id: 'common.table.no' })
|
||||
// },
|
||||
{
|
||||
title: (
|
||||
<TitleWithTip
|
||||
title={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitCpu'
|
||||
})}
|
||||
tip={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitCpu.tip'
|
||||
})}
|
||||
/>
|
||||
),
|
||||
dataIndex: ['spec', 'unitResources', 'cpu'],
|
||||
key: 'cpu',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (value: string) => {
|
||||
const cores = ceilMilliToCore(value ?? null)?.cores;
|
||||
return cores != null ? `${cores} vCPU` : '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<TitleWithTip
|
||||
title={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitRam'
|
||||
})}
|
||||
tip={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.unitRam.tip'
|
||||
})}
|
||||
/>
|
||||
),
|
||||
dataIndex: ['spec', 'unitResources', 'ram'],
|
||||
key: 'ram',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (value: string) => {
|
||||
const gi = parseQuantityToGi(value ?? null)?.value;
|
||||
return gi != null ? `${gi} GB` : '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: (
|
||||
<TitleWithTip
|
||||
title={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.localStorage'
|
||||
})}
|
||||
tip={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.localStorage.tip'
|
||||
})}
|
||||
/>
|
||||
),
|
||||
dataIndex: ['spec', 'localStorage'],
|
||||
key: 'localStorage',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (value: string) => {
|
||||
const gi = parseQuantityToGi(value ?? null)?.value;
|
||||
return gi != null ? `${gi} GB` : '-';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'gpuservice.instance.os' }),
|
||||
key: 'os',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (_text, record: ListItem) => {
|
||||
const os = _.capitalize(record.spec?.os || '');
|
||||
const arch = _.toUpper(record.spec?.arch || '');
|
||||
if (!os) return '-';
|
||||
return arch ? `${os} (${arch})` : os;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'common.table.status' }),
|
||||
dataIndex: ['status', 'phase'],
|
||||
key: 'status',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (value: string, record: ListItem) =>
|
||||
value ? (
|
||||
<StatusTag
|
||||
statusValue={{
|
||||
status: phaseStatusMap[value],
|
||||
text: InstanceTypePhaseLabelMap[value] || value,
|
||||
message: record.status?.phaseMessage || ''
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
'-'
|
||||
)
|
||||
},
|
||||
{
|
||||
title: intl.formatMessage({ id: 'common.table.operation' }),
|
||||
key: 'operation',
|
||||
dataIndex: 'operation',
|
||||
ellipsis: { showTitle: false },
|
||||
render: (_text, record: ListItem) => (
|
||||
<DropdownButtons
|
||||
items={rowActions}
|
||||
onSelect={(val: string) => handleSelect(val, record)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
];
|
||||
}, [handleSelect, intl]);
|
||||
};
|
||||
|
||||
export default useInstanceTypeColumns;
|
||||
@@ -1,231 +0,0 @@
|
||||
import { ProviderValueMap } from '@/pages/cluster-management/config';
|
||||
import { useQueryClusterList } from '@/pages/cluster-management/services/use-query-cluster-list';
|
||||
import {
|
||||
BaseSelect,
|
||||
DeleteModal,
|
||||
FilterBar,
|
||||
IconFont,
|
||||
NoResult
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { ConfigProvider, Divider, Flex, Table, message } from 'antd';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import PageBox, { HeaderLeft } from '../../_components/page-box';
|
||||
import { deleteGPUInstanceType } from './apis';
|
||||
import AddInstanceTypeModal from './components/add-instance-type-modal';
|
||||
import { FormData, ListItem } from './config/types';
|
||||
import useCreateInstanceTypeModal from './hooks/use-create-instance-type-modal';
|
||||
import useInstanceTypeColumns from './hooks/use-instance-type-columns';
|
||||
import useCreateInstanceType from './services/use-create-instance-type';
|
||||
import useQueryInstanceTypes from './services/use-query-instance-types';
|
||||
|
||||
const GPUServiceInstanceTypes: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const deleteModalRef = useRef<any>(null);
|
||||
const [clusterId, setClusterId] = useState<number | undefined>();
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
const {
|
||||
clusterList,
|
||||
fetchClusterList,
|
||||
loading: clusterLoading
|
||||
} = useQueryClusterList();
|
||||
const {
|
||||
dataList,
|
||||
loading: instanceTypesLoading,
|
||||
fetchInstanceTypes
|
||||
} = useQueryInstanceTypes();
|
||||
const { fetchData: createInstanceType } = useCreateInstanceType();
|
||||
const {
|
||||
openInstanceTypeModalStatus,
|
||||
openInstanceTypeModal,
|
||||
closeInstanceTypeModal
|
||||
} = useCreateInstanceTypeModal();
|
||||
|
||||
// Only Kubernetes clusters own GPU instance types.
|
||||
const k8sClusters = useMemo(
|
||||
() => clusterList.filter((c) => c.provider === ProviderValueMap.Kubernetes),
|
||||
[clusterList]
|
||||
);
|
||||
|
||||
// Fetch the visible clusters, default to the first Kubernetes one, then load
|
||||
// its instance types. Action-driven: subsequent loads fire from the cluster
|
||||
// picker / refresh, never from an effect dependency.
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
const items = await fetchClusterList({ page: -1 });
|
||||
const firstK8s = (items || []).find(
|
||||
(c: any) => c.provider === ProviderValueMap.Kubernetes
|
||||
);
|
||||
if (firstK8s?.id != null) {
|
||||
setClusterId(firstK8s.id);
|
||||
await fetchInstanceTypes(firstK8s.id);
|
||||
}
|
||||
setLoaded(true);
|
||||
};
|
||||
init();
|
||||
}, []);
|
||||
|
||||
const handleClusterChange = useMemoizedFn((value: number) => {
|
||||
setClusterId(value);
|
||||
setKeyword('');
|
||||
fetchInstanceTypes(value);
|
||||
});
|
||||
|
||||
const handleRefresh = useMemoizedFn(() => {
|
||||
if (clusterId != null) {
|
||||
fetchInstanceTypes(clusterId);
|
||||
}
|
||||
});
|
||||
|
||||
const handleNameChange = useMemoizedFn(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setKeyword(e.target.value);
|
||||
}
|
||||
);
|
||||
|
||||
const handleAdd = useMemoizedFn(() => {
|
||||
openInstanceTypeModal(
|
||||
intl.formatMessage({ id: 'gpuservice.instanceType.add' })
|
||||
);
|
||||
});
|
||||
|
||||
const handleModalOk = useMemoizedFn(async (data: FormData) => {
|
||||
if (clusterId == null) return;
|
||||
try {
|
||||
await createInstanceType({ cluster_id: clusterId, data });
|
||||
closeInstanceTypeModal();
|
||||
message.success(intl.formatMessage({ id: 'common.message.success' }));
|
||||
fetchInstanceTypes(clusterId);
|
||||
} catch (error) {
|
||||
// handled by the request interceptor
|
||||
}
|
||||
});
|
||||
|
||||
const handleDelete = useMemoizedFn((record: ListItem) => {
|
||||
if (clusterId == null) return;
|
||||
deleteModalRef.current?.show({
|
||||
content: intl.formatMessage({ id: 'gpuservice.instanceType' }),
|
||||
operation: 'common.delete.single.confirm',
|
||||
name: record.name,
|
||||
async onOk() {
|
||||
await deleteGPUInstanceType({
|
||||
name: record.name,
|
||||
cluster_id: clusterId
|
||||
});
|
||||
fetchInstanceTypes(clusterId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const handleSelect = useMemoizedFn((val: string, record: ListItem) => {
|
||||
if (val === 'delete') {
|
||||
handleDelete(record);
|
||||
}
|
||||
});
|
||||
|
||||
const columns = useInstanceTypeColumns({ handleSelect });
|
||||
|
||||
const filteredList = useMemo(() => {
|
||||
const trimmed = keyword.trim().toLowerCase();
|
||||
if (!trimmed) return dataList;
|
||||
return dataList.filter((item) => item.name.toLowerCase().includes(trimmed));
|
||||
}, [dataList, keyword]);
|
||||
|
||||
const hasK8sCluster = k8sClusters.length > 0;
|
||||
|
||||
const renderEmpty = (type?: string) => {
|
||||
if (type !== 'Table') return;
|
||||
return (
|
||||
<NoResult
|
||||
loading={instanceTypesLoading || clusterLoading}
|
||||
loadend={loaded}
|
||||
dataSource={filteredList}
|
||||
image={<IconFont type="icon-gpu1" />}
|
||||
filters={keyword ? { search: keyword } : undefined}
|
||||
noFoundText={intl.formatMessage({
|
||||
id: 'noresult.gpuservice.instanceType.nofound'
|
||||
})}
|
||||
title={intl.formatMessage({
|
||||
id: 'noresult.gpuservice.instanceType.title'
|
||||
})}
|
||||
subTitle={
|
||||
hasK8sCluster
|
||||
? intl.formatMessage({
|
||||
id: 'noresult.gpuservice.instanceType.subTitle'
|
||||
})
|
||||
: intl.formatMessage({ id: 'noresult.resources.k8sCluster' })
|
||||
}
|
||||
{...(hasK8sCluster
|
||||
? {
|
||||
onClick: handleAdd,
|
||||
buttonText: intl.formatMessage({ id: 'noresult.button.add' })
|
||||
}
|
||||
: {})}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeaderLeft>
|
||||
<Flex align="center">
|
||||
<span className="font-600">
|
||||
{intl.formatMessage({ id: 'gpuservice.instance.types' })}
|
||||
</span>
|
||||
<Divider orientation="vertical" style={{ margin: '0 16px' }} />
|
||||
<BaseSelect
|
||||
size="small"
|
||||
variant="borderless"
|
||||
style={{ minWidth: 160 }}
|
||||
popupMatchSelectWidth={false}
|
||||
options={k8sClusters}
|
||||
value={clusterId}
|
||||
onChange={handleClusterChange}
|
||||
/>
|
||||
</Flex>
|
||||
</HeaderLeft>
|
||||
<PageBox>
|
||||
<FilterBar
|
||||
marginBottom={22}
|
||||
marginTop={30}
|
||||
showSelect={false}
|
||||
inputHolder={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.filter.name'
|
||||
})}
|
||||
buttonText={intl.formatMessage({
|
||||
id: 'gpuservice.instanceType.add'
|
||||
})}
|
||||
handleSearch={handleRefresh}
|
||||
handleClickPrimary={hasK8sCluster ? handleAdd : undefined}
|
||||
handleInputChange={handleNameChange}
|
||||
widths={{ input: 300 }}
|
||||
/>
|
||||
<ConfigProvider renderEmpty={renderEmpty}>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={filteredList}
|
||||
loading={{
|
||||
spinning: instanceTypesLoading || clusterLoading,
|
||||
size: 'middle'
|
||||
}}
|
||||
rowKey={(record) => record.name}
|
||||
pagination={false}
|
||||
/>
|
||||
</ConfigProvider>
|
||||
</PageBox>
|
||||
<AddInstanceTypeModal
|
||||
open={openInstanceTypeModalStatus.open}
|
||||
title={openInstanceTypeModalStatus.title}
|
||||
clusterId={clusterId}
|
||||
onCancel={closeInstanceTypeModal}
|
||||
onOk={handleModalOk}
|
||||
/>
|
||||
<DeleteModal ref={deleteModalRef} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default GPUServiceInstanceTypes;
|
||||
@@ -1,35 +0,0 @@
|
||||
import { useQueryData } from '@gpustack/core-ui';
|
||||
import { useCallback } from 'react';
|
||||
import { createGPUInstanceType } from '../apis';
|
||||
import { FormData, ListItem } from '../config/types';
|
||||
|
||||
interface CreateInstanceTypeParams {
|
||||
cluster_id: number;
|
||||
data: FormData;
|
||||
}
|
||||
|
||||
export default function useCreateInstanceType() {
|
||||
const fetchDetail = useCallback(
|
||||
(params: CreateInstanceTypeParams) =>
|
||||
createGPUInstanceType({
|
||||
cluster_id: params.cluster_id,
|
||||
data: params.data
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
const { detailData, loading, cancelRequest, fetchData } = useQueryData<
|
||||
ListItem,
|
||||
CreateInstanceTypeParams
|
||||
>({
|
||||
fetchDetail,
|
||||
key: 'createInstanceType'
|
||||
});
|
||||
|
||||
return {
|
||||
detailData,
|
||||
loading,
|
||||
cancelRequest,
|
||||
fetchData
|
||||
};
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
import { createAxiosToken } from '@/hooks/use-chunk-request';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { CancelTokenSource } from 'axios';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { queryGPUInstanceTypeFlavors } from '../apis';
|
||||
import { FlavorItem } from '../config/types';
|
||||
|
||||
// Cluster-scoped flavors for the create drawer's first column. Fetched when
|
||||
// the drawer opens (and on cluster change), never via an effect dependency.
|
||||
export default function useQueryFlavors() {
|
||||
const tokenRef = useRef<CancelTokenSource | null>(null);
|
||||
const [dataList, setDataList] = useState<FlavorItem[]>([]);
|
||||
|
||||
const {
|
||||
runAsync: fetchFlavors,
|
||||
loading,
|
||||
cancel
|
||||
} = useRequest(
|
||||
async (clusterId: number) => {
|
||||
tokenRef.current?.cancel();
|
||||
tokenRef.current = createAxiosToken();
|
||||
const res = await queryGPUInstanceTypeFlavors(
|
||||
{ cluster_id: clusterId },
|
||||
{ token: tokenRef.current.token }
|
||||
);
|
||||
const list = res?.items || [];
|
||||
setDataList(list);
|
||||
return list;
|
||||
},
|
||||
{
|
||||
manual: true,
|
||||
onError: (error: any) => {
|
||||
if (error?.message === 'CANCEL_PREVIOUS_REQUEST') return;
|
||||
setDataList([]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const cancelRequest = () => {
|
||||
cancel();
|
||||
tokenRef.current?.cancel('CANCEL_PREVIOUS_REQUEST');
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
cancel();
|
||||
tokenRef.current?.cancel();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
dataList,
|
||||
loading,
|
||||
fetchFlavors,
|
||||
cancelRequest,
|
||||
setDataList
|
||||
};
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import { createAxiosToken } from '@/hooks/use-chunk-request';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { CancelTokenSource } from 'axios';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { queryGPUInstanceTypes } from '../apis';
|
||||
import { ListItem } from '../config/types';
|
||||
|
||||
// Cluster-scoped instance types for the management list. Action-driven:
|
||||
// call fetchInstanceTypes(clusterId) from the cluster picker / refresh, not
|
||||
// via an effect dependency.
|
||||
export default function useQueryInstanceTypes() {
|
||||
const tokenRef = useRef<CancelTokenSource | null>(null);
|
||||
const [dataList, setDataList] = useState<ListItem[]>([]);
|
||||
|
||||
const {
|
||||
runAsync: fetchInstanceTypes,
|
||||
loading,
|
||||
cancel
|
||||
} = useRequest(
|
||||
async (clusterId: number) => {
|
||||
tokenRef.current?.cancel();
|
||||
tokenRef.current = createAxiosToken();
|
||||
const res = await queryGPUInstanceTypes(
|
||||
{ cluster_id: clusterId },
|
||||
{ token: tokenRef.current.token }
|
||||
);
|
||||
const list = res?.items || [];
|
||||
setDataList(list);
|
||||
return list;
|
||||
},
|
||||
{
|
||||
manual: true,
|
||||
onError: (error: any) => {
|
||||
// Ignore the synthetic cancel error from switching clusters quickly.
|
||||
if (error?.message === 'CANCEL_PREVIOUS_REQUEST') return;
|
||||
setDataList([]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const cancelRequest = () => {
|
||||
cancel();
|
||||
tokenRef.current?.cancel('CANCEL_PREVIOUS_REQUEST');
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
cancel();
|
||||
tokenRef.current?.cancel();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
dataList,
|
||||
loading,
|
||||
fetchInstanceTypes,
|
||||
cancelRequest,
|
||||
setDataList
|
||||
};
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
// ============ create drawer (two-column: flavors | form) ============
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.colWrapper {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.formWrapper {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panelBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.stickyHead {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
background-color: var(--ant-color-bg-elevated);
|
||||
}
|
||||
|
||||
.flavorCard {
|
||||
height: auto !important;
|
||||
min-height: 96px;
|
||||
}
|
||||
|
||||
// ============ list card (Linear-style, minimal) ============
|
||||
.listCard {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// --- level 1: identity + status + actions ---
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.name {
|
||||
min-width: 0;
|
||||
font-size: 13px;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
}
|
||||
|
||||
.headerRight {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// --- level 2: hero (model + memory) ---
|
||||
.hero {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.product {
|
||||
min-width: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color: var(--ant-color-text);
|
||||
}
|
||||
|
||||
.memory {
|
||||
flex-shrink: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color: var(--ant-color-text);
|
||||
}
|
||||
|
||||
.subline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
min-height: 22px;
|
||||
font-size: 13px;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
}
|
||||
|
||||
.tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: var(--ant-border-radius-sm);
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.tagSliceable {
|
||||
color: var(--ant-color-primary);
|
||||
background-color: var(--ant-color-primary-bg);
|
||||
}
|
||||
|
||||
.tagPlain {
|
||||
color: var(--ant-color-text-tertiary);
|
||||
background-color: var(--ant-color-fill-tertiary);
|
||||
}
|
||||
|
||||
// --- level 3: base resources ---
|
||||
.divider {
|
||||
height: 1px;
|
||||
margin: 16px 0;
|
||||
background-color: var(--ant-color-border-secondary);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.footer {
|
||||
font-size: 14px;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
}
|
||||
|
||||
.dotSep {
|
||||
margin: 0 8px;
|
||||
color: var(--ant-color-text-quaternary);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
|
||||
export const GPU_SERVICE_INSTANCES_API = '/gpu-instances';
|
||||
|
||||
export const GPU_SERVICE_INSTANCES_TYPE_API = '/gpu-instance-types/aggregated';
|
||||
export const GPU_SERVICE_INSTANCES_TYPE_API = '/gpu-instance-types';
|
||||
|
||||
// View logs / events still go through the K8s proxy until the /v2
|
||||
// /gpu-instances API exposes equivalents. clusterID and namespace come
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import PluginExtraFields from '@/components/plugin-extra-fields';
|
||||
import { AutoTooltip, IconFont, ThemeTag } from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Flex, Tag } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import styled from 'styled-components';
|
||||
import { manufactureColorMap } from '../../templates/config';
|
||||
import { formatManufacturer } from '../../utils';
|
||||
import { formatMemoryDisplay } from '../config';
|
||||
import { InstanceTypeItem as InstanceTypeItemModel } from '../config/types';
|
||||
|
||||
const Vendors = ['intel'] as const;
|
||||
|
||||
const Title = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -58,9 +58,6 @@ interface InstanceTypeItemProps {
|
||||
|
||||
interface MetadataSectionProps {
|
||||
spec: InstanceTypeItemModel['spec'];
|
||||
// status.onceMaxRequest.acceleratorSliced (max sliceable percentage). Shown
|
||||
// next to Max for sliceable types.
|
||||
slicedMaxPercentage?: number;
|
||||
}
|
||||
|
||||
const MetaItem: React.FC<{
|
||||
@@ -119,95 +116,109 @@ function getInstanceDerived(item: InstanceTypeItemModel) {
|
||||
ramUnit: spec.unitResourcesParsed?.ram?.value,
|
||||
os: _.capitalize(spec.os) || '',
|
||||
arch: spec.arch,
|
||||
cpuManufacturer: formatManufacturer(cpuManufacturer),
|
||||
cpuManufacturer: Vendors.includes(cpuManufacturer as any)
|
||||
? _.capitalize(cpuManufacturer)
|
||||
: _.toUpper(cpuManufacturer),
|
||||
cpuUnitCores: spec.unitResourcesParsed?.cpu?.cores
|
||||
};
|
||||
}
|
||||
|
||||
type MetaEntry = { icon: string; label?: string; value: React.ReactNode };
|
||||
|
||||
// All rows share a single grid so columns — and therefore icons — line up
|
||||
// vertically. Each item is 3 cells (icon/label/value); every item past the
|
||||
// first adds a leading dot cell, so a row of k items spans 4k-1 cells. A short
|
||||
// row is padded with a spanning spacer so the next row restarts at column 1.
|
||||
const renderMetaRow = (items: MetaEntry[], columns: number, rowKey: string) => {
|
||||
const cells = items.map((item, index) => (
|
||||
<MetaItem
|
||||
key={`${rowKey}-${item.icon}`}
|
||||
showDot={index > 0}
|
||||
icon={item.icon}
|
||||
label={item.label}
|
||||
value={item.value}
|
||||
/>
|
||||
));
|
||||
const remaining = columns - (4 * items.length - 1);
|
||||
if (remaining > 0) {
|
||||
cells.push(
|
||||
<span
|
||||
key={`${rowKey}-spacer`}
|
||||
style={{ gridColumn: `span ${remaining}` }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return cells;
|
||||
};
|
||||
|
||||
export const InstanceMetadataSection: React.FC<MetadataSectionProps> = ({
|
||||
spec,
|
||||
slicedMaxPercentage
|
||||
spec
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
|
||||
const { ramUnit, cpuUnitCores, isGPU, arch } = getInstanceDerived({
|
||||
const { ramUnit, cpuUnitCores, isGPU, os, arch } = getInstanceDerived({
|
||||
spec
|
||||
} as InstanceTypeItemModel);
|
||||
|
||||
// Sliceable types append a "Sliceable {n}%" cell to the second row.
|
||||
const showSliceable = !!spec.sliceable && (slicedMaxPercentage ?? 0) > 0;
|
||||
|
||||
const cpuItem: MetaEntry = {
|
||||
icon: 'icon-cpu',
|
||||
label: 'CPU',
|
||||
value: cpuUnitCores || '-'
|
||||
};
|
||||
const ramItem: MetaEntry = {
|
||||
icon: 'icon-ram-02',
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.ram' }),
|
||||
value: ramUnit ? `${ramUnit} GB` : '-'
|
||||
};
|
||||
const memoryItem: MetaEntry = {
|
||||
icon: 'icon-gpu1',
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.memory' }),
|
||||
value: formatMemoryDisplay(spec?.memory ?? undefined) ?? '-'
|
||||
};
|
||||
const archItem: MetaEntry = {
|
||||
icon: 'icon-cube',
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.arch' }),
|
||||
value: _.toUpper(arch) || '-'
|
||||
};
|
||||
const maxItem: MetaEntry = {
|
||||
icon: 'icon-database',
|
||||
label: intl.formatMessage({ id: 'common.max' }, { count: '' }),
|
||||
value: `${spec.maxComputeUnitCount || 0}`
|
||||
};
|
||||
const slicedItem: MetaEntry = {
|
||||
icon: 'icon-sliced',
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.sliceable' }),
|
||||
value: `${slicedMaxPercentage}%`
|
||||
};
|
||||
|
||||
// GPU: 3 items/row → 11 cols. CPU: 2 items/row → 7 cols.
|
||||
const columns = isGPU ? 11 : 7;
|
||||
const rows: MetaEntry[][] = isGPU
|
||||
? [
|
||||
[ramItem, memoryItem, cpuItem],
|
||||
showSliceable ? [archItem, maxItem, slicedItem] : [archItem, maxItem]
|
||||
]
|
||||
: [[ramItem], [archItem, maxItem]];
|
||||
|
||||
return (
|
||||
<Meta $columns={columns}>
|
||||
{rows.map((row, index) => renderMetaRow(row, columns, `row-${index}`))}
|
||||
<Meta $columns={isGPU ? 11 : 7}>
|
||||
{isGPU && (
|
||||
<>
|
||||
{/* row 1: Memory | Max | RAM */}
|
||||
<MetaItem
|
||||
show={isGPU}
|
||||
showDot={false}
|
||||
icon="icon-gpu1"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.memory' })}
|
||||
value={formatMemoryDisplay(spec?.memory ?? undefined) ?? '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
showDot={true}
|
||||
icon="icon-ram-02"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.ram' })}
|
||||
value={ramUnit ? `${ramUnit} GB` : '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
icon="icon-database"
|
||||
label={intl.formatMessage(
|
||||
{
|
||||
id: 'common.max'
|
||||
},
|
||||
{ count: '' }
|
||||
)}
|
||||
value={`${spec.maxComputeUnitCount || 0}`}
|
||||
/>
|
||||
{/* row 2: OS | Arch | CPU */}
|
||||
<MetaItem
|
||||
showDot={false}
|
||||
icon="icon-server02"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.os' })}
|
||||
value={os || '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
icon="icon-cube"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.arch' })}
|
||||
value={_.toUpper(arch) || '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
show={isGPU}
|
||||
showDot={true}
|
||||
icon="icon-cpu"
|
||||
label="CPU"
|
||||
value={
|
||||
<Flex gap={4} align="center">
|
||||
<span>{cpuUnitCores || '-'}</span>
|
||||
</Flex>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!isGPU && (
|
||||
<>
|
||||
{/* row 1: RAM | Max */}
|
||||
<MetaItem
|
||||
showDot={false}
|
||||
icon="icon-ram-02"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.ram' })}
|
||||
value={ramUnit ? `${ramUnit} GB` : '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
icon="icon-database"
|
||||
label={intl.formatMessage(
|
||||
{
|
||||
id: 'common.max'
|
||||
},
|
||||
{ count: '' }
|
||||
)}
|
||||
value={`${spec.maxComputeUnitCount || 0}`}
|
||||
/>
|
||||
{/* row 2: OS | Arch */}
|
||||
<MetaItem
|
||||
showDot={false}
|
||||
icon="icon-server02"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.os' })}
|
||||
value={os || '-'}
|
||||
/>
|
||||
<MetaItem
|
||||
icon="icon-cube"
|
||||
label={intl.formatMessage({ id: 'gpuservice.instance.arch' })}
|
||||
value={_.toUpper(arch) || '-'}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Meta>
|
||||
);
|
||||
};
|
||||
@@ -248,7 +259,7 @@ const InstanceTypeItem: React.FC<InstanceTypeItemProps> = ({ item }) => {
|
||||
disabled={false}
|
||||
style={{ fontWeight: 400 }}
|
||||
>
|
||||
{formatManufacturer(manufacturer)}
|
||||
{manufacturer?.toUpperCase()}
|
||||
</ThemeTag>
|
||||
)}
|
||||
{showCpuManufacturerTag && (
|
||||
@@ -260,18 +271,9 @@ const InstanceTypeItem: React.FC<InstanceTypeItemProps> = ({ item }) => {
|
||||
{cpuManufacturer}
|
||||
</ThemeTag>
|
||||
)}
|
||||
<PluginExtraFields
|
||||
name="InstanceTypeBillingBadge"
|
||||
context={{ instanceType: item }}
|
||||
/>
|
||||
</Flex>
|
||||
</Title>
|
||||
<InstanceMetadataSection
|
||||
spec={specData}
|
||||
slicedMaxPercentage={
|
||||
Number(item.status?.onceMaxRequest?.acceleratorSliced) || 0
|
||||
}
|
||||
></InstanceMetadataSection>
|
||||
<InstanceMetadataSection spec={specData}></InstanceMetadataSection>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import PluginExtraFields from '@/components/plugin-extra-fields';
|
||||
import { FileSkeletonRows } from '@/pages/llmodels/components/model-source/file-skeleton';
|
||||
import { TemplateCard } from '@gpustack/core-ui';
|
||||
import { Empty, Flex, Spin } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { InstanceTypeItem as InstanceTypeItemModel } from '../config/types';
|
||||
import styles from '../styles/instances.module.less';
|
||||
import InstanceTypeItem from './instance-type-item';
|
||||
|
||||
interface InstanceTypeListProps {
|
||||
@@ -42,19 +40,15 @@ const InstanceTypeList: React.FC<InstanceTypeListProps> = ({
|
||||
|
||||
return (
|
||||
<Flex orientation="vertical" gap={16}>
|
||||
<PluginExtraFields
|
||||
name="InstanceTypeBillingProvider"
|
||||
context={{ instanceTypes: dataList }}
|
||||
/>
|
||||
{dataList.map((item) => {
|
||||
const name = item.name;
|
||||
return (
|
||||
<TemplateCard
|
||||
key={name}
|
||||
className={styles.instanceTypeCard}
|
||||
clickable
|
||||
ghost
|
||||
hoverable
|
||||
height={106}
|
||||
active={value === name}
|
||||
disabled={item.disabled}
|
||||
onClick={() => handleSelect(item)}
|
||||
|
||||
@@ -262,39 +262,32 @@ export const getAcceleratorMax = (
|
||||
|
||||
// Picks the candidate (cluster + type name) that should fulfill a requested
|
||||
// accelerator count: the first candidate of the smallest tier whose
|
||||
// onceMaxRequest.accelerator is >= the requested count. Accelerated types are
|
||||
// not gated on CPU remaining (only CPU-only types are); in sliced mode the
|
||||
// candidate's acceleratorSliced remaining must also be > 0.
|
||||
// onceMaxRequest.accelerator is >= the requested count and whose cpu/ram/localStorage
|
||||
// remaining are all > 0.
|
||||
export const pickCandidateForAccelerator = <
|
||||
C extends {
|
||||
cluster: string;
|
||||
name: string;
|
||||
cpu?: { remaining?: string | null } | null;
|
||||
acceleratorSliced?: { remaining?: string | null } | null;
|
||||
ram?: { remaining?: string | null } | null;
|
||||
localStorage?: { remaining?: string | null } | null;
|
||||
}
|
||||
>(
|
||||
tiers:
|
||||
| {
|
||||
onceMaxRequest: { accelerator?: string; acceleratorSliced?: string };
|
||||
onceMaxRequest: { accelerator?: string };
|
||||
candidates?: C[] | null;
|
||||
}[]
|
||||
| undefined
|
||||
| null,
|
||||
{
|
||||
count,
|
||||
acceleratable,
|
||||
sliced
|
||||
}: { count: number; acceleratable?: boolean; sliced?: boolean }
|
||||
{ count, acceleratable }: { count: number; acceleratable?: boolean }
|
||||
): C | null => {
|
||||
if (!tiers?.length) return null;
|
||||
|
||||
const hasResources = (c: C) => {
|
||||
// Accelerated types are not gated on CPU remaining; CPU-only types are.
|
||||
if (!acceleratable && parseQuantity(c.cpu?.remaining) <= 0) return false;
|
||||
if (sliced && parseQuantity(c.acceleratorSliced?.remaining) <= 0)
|
||||
return false;
|
||||
return true;
|
||||
};
|
||||
const hasResources = (c: C) =>
|
||||
parseQuantity(c.cpu?.remaining) > 0 &&
|
||||
parseQuantity(c.ram?.remaining) > 0 &&
|
||||
parseQuantity(c.localStorage?.remaining) > 0;
|
||||
|
||||
const sorted = [...tiers].sort(
|
||||
(a, b) =>
|
||||
@@ -305,12 +298,7 @@ export const pickCandidateForAccelerator = <
|
||||
// count === 0 ? parseQuantity(tier.onceMaxRequest.accelerator) > count; this is CPU-only case.
|
||||
for (const tier of sorted) {
|
||||
const acceleratorCount = parseQuantity(tier.onceMaxRequest?.accelerator);
|
||||
// Sliced mode requests a fraction of a single card, so the tier's
|
||||
// whole-card accelerator count (0 for a slice-only type) can't gate it;
|
||||
// fit on the tier's sliced capacity instead.
|
||||
const fits = sliced
|
||||
? parseQuantity(tier.onceMaxRequest?.acceleratorSliced) > 0
|
||||
: acceleratable
|
||||
const fits = acceleratable
|
||||
? acceleratorCount >= count
|
||||
: acceleratorCount === 0;
|
||||
if (!fits) continue;
|
||||
|
||||
@@ -45,11 +45,6 @@ export interface FormData {
|
||||
ram: string | null | number;
|
||||
localStorage: string | null | number;
|
||||
accelerator: number | string | null;
|
||||
// Sliced (percentage) mode only. Memory (VRAM) percentage bound to the
|
||||
// 10-100 selector + free input; cores (compute) percentage bound to the
|
||||
// "100% compute" checkbox (100 when checked, mirrors memory otherwise).
|
||||
acceleratorSlicedMemoryPercentage?: number;
|
||||
acceleratorSlicedCoresPercentage?: number;
|
||||
};
|
||||
volume: {
|
||||
ephemeral?: {
|
||||
@@ -133,10 +128,8 @@ export interface InstanceTypeCandidate {
|
||||
name: string;
|
||||
accelerator: InstanceTypeResource;
|
||||
cpu: InstanceTypeResource;
|
||||
// Shared-mode available resource (not shown in the GPU Instance form).
|
||||
acceleratorShared: InstanceTypeResource;
|
||||
// Sliced-mode available resource.
|
||||
acceleratorSliced: InstanceTypeResource;
|
||||
ram: InstanceTypeResource;
|
||||
localStorage: InstanceTypeResource;
|
||||
}
|
||||
|
||||
export interface InstanceTypeTierOnceMaxRequestResource {
|
||||
@@ -156,8 +149,6 @@ export interface InstanceTypeOnceMaxRequestResource {
|
||||
cpu: QuanityCPU;
|
||||
ram: QuanityMemory;
|
||||
localStorage: QuanityLocalStorage;
|
||||
acceleratorShared: `${number}` | null;
|
||||
acceleratorSliced: `${number}` | null;
|
||||
}
|
||||
|
||||
export interface CPUCache {
|
||||
@@ -190,8 +181,6 @@ export interface InstanceTypeSpec {
|
||||
family?: string | null;
|
||||
computeCapability?: string | null;
|
||||
sliced?: string | null;
|
||||
sliceable?: boolean;
|
||||
localStorage?: QuanityLocalStorage;
|
||||
maxComputeUnitCount?: number;
|
||||
unitResources?: {
|
||||
cpu: QuanityCPU;
|
||||
|
||||
@@ -273,103 +273,33 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
|
||||
const buildResourcesDataForSubmit = (values: FormData) => {
|
||||
const unitResourcesParsed = getUnitResources();
|
||||
const resources = values.spec?.resources ?? ({} as any);
|
||||
const accelerator = _.toNumber(resources.accelerator) || 0;
|
||||
const cpuCount = _.toNumber(resources.cpu) || 0;
|
||||
const accelerator = _.toNumber(values.spec?.resources?.accelerator) || 0;
|
||||
const cpuCount = _.toNumber(values.spec?.resources?.cpu) || 0;
|
||||
|
||||
const cpuNum = unitResourcesParsed?.cpu?.num;
|
||||
const ramNum = unitResourcesParsed?.ram?.num;
|
||||
|
||||
const fallbackCpu = resources.cpu;
|
||||
const fallbackCpu = values.spec?.resources?.cpu;
|
||||
|
||||
const percentage = _.toNumber(
|
||||
resources.acceleratorSlicedMemoryPercentage
|
||||
);
|
||||
const sliced = isGPUType && percentage > 0;
|
||||
const wholeFactor = isGPUType ? accelerator : cpuCount;
|
||||
const factor = isGPUType ? accelerator : cpuCount;
|
||||
|
||||
// Sliced mode: scale a single card's unit resources by the chosen
|
||||
// percentage. Scale CPU in millicores and RAM in MiB so fractional
|
||||
// slices stay precise and k8s-valid (integers) — e.g. 10% of a 4-core /
|
||||
// 16Gi card → 400m / 1638Mi, not a rounded-up 1 core / 1Gi.
|
||||
if (sliced && unitResourcesParsed) {
|
||||
const cpuCores = unitResourcesParsed.cpu?.cores ?? 0;
|
||||
const ramValue = unitResourcesParsed.ram?.value ?? 0;
|
||||
return {
|
||||
cpu: `${Math.max(1, _.floor((cpuCores * 1000 * percentage) / 100))}m`,
|
||||
ram: `${Math.max(1, _.floor((ramValue * 1024 * percentage) / 100))}Mi`
|
||||
};
|
||||
}
|
||||
|
||||
// Whole / CPU mode: multiply the unit by the count.
|
||||
return {
|
||||
cpu: cpuNum
|
||||
? `${wholeFactor * cpuNum}${unitResourcesParsed?.cpu?.unit || ''}`
|
||||
? `${factor * cpuNum}${unitResourcesParsed?.cpu?.unit || ''}`
|
||||
: // Don't stringify an unset value — `${undefined}` becomes the
|
||||
// literal "undefined", which fails k8s quantity validation.
|
||||
fallbackCpu
|
||||
? `${fallbackCpu}`
|
||||
: undefined,
|
||||
ram: ramNum
|
||||
? `${wholeFactor * ramNum}${unitResourcesParsed?.ram?.unit || ''}`
|
||||
: resources.ram
|
||||
? `${factor * ramNum}${unitResourcesParsed?.ram?.unit || ''}`
|
||||
: values.spec?.resources?.ram
|
||||
};
|
||||
};
|
||||
|
||||
// Sliced display: set the (disabled) CPU / RAM inputs to a single card's
|
||||
// unit resources scaled by the chosen percentage, floored. Reads the
|
||||
// percentage straight from the form so it can be re-run after any slider
|
||||
// change without threading values through.
|
||||
const applySlicedResourceScaling = () => {
|
||||
const unitResourcesParsed = getUnitResources();
|
||||
const cpuCores = unitResourcesParsed?.cpu?.cores;
|
||||
const ramValue = unitResourcesParsed?.ram?.value;
|
||||
const percentage = _.toNumber(
|
||||
form.getFieldValue([
|
||||
'spec',
|
||||
'resources',
|
||||
'acceleratorSlicedMemoryPercentage'
|
||||
])
|
||||
);
|
||||
|
||||
form.setFieldsValue({
|
||||
spec: {
|
||||
resources: {
|
||||
// Display the precise (rounded) fractional values — the inputs are
|
||||
// disabled, so decimals are fine and match the submitted
|
||||
// millicore / MiB allocation better than a floored integer.
|
||||
cpu:
|
||||
cpuCores != null && percentage > 0
|
||||
? _.round((cpuCores * percentage) / 100, 2)
|
||||
: null,
|
||||
ram:
|
||||
ramValue != null && percentage > 0
|
||||
? _.round((ramValue * percentage) / 100, 2)
|
||||
: null
|
||||
}
|
||||
}
|
||||
} as any);
|
||||
};
|
||||
|
||||
// Single entry point for the sliced memory ratio: write the ratio (compute
|
||||
// stays pinned at 100%) and rescale CPU / RAM off it. Reused by the slider
|
||||
// onChange and by the sliced-mode defaults so both share one path.
|
||||
const applySliceMemoryPercentage = (value: number) => {
|
||||
form.setFieldsValue({
|
||||
spec: {
|
||||
resources: {
|
||||
acceleratorSlicedMemoryPercentage: value,
|
||||
acceleratorSlicedCoresPercentage: 100
|
||||
}
|
||||
}
|
||||
} as any);
|
||||
applySlicedResourceScaling();
|
||||
};
|
||||
|
||||
const resolveAndApply = (
|
||||
instanceType: InstanceTypeItem | undefined,
|
||||
count: number,
|
||||
sliced?: boolean
|
||||
count: number
|
||||
) => {
|
||||
if (!instanceType) {
|
||||
setSelectedInstanceType(undefined);
|
||||
@@ -398,8 +328,7 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
instanceType.status?.tiers,
|
||||
{
|
||||
count,
|
||||
acceleratable: instanceType.spec?.acceleratable,
|
||||
sliced
|
||||
acceleratable: instanceType.spec?.acceleratable
|
||||
}
|
||||
);
|
||||
|
||||
@@ -407,12 +336,9 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
|
||||
setOnceMaxRequest({
|
||||
cpu: ceilMilliToCore(candidate?.cpu?.onceMaxRequest)?.cores,
|
||||
// candidate no longer carries ram/localStorage: memory max comes from
|
||||
// the type-level onceMaxRequest.ram (already parsed to a Gi number by
|
||||
// the query hook), disk max from spec.localStorage (UI-only cap).
|
||||
memory: _.toNumber(instanceType.status?.onceMaxRequest?.ram) || null,
|
||||
localStorage:
|
||||
parseQuantityToGi(instanceType.spec?.localStorage)?.value ?? null
|
||||
memory: parseQuantityToGi(candidate?.ram?.onceMaxRequest)?.value,
|
||||
localStorage: parseQuantityToGi(candidate?.localStorage?.onceMaxRequest)
|
||||
?.value
|
||||
});
|
||||
|
||||
form.setFieldsValue({
|
||||
@@ -428,44 +354,8 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
});
|
||||
};
|
||||
|
||||
// Whole-card (exclusive) vs sliced (percentage) mode. Only meaningful for
|
||||
// sliceable accelerator types; derived (no persisted field) — on edit/
|
||||
// recreate it is inferred from acceleratorSlicedMemoryPercentage > 0.
|
||||
const [sliceMode, setSliceMode] = useState<'whole' | 'sliced'>('whole');
|
||||
|
||||
const handleAcceleratorChange = (count: number) => {
|
||||
resolveAndApply(selectedInstanceType, count, false);
|
||||
};
|
||||
|
||||
// Seed the sliced-mode default ratio for an instance type: 10% but never
|
||||
// above the type's max sliceable ratio (status.onceMaxRequest
|
||||
// .acceleratorSliced). Shares applySliceMemoryPercentage with the slider.
|
||||
const applySlicedDefaults = (instanceType?: InstanceTypeItem) => {
|
||||
const slicedMax =
|
||||
_.toNumber(instanceType?.status?.onceMaxRequest?.acceleratorSliced) ||
|
||||
0;
|
||||
applySliceMemoryPercentage(slicedMax ? Math.min(10, slicedMax) : 10);
|
||||
};
|
||||
|
||||
// Toggle between whole-card and sliced mode. Sliced fixes the accelerator
|
||||
// count to 1 (a single card is partitioned by percentage) and clears the
|
||||
// slice-percentage fields when leaving sliced mode.
|
||||
const handleSliceModeChange = (mode: 'whole' | 'sliced') => {
|
||||
setSliceMode(mode);
|
||||
if (mode === 'sliced') {
|
||||
resolveAndApply(selectedInstanceType, 1, true);
|
||||
applySlicedDefaults(selectedInstanceType);
|
||||
} else {
|
||||
form.setFieldsValue({
|
||||
spec: {
|
||||
resources: {
|
||||
acceleratorSlicedMemoryPercentage: undefined,
|
||||
acceleratorSlicedCoresPercentage: undefined
|
||||
}
|
||||
}
|
||||
} as any);
|
||||
resolveAndApply(selectedInstanceType, 1, false);
|
||||
}
|
||||
resolveAndApply(selectedInstanceType, count);
|
||||
};
|
||||
|
||||
const onTargetChange = (key: string) => {
|
||||
@@ -517,14 +407,6 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
? _.toNumber(currentData?.spec?.resources?.accelerator)
|
||||
: _.toNumber(currentData?.spec?.resources?.cpu) || 0;
|
||||
|
||||
// Infer the mode from the persisted slice percentage (recreate keeps
|
||||
// the section editable; edit/view render a readonly card).
|
||||
const persistedSliced =
|
||||
_.toNumber(
|
||||
currentData?.spec?.resources?.acceleratorSlicedMemoryPercentage
|
||||
) > 0;
|
||||
setSliceMode(persistedSliced ? 'sliced' : 'whole');
|
||||
|
||||
form.setFieldsValue({
|
||||
...currentData,
|
||||
spec: {
|
||||
@@ -542,12 +424,6 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
enable_ssh: !!currentData?.spec?.sshPublicKeys?.length,
|
||||
storageMode: detectMode(currentData?.spec?.volume)
|
||||
});
|
||||
|
||||
// buildResourcesData above filled CPU / RAM for the whole card; rescale
|
||||
// them off the persisted percentages when recreating a sliced instance.
|
||||
if (persistedSliced) {
|
||||
applySlicedResourceScaling();
|
||||
}
|
||||
}
|
||||
}, [action, currentData, form, open, realAction, instanceTypeList]);
|
||||
|
||||
@@ -616,30 +492,11 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
getFieldsValue: () => form.getFieldsValue(),
|
||||
applyInstanceType: (instanceType?: InstanceTypeItem) => {
|
||||
if (!instanceType) {
|
||||
setSliceMode('whole');
|
||||
resolveAndApply(undefined, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// A sliceable type with no whole-card capacity (Max < 1) defaults to
|
||||
// sliced mode — whole mode would have nothing selectable.
|
||||
const wholeMax = instanceType.spec?.maxComputeUnitCount ?? 0;
|
||||
const slicedMax =
|
||||
_.toNumber(instanceType.status?.onceMaxRequest?.acceleratorSliced) ||
|
||||
0;
|
||||
const defaultSliced =
|
||||
!!instanceType.spec?.sliceable && wholeMax < 1 && slicedMax > 0;
|
||||
|
||||
if (defaultSliced) {
|
||||
setSliceMode('sliced');
|
||||
resolveAndApply(instanceType, 1, true);
|
||||
applySlicedDefaults(instanceType);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise default to whole-card mode (a new type may not be
|
||||
// sliceable); set count to 1 for all instance types: GPU or non-GPU.
|
||||
setSliceMode('whole');
|
||||
// set default to 1, for all instance types: GPU or non-GPU
|
||||
resolveAndApply(instanceType, 1);
|
||||
}
|
||||
}));
|
||||
@@ -750,9 +607,6 @@ const GPUServiceInstanceForm: React.FC<InstanceFormProps> = forwardRef(
|
||||
currentData={currentData as any}
|
||||
onceMaxRequest={onceMaxRequest}
|
||||
noAvailableTypes={noAvailableInstanceTypes}
|
||||
sliceMode={sliceMode}
|
||||
onSliceModeChange={handleSliceModeChange}
|
||||
onSliceMemoryPercentageChange={applySliceMemoryPercentage}
|
||||
onGPUCountChange={handleAcceleratorChange}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PageActionType } from '@/config/types';
|
||||
import NumberSelection from '@/pages/_components/number-selection';
|
||||
import { InputNumber } from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Flex, Form, Segmented } from 'antd';
|
||||
import { Flex, Form } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import { useContext, useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
@@ -57,9 +57,6 @@ const InstanceTypePicker: React.FC<InstanceTypePickerProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
// Fixed 10-tick percentage scale (10..100) for the sliced (percentage) mode.
|
||||
const SLICE_PERCENT_TICKS = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
||||
|
||||
interface InstanceTypeFormItemProps {
|
||||
action: PageActionType;
|
||||
disabled?: boolean;
|
||||
@@ -70,12 +67,6 @@ interface InstanceTypeFormItemProps {
|
||||
// org owns no clusters. Surface a "no available" message instead of the
|
||||
// "please select" placeholder + empty CPU / memory inputs.
|
||||
noAvailableTypes?: boolean;
|
||||
// Whole-card (exclusive) vs sliced (percentage) mode. Owned by the parent
|
||||
// form (it drives candidate picking + the fixed accelerator=1 for sliced).
|
||||
sliceMode?: 'whole' | 'sliced';
|
||||
onSliceModeChange?: (mode: 'whole' | 'sliced') => void;
|
||||
// Commit a new sliced memory ratio (writes the field + rescales CPU / RAM).
|
||||
onSliceMemoryPercentageChange?: (value: number) => void;
|
||||
onGPUCountChange?: (value: number) => void;
|
||||
}
|
||||
|
||||
@@ -86,13 +77,9 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
selectedInstanceType,
|
||||
onceMaxRequest,
|
||||
noAvailableTypes,
|
||||
sliceMode = 'whole',
|
||||
onSliceModeChange,
|
||||
onSliceMemoryPercentageChange,
|
||||
onGPUCountChange
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const form = Form.useFormInstance();
|
||||
const { isGPUType } = useContext(FormContext);
|
||||
|
||||
const maxComputeUnitCount = useMemo(() => {
|
||||
@@ -117,62 +104,6 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
onGPUCountChange?.(value);
|
||||
};
|
||||
|
||||
// Sliced mode is only offered for sliceable accelerator types, and only when
|
||||
// the section is editable (create / recreate; edit renders a readonly card).
|
||||
const showModeSwitch =
|
||||
action !== PageAction.EDIT &&
|
||||
isGPUType &&
|
||||
!!selectedInstanceType?.spec?.sliceable;
|
||||
|
||||
const handleModeChange = (value: string) => {
|
||||
onSliceModeChange?.(value as 'whole' | 'sliced');
|
||||
};
|
||||
|
||||
// Memory (VRAM) percentage changed via the slider/input — forward the new
|
||||
// value so the parent writes the field and rescales CPU / RAM.
|
||||
const handleMemoryPercentageChange = (value: number) => {
|
||||
onSliceMemoryPercentageChange?.(value);
|
||||
};
|
||||
|
||||
// Max selectable ratio in sliced mode: status.onceMaxRequest.acceleratorSliced
|
||||
// (a percentage). Ticks above it stay visible but disabled.
|
||||
const slicedMaxPercentage =
|
||||
_.toNumber(
|
||||
selectedInstanceType?.status?.onceMaxRequest?.acceleratorSliced
|
||||
) || 0;
|
||||
|
||||
const modeSegmented = showModeSwitch ? (
|
||||
<Segmented
|
||||
size="small"
|
||||
shape="round"
|
||||
style={{ fontSize: 12 }}
|
||||
value={sliceMode}
|
||||
disabled={disabled}
|
||||
onChange={handleModeChange}
|
||||
options={[
|
||||
{
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.mode.whole' }),
|
||||
value: 'whole'
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({ id: 'gpuservice.instance.mode.sliced' }),
|
||||
value: 'sliced',
|
||||
// No sliced capacity → keep the option visible but unselectable.
|
||||
disabled: slicedMaxPercentage <= 0
|
||||
}
|
||||
]}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
const isSliced = showModeSwitch && sliceMode === 'sliced';
|
||||
|
||||
// When the max ratio is below 10%, switch the ticks to a finer 1..10 scale
|
||||
// so small slices are still selectable; otherwise use the 10..100 scale.
|
||||
const sliceTicks =
|
||||
slicedMaxPercentage < 10
|
||||
? [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
: SLICE_PERCENT_TICKS;
|
||||
|
||||
const renderMaxLabel = (
|
||||
label: React.ReactNode,
|
||||
max?: number | null
|
||||
@@ -275,7 +206,7 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
: ['spec', 'resources', 'cpu']
|
||||
}
|
||||
preserve
|
||||
hidden={action === PageAction.EDIT || isSliced}
|
||||
hidden={action === PageAction.EDIT}
|
||||
normalize={(value) => (value != null ? _.toString(value) : undefined)}
|
||||
getValueProps={(value) => ({
|
||||
value: value != null ? _.toNumber(value) : undefined
|
||||
@@ -316,7 +247,6 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
max={maxComputeUnitCount}
|
||||
step={1}
|
||||
required
|
||||
labelExtra={sliceMode === 'whole' ? modeSegmented : undefined}
|
||||
disabled={disabled || action === PageAction.EDIT}
|
||||
label={`${intl.formatMessage({ id: 'common.max.count' }, { label: numberSelectionLabel.label })} (${intl.formatMessage(
|
||||
{
|
||||
@@ -327,89 +257,6 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{!noAvailableTypes && isSliced && (
|
||||
<FieldBlock>
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'resources', 'acceleratorSlicedMemoryPercentage']}
|
||||
getValueProps={(value) => ({
|
||||
value: value != null ? _.toNumber(value) : undefined
|
||||
})}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
validator: (_, value) => {
|
||||
const num = Number(value);
|
||||
if (value == null || value === '' || Number.isNaN(num)) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
intl.formatMessage({
|
||||
id: 'gpuservice.instance.slice.percentage.required'
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
if (num > slicedMaxPercentage || num <= 0) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
intl.formatMessage(
|
||||
{
|
||||
id: 'gpuservice.instance.slice.percentage.max'
|
||||
},
|
||||
{ count: slicedMaxPercentage }
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]}
|
||||
>
|
||||
<NumberSelection
|
||||
min={1}
|
||||
max={slicedMaxPercentage}
|
||||
step={1}
|
||||
maxCount={sliceTicks.length}
|
||||
presetValues={sliceTicks}
|
||||
alwaysShowInput
|
||||
required
|
||||
disabled={disabled}
|
||||
onChange={handleMemoryPercentageChange}
|
||||
labelExtra={modeSegmented}
|
||||
label={intl.formatMessage({
|
||||
id: 'gpuservice.instance.slice.memoryPercentage'
|
||||
})}
|
||||
/>
|
||||
</Form.Item>
|
||||
{/* Compute (cores) percentage is fixed at 100. Kept in the form via a
|
||||
hidden item so it rides along on submit. */}
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'resources', 'acceleratorSlicedCoresPercentage']}
|
||||
hidden
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
</FieldBlock>
|
||||
)}
|
||||
{/* Edit renders a readonly card (no sliced UI), so register the slice
|
||||
percentages as hidden fields — otherwise their persisted values are
|
||||
dropped from the submit payload. */}
|
||||
{action === PageAction.EDIT && (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'resources', 'acceleratorSlicedMemoryPercentage']}
|
||||
hidden
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name={['spec', 'resources', 'acceleratorSlicedCoresPercentage']}
|
||||
hidden
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
{!noAvailableTypes && (
|
||||
<Flex gap={12}>
|
||||
<div style={{ flex: 1 }}>
|
||||
@@ -434,7 +281,11 @@ const InstanceTypeFormItem: React.FC<InstanceTypeFormItemProps> = ({
|
||||
key="cpu_input"
|
||||
preserve
|
||||
>
|
||||
<InputNumber label={'CPU'} disabled={true} />
|
||||
<InputNumber
|
||||
label={'CPU'}
|
||||
max={onceMaxRequest?.cpu ?? undefined}
|
||||
disabled={true}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -36,20 +36,6 @@ export default function useQueryInstanceTypes() {
|
||||
}
|
||||
|
||||
const max = getAcceleratorMax(item.status?.tiers);
|
||||
|
||||
// Sliceable types stay selectable as long as either whole-card or sliced
|
||||
// capacity remains; unavailable only when both status.onceMaxRequest
|
||||
// .accelerator and .acceleratorSliced are 0.
|
||||
if (item.spec?.sliceable) {
|
||||
const wholeMax = Number(item.status?.onceMaxRequest?.accelerator) || 0;
|
||||
const slicedMax =
|
||||
Number(item.status?.onceMaxRequest?.acceleratorSliced) || 0;
|
||||
return {
|
||||
maxComputeUnitCount: max || 0,
|
||||
available: wholeMax > 0 || slicedMax > 0
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
maxComputeUnitCount: max || 0,
|
||||
available: (max || 0) > 0
|
||||
|
||||
@@ -45,10 +45,3 @@
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
// TemplateCard applies a fixed inline height; override to let sliceable cards
|
||||
// (with the extra Sliceable row) grow while keeping a 106px floor.
|
||||
.instanceTypeCard {
|
||||
height: auto !important;
|
||||
min-height: 106px;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* with ``buildInstanceTypeRecordFromMiB`` and feed it here.
|
||||
*/
|
||||
import _ from 'lodash';
|
||||
import { parseJsonSafe, parseQuantityToGi } from '../../utils';
|
||||
import { parseJsonSafe } from '../../utils';
|
||||
import InstanceTypeCell from '../components/instance-type-cell';
|
||||
import { formatMemoryDisplay } from '../config';
|
||||
import { InstanceTypeSpec, ListItem } from '../config/types';
|
||||
@@ -49,10 +49,6 @@ const buildResourcesData = (
|
||||
return {};
|
||||
};
|
||||
|
||||
// Memory (VRAM) percentage for a sliced instance; 0 when not sliced.
|
||||
const getSliceMemoryPercentage = (record: ListItem) =>
|
||||
_.toNumber(record.spec?.resources?.acceleratorSlicedMemoryPercentage) || 0;
|
||||
|
||||
const formatResources = (
|
||||
instanceTypeSpec: { spec: InstanceTypeSpec },
|
||||
record: ListItem
|
||||
@@ -75,34 +71,6 @@ const formatResources = (
|
||||
};
|
||||
}
|
||||
|
||||
const sliceMemoryPercentage = getSliceMemoryPercentage(record);
|
||||
|
||||
// Sliced: CPU / RAM carry the already-scaled values on spec.resources, and
|
||||
// VRAM is the per-card memory scaled by the memory percentage (floored,
|
||||
// min 1) — not the whole card's size.
|
||||
if (sliceMemoryPercentage > 0) {
|
||||
const vramGi = parseQuantityToGi(
|
||||
(instanceTypeSpec.spec as any)?.memory
|
||||
)?.value;
|
||||
const vram =
|
||||
vramGi != null
|
||||
? `${Math.max(1, _.floor((vramGi * sliceMemoryPercentage) / 100))} GB`
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
cpu: record.spec?.resources?.cpu
|
||||
? `${record.spec?.resources?.cpu} vCPU`
|
||||
: '-',
|
||||
ram: record.spec?.resources?.ram
|
||||
? toGB(record.spec?.resources?.ram)
|
||||
: '-',
|
||||
vram,
|
||||
localStorage: record.spec?.resources?.localStorage
|
||||
? toGB(record.spec?.resources?.localStorage)
|
||||
: undefined
|
||||
};
|
||||
}
|
||||
|
||||
// VRAM = per-card GPU memory (a single card's size; not aggregated across
|
||||
// cards — the model's marquee spec).
|
||||
const vram = formatMemoryDisplay((instanceTypeSpec.spec as any)?.memory);
|
||||
@@ -140,14 +108,10 @@ export const renderInstanceType = (
|
||||
parseJsonSafe<any>(record?.description || '{}', {}).spec || {};
|
||||
const resources = formatResources({ spec: description }, record);
|
||||
const accelerator = record.spec?.resources?.accelerator;
|
||||
const sliceMemoryPercentage = getSliceMemoryPercentage(record);
|
||||
const isSliced = description.acceleratable && sliceMemoryPercentage > 0;
|
||||
const title =
|
||||
options.title ??
|
||||
(description.acceleratable
|
||||
? isSliced
|
||||
? `${description.product} (${sliceMemoryPercentage}%)`
|
||||
: `${description.product} x ${accelerator}`
|
||||
? `${description.product} x ${accelerator}`
|
||||
: 'CPU Only');
|
||||
|
||||
const volume = (record.spec as any)?.volume;
|
||||
@@ -167,13 +131,7 @@ export const renderInstanceType = (
|
||||
icon: 'icon-gpu',
|
||||
name: 'GPU',
|
||||
rows: [
|
||||
// Sliced instances show the ratio instead of a card count (always 1).
|
||||
isSliced
|
||||
? [
|
||||
intl.formatMessage({ id: 'gpuservice.instance.sliced' }),
|
||||
`${sliceMemoryPercentage}%`
|
||||
]
|
||||
: [
|
||||
[
|
||||
intl.formatMessage({ id: 'gpuservice.table.count' }),
|
||||
accelerator ? `${accelerator}` : undefined
|
||||
],
|
||||
|
||||
@@ -28,13 +28,21 @@ interface ColumnsHookProps {
|
||||
const getKindLabel = (record: ListItem) => {
|
||||
if (record.spec?.nfs)
|
||||
return (
|
||||
<ThemeTag color="cyan" icon={<FolderOutlined />}>
|
||||
<ThemeTag
|
||||
style={{ width: 'fit-content' }}
|
||||
color="cyan"
|
||||
icon={<FolderOutlined />}
|
||||
>
|
||||
{StorageTypeKindLabelMap.nfs}
|
||||
</ThemeTag>
|
||||
);
|
||||
if (record.spec?.s3)
|
||||
return (
|
||||
<ThemeTag color="green" icon={<IconFont type="icon-database" />}>
|
||||
<ThemeTag
|
||||
style={{ width: 'fit-content' }}
|
||||
color="green"
|
||||
icon={<IconFont type="icon-database" />}
|
||||
>
|
||||
{StorageTypeKindLabelMap.s3}
|
||||
</ThemeTag>
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ const matchImageLogo = (
|
||||
isDark: boolean
|
||||
): { logo: string; type: string } | null => {
|
||||
if (!image) return null;
|
||||
const logoMap = isDark ? imageLogoDarkMap : imageLogoLightMap;
|
||||
const logoMap = imageLogoLightMap;
|
||||
const lower = image.toLowerCase();
|
||||
let matched: keyof typeof logoMap | null = null;
|
||||
let earliest = Infinity;
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
// Manufacturer display: most vendors read best all-caps (NVIDIA, AMD), but a
|
||||
// few read better capitalized (Intel). Shared by the instance-type list and the
|
||||
// create-instance drawer so both render the vendor identically.
|
||||
const CapitalizedVendors = ['intel'];
|
||||
|
||||
export const formatManufacturer = (manufacturer?: string | null): string => {
|
||||
if (!manufacturer) return '';
|
||||
return CapitalizedVendors.includes(manufacturer.toLowerCase())
|
||||
? _.capitalize(manufacturer)
|
||||
: _.toUpper(manufacturer);
|
||||
};
|
||||
|
||||
export const omitPathParams = <T extends Record<string, any>>(
|
||||
params: T
|
||||
): Omit<T, 'namespace' | 'clusterID'> => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getGPUStackPlugin } from '@/plugins';
|
||||
import { DownOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
AlertBlockInfo,
|
||||
CardRadioGroup,
|
||||
TooltipList,
|
||||
Transfer as TransferInner
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl } from '@umijs/max';
|
||||
@@ -15,8 +15,9 @@ import {
|
||||
Dropdown,
|
||||
DropdownProps,
|
||||
Empty,
|
||||
Flex,
|
||||
Form,
|
||||
Radio,
|
||||
RadioChangeEvent,
|
||||
Tooltip
|
||||
} from 'antd';
|
||||
import {
|
||||
@@ -79,9 +80,9 @@ const Label = styled.div`
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
color: var(--ant-color-text-secondary);
|
||||
margin-block: 8px 12px;
|
||||
font-size: 14px;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
`;
|
||||
|
||||
interface AccessControlFormProps {
|
||||
@@ -106,14 +107,6 @@ type AllowedUsersOverride = {
|
||||
routeId?: number;
|
||||
action: PageActionType;
|
||||
}>;
|
||||
// Optional trigger (e.g. an "Add" button) rendered by the host in its
|
||||
// own layout slot while `Field` renders the body. Same props as Field
|
||||
// so the plugin can gate visibility on action/routeId.
|
||||
Action?: React.ComponentType<{
|
||||
form: any;
|
||||
routeId?: number;
|
||||
action: PageActionType;
|
||||
}>;
|
||||
};
|
||||
|
||||
// Extra policy entries prepended to the radio list (rendered before
|
||||
@@ -230,7 +223,9 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleOnPolicyChange = async (policy: string) => {
|
||||
const handleOnPolicyChange = async (e: RadioChangeEvent) => {
|
||||
console.log('policy changed:', e.target.value);
|
||||
const policy = e.target.value;
|
||||
if (policy === ALLOWED_PRINCIPALS_POLICY) {
|
||||
form.setFieldsValue({ users: formDataCacheRef.current?.users || [] });
|
||||
} else {
|
||||
@@ -396,29 +391,33 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
: undefined
|
||||
}}
|
||||
>
|
||||
<Label>{intl.formatMessage({ id: 'models.table.accessScope' })}</Label>
|
||||
|
||||
<Form.Item<AccessControlFormData>
|
||||
name="access_policy"
|
||||
style={{
|
||||
marginBottom: 16
|
||||
}}
|
||||
<Label>
|
||||
{intl.formatMessage({ id: 'models.table.accessScope' })}
|
||||
<Tooltip
|
||||
title={
|
||||
<TooltipList
|
||||
list={buildAccessScopeTips(
|
||||
allowedUsersOverride,
|
||||
prependedPolicies
|
||||
)}
|
||||
></TooltipList>
|
||||
}
|
||||
>
|
||||
<CardRadioGroup
|
||||
<QuestionCircleOutlined />
|
||||
</Tooltip>
|
||||
</Label>
|
||||
|
||||
<Form.Item<AccessControlFormData> name="access_policy" noStyle>
|
||||
<Radio.Group
|
||||
onChange={handleOnPolicyChange}
|
||||
style={{ marginBottom: 12 }}
|
||||
options={[
|
||||
...prependedPolicies.map((p) => ({
|
||||
label: intl.formatMessage({ id: p.labelId }),
|
||||
description: intl.formatMessage({ id: p.tipsId ?? p.labelId }),
|
||||
value: p.policyValue
|
||||
})),
|
||||
{
|
||||
label: intl.formatMessage({
|
||||
id: 'models.accessSettings.authed'
|
||||
}),
|
||||
description: intl.formatMessage({
|
||||
id: 'models.accessSettings.authed.tips'
|
||||
}),
|
||||
label: intl.formatMessage({ id: 'models.accessSettings.authed' }),
|
||||
value: 'authed'
|
||||
},
|
||||
allowedUsersOverride
|
||||
@@ -426,52 +425,23 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
label: intl.formatMessage({
|
||||
id: allowedUsersOverride.labelId
|
||||
}),
|
||||
description: intl.formatMessage({
|
||||
id:
|
||||
allowedUsersOverride.tipsId ??
|
||||
'models.accessSettings.allowedUsers.tips'
|
||||
}),
|
||||
value: allowedUsersOverride.policyValue
|
||||
}
|
||||
: {
|
||||
label: intl.formatMessage({
|
||||
id: 'models.accessSettings.allowedUsers'
|
||||
}),
|
||||
description: intl.formatMessage({
|
||||
id: 'models.accessSettings.allowedUsers.tips'
|
||||
}),
|
||||
value: ALLOWED_PRINCIPALS_POLICY
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({
|
||||
id: 'models.accessSettings.public'
|
||||
}),
|
||||
description: intl.formatMessage({
|
||||
id: 'models.accessSettings.public.desc'
|
||||
}),
|
||||
value: 'public'
|
||||
}
|
||||
]}
|
||||
/>
|
||||
></Radio.Group>
|
||||
</Form.Item>
|
||||
{allowedUsersOverride?.Action && accessPolicy === overridePolicyValue && (
|
||||
<Flex
|
||||
justify="space-between"
|
||||
align="center"
|
||||
style={{ marginBottom: 8 }}
|
||||
>
|
||||
<Label style={{ marginBottom: 0 }}>
|
||||
{intl.formatMessage({
|
||||
id: 'models.accessSettings.grantedPrincipals'
|
||||
})}
|
||||
</Label>
|
||||
<allowedUsersOverride.Action
|
||||
form={form}
|
||||
routeId={currentData?.id}
|
||||
action={action}
|
||||
/>
|
||||
</Flex>
|
||||
)}
|
||||
{accessPolicy === 'public' && (
|
||||
<div style={{ marginBlock: '16px 12px' }}>
|
||||
<AlertBlockInfo
|
||||
@@ -479,13 +449,6 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
|
||||
message={intl.formatMessage({
|
||||
id: 'models.accessSettings.public.tips'
|
||||
})}
|
||||
overlayScrollerProps={{
|
||||
styles: {
|
||||
wrapper: {
|
||||
paddingLeft: 0
|
||||
}
|
||||
}
|
||||
}}
|
||||
></AlertBlockInfo>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -130,9 +130,7 @@ const AccessControlModal: React.FC<
|
||||
<AlertBlockInfo
|
||||
type="warning"
|
||||
style={{ marginBottom: 16 }}
|
||||
contentStyle={{
|
||||
paddingInline: 0
|
||||
}}
|
||||
contentStyle={{ paddingInline: 0 }}
|
||||
message={intl.formatMessage({
|
||||
id: 'models.button.accessSettings.tips'
|
||||
})}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import PluginExtraFields from '@/components/plugin-extra-fields';
|
||||
import {
|
||||
IconFont,
|
||||
StatusDot,
|
||||
StatusTag,
|
||||
TagsWrapper,
|
||||
TemplateCard,
|
||||
ThemeTag
|
||||
} from '@gpustack/core-ui';
|
||||
import { useIntl, useNavigate } from '@umijs/max';
|
||||
import { Button, Tooltip } from 'antd';
|
||||
import { Button } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
@@ -193,23 +192,6 @@ const ModelItem: React.FC<{
|
||||
return _.round(max_tokens / 1024);
|
||||
}, [model]);
|
||||
|
||||
// Ready is the normal state — show just the dot (no label); other states
|
||||
// (Not Ready / Stopped) keep their label so the problem is legible.
|
||||
const statusNode = (
|
||||
<StatusDot
|
||||
statusValue={{
|
||||
status: MyModelsStatusMap[model.status],
|
||||
text:
|
||||
model.status === MyModelsStatusValueMap.Ready ||
|
||||
!MyModelsStatusLabelMap[model.status]
|
||||
? ''
|
||||
: intl.formatMessage({
|
||||
id: MyModelsStatusLabelMap[model.status]
|
||||
})
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<CardWrapper>
|
||||
<TemplateCard
|
||||
@@ -228,32 +210,18 @@ const ModelItem: React.FC<{
|
||||
) : (
|
||||
<ModelLogo src={defaultModelLogo} alt="" />
|
||||
)}
|
||||
<span className="flex-center" style={{ gap: 8, minWidth: 0 }}>
|
||||
<span>{model.name}</span>
|
||||
{/* Status moved to a compact dot right after the name, freeing
|
||||
the header's right side for the price summary. The dot keeps
|
||||
the state message on hover (StatusDot has no built-in one). */}
|
||||
<span
|
||||
style={{
|
||||
fontWeight: 400,
|
||||
fontSize: 'var(--font-size-small)'
|
||||
</span>
|
||||
<StatusTag
|
||||
maxTooltipWidth={400}
|
||||
statusValue={{
|
||||
status: MyModelsStatusMap[model.status],
|
||||
text: intl.formatMessage({
|
||||
id: MyModelsStatusLabelMap[model.status] || ''
|
||||
}),
|
||||
message: model.state_message
|
||||
}}
|
||||
>
|
||||
{model.state_message ? (
|
||||
<Tooltip title={model.state_message}>
|
||||
<span style={{ display: 'inline-flex' }}>
|
||||
{statusNode}
|
||||
</span>
|
||||
</Tooltip>
|
||||
) : (
|
||||
statusNode
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className="flex-center gap-8">
|
||||
<PluginExtraFields name="ModelPriceSummary" context={{ model }} />
|
||||
</span>
|
||||
></StatusTag>
|
||||
</Header>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -268,7 +268,7 @@ const useModelsColumns = ({
|
||||
dataIndex: 'created_at',
|
||||
key: 'created_at',
|
||||
sorter: tableSorter(5),
|
||||
width: 180,
|
||||
span: spans.createTime,
|
||||
render: (text: number) => (
|
||||
<AutoTooltip ghost>
|
||||
{dayjs(text).format('YYYY-MM-DD HH:mm:ss')}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import PluginExtraFields from '@/components/plugin-extra-fields';
|
||||
import useTableFetch from '@/hooks/use-table-fetch';
|
||||
import { SyncOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
@@ -269,10 +268,6 @@ const UserModels: React.FC = () => {
|
||||
</Space>
|
||||
}
|
||||
></PageTools>
|
||||
<PluginExtraFields
|
||||
name="ModelBillingProvider"
|
||||
context={{ models: dataList }}
|
||||
/>
|
||||
<InfiniteScrollerProvider
|
||||
value={{
|
||||
total: dataSource.totalPage,
|
||||
|
||||
@@ -177,7 +177,6 @@ const ModelItem: React.FC<ModelItemProps> = ({
|
||||
<span>
|
||||
<AutoComplete
|
||||
loading={loading}
|
||||
allowClear
|
||||
showSearch={{
|
||||
filterOption: (inputValue, option: any) => {
|
||||
return (
|
||||
|
||||
@@ -300,7 +300,6 @@ const Workers: React.FC<WorkersProps> = ({ clusterId, source }) => {
|
||||
></FilterBar>
|
||||
<ConfigProvider renderEmpty={renderEmpty}>
|
||||
<Table
|
||||
tableLayout="auto"
|
||||
columns={columns}
|
||||
sortDirections={TABLE_SORT_DIRECTIONS}
|
||||
showSorterTooltip={false}
|
||||
|
||||
@@ -26,7 +26,7 @@ import { Tooltip } from 'antd';
|
||||
import { ColumnsType } from 'antd/lib/table';
|
||||
import { useAtom, useAtomValue } from 'jotai';
|
||||
import _ from 'lodash';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import semverCoerce from 'semver/functions/coerce';
|
||||
import semverGt from 'semver/functions/gt';
|
||||
import { status, WorkerStatusMap, WorkerStatusMapValue } from '../config';
|
||||
@@ -143,57 +143,15 @@ const GPUCell = ({ devices }: { devices: GPUDeviceItem[] }) => (
|
||||
</span>
|
||||
);
|
||||
|
||||
// index + ProgressBar
|
||||
const VRAMItem = ({
|
||||
item,
|
||||
autoOpen
|
||||
}: {
|
||||
item: GPUDeviceItem;
|
||||
autoOpen: boolean;
|
||||
}) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setOpen(autoOpen);
|
||||
}, [autoOpen]);
|
||||
|
||||
const percent = item.memory?.used
|
||||
? _.round(item.memory?.utilization_rate, 0)
|
||||
: _.round((item.memory?.allocated / item.memory?.total) * 100, 0);
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
title={<InfoColumn fieldList={fieldList} data={item.memory} />}
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
>
|
||||
<span className="flex-center" style={{ cursor: 'pointer' }}>
|
||||
<span
|
||||
className="m-r-5"
|
||||
style={{ display: 'flex', width: 25, lineHeight: 1.2 }}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
paddingBottom: 2,
|
||||
borderBottom: '1px dashed var(--ant-blue-6)'
|
||||
}}
|
||||
>
|
||||
[{item.index}]
|
||||
</span>
|
||||
</span>
|
||||
<ProgressBar percent={percent} />
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
const VRAMCell = ({
|
||||
devices,
|
||||
intl,
|
||||
rIndex,
|
||||
loadend,
|
||||
firstLoad
|
||||
}: {
|
||||
devices: GPUDeviceItem[];
|
||||
intl: any;
|
||||
rIndex: number;
|
||||
loadend: boolean;
|
||||
firstLoad: boolean;
|
||||
@@ -202,11 +160,36 @@ const VRAMCell = ({
|
||||
{_.map(
|
||||
_.sortBy(devices || [], ['index']),
|
||||
(item: GPUDeviceItem, index: number) => (
|
||||
<VRAMItem
|
||||
key={index}
|
||||
item={item}
|
||||
autoOpen={rIndex === 0 && index === 0 && loadend && firstLoad}
|
||||
<span key={index} className="flex-center">
|
||||
<span
|
||||
className="m-r-5"
|
||||
style={{ display: 'flex', width: 25, lineHeight: 1 }}
|
||||
>
|
||||
[{item.index}]
|
||||
</span>
|
||||
<ProgressBar
|
||||
defaultOpen={rIndex === 0 && index === 0 && loadend && firstLoad}
|
||||
percent={
|
||||
item.memory?.used
|
||||
? _.round(item.memory?.utilization_rate, 0)
|
||||
: _.round(
|
||||
(item.memory?.allocated / item.memory?.total) * 100,
|
||||
0
|
||||
)
|
||||
}
|
||||
label={<InfoColumn fieldList={fieldList} data={item.memory} />}
|
||||
/>
|
||||
{item.memory.is_unified_memory && (
|
||||
<Tooltip
|
||||
title={intl.formatMessage({ id: 'resources.table.unified' })}
|
||||
>
|
||||
<InfoCircleOutlined
|
||||
className="m-l-5"
|
||||
style={{ color: 'var(--ant-blue-5)' }}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
)}
|
||||
</span>
|
||||
@@ -515,7 +498,6 @@ const useWorkerColumns = ({
|
||||
{
|
||||
title: 'GPU',
|
||||
dataIndex: 'gpu',
|
||||
minWidth: 100,
|
||||
render: (_, record) =>
|
||||
statusAvailable(record) ? (
|
||||
<GPUCell devices={record?.status?.gpu_devices} />
|
||||
@@ -526,11 +508,11 @@ const useWorkerColumns = ({
|
||||
{
|
||||
title: intl.formatMessage({ id: 'resources.table.vram' }),
|
||||
dataIndex: 'vram',
|
||||
minWidth: 100,
|
||||
render: (_, record, rIndex) =>
|
||||
statusAvailable(record) ? (
|
||||
<VRAMCell
|
||||
devices={record?.status?.gpu_devices}
|
||||
intl={intl}
|
||||
rIndex={rIndex}
|
||||
loadend={loadend}
|
||||
firstLoad={firstLoad}
|
||||
@@ -542,7 +524,6 @@ const useWorkerColumns = ({
|
||||
{
|
||||
title: intl.formatMessage({ id: 'resources.table.disk' }),
|
||||
dataIndex: 'storage',
|
||||
minWidth: 100,
|
||||
render: (_, record) => (
|
||||
<span className="flex-center flex-full">
|
||||
{statusAvailable(record) ? (
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
* tab (date range + "filter by user" for managers); the resource-type /
|
||||
* event-type selects ride in the bar's ``extra`` slot.
|
||||
*/
|
||||
import { type StatusType } from '@/config/types';
|
||||
import { SimpleSelect, StatusDot } from '@gpustack/core-ui';
|
||||
import { SimpleSelect } from '@gpustack/core-ui';
|
||||
import { useAccess, useIntl } from '@umijs/max';
|
||||
import { useMemoizedFn } from 'ahooks';
|
||||
import { Input, Select, Table } from 'antd';
|
||||
import { Input, Select, Table, Tag } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import _ from 'lodash';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
@@ -24,11 +23,11 @@ import useQueryResourceEvents from './services/use-query-resource-events';
|
||||
// Only these four are ever emitted (see resource_event_logger): create/delete
|
||||
// + the metering-window pair. updated/attached/detached exist as enum values
|
||||
// but are intentionally not recorded, so they're not offered as filters.
|
||||
const EVENT_STATUS: Record<string, StatusType> = {
|
||||
created: 'success',
|
||||
deleted: 'error',
|
||||
phase_to_metered: 'transitioning',
|
||||
phase_left_metered: 'warning'
|
||||
const EVENT_COLOR: Record<string, string> = {
|
||||
created: 'green',
|
||||
deleted: 'red',
|
||||
phase_to_metered: 'blue',
|
||||
phase_left_metered: 'orange'
|
||||
};
|
||||
|
||||
// Humanize a failure phase enum for display, e.g. "SSHPublicKeyCreateFailed" →
|
||||
@@ -187,12 +186,7 @@ const ResourceEvents: React.FC = () => {
|
||||
dataIndex: 'event_type',
|
||||
key: 'event_type',
|
||||
render: (v: string) => (
|
||||
<StatusDot
|
||||
statusValue={{
|
||||
status: EVENT_STATUS[v] ?? 'inactive',
|
||||
text: EVENT_LABEL[v] ?? v
|
||||
}}
|
||||
/>
|
||||
<Tag color={EVENT_COLOR[v] ?? 'default'}>{EVENT_LABEL[v] ?? v}</Tag>
|
||||
),
|
||||
width: 180
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user