Compare commits

...
11 changed files with 192 additions and 105 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
"@ant-design/pro-components": "3.1.0-0", "@ant-design/pro-components": "3.1.0-0",
"@antv/g6": "^5.0.51", "@antv/g6": "^5.0.51",
"@braintree/sanitize-url": "^7.1.1", "@braintree/sanitize-url": "^7.1.1",
"@gpustack/core-ui": "^1.0.40", "@gpustack/core-ui": "^1.0.42",
"@huggingface/gguf": "^0.1.7", "@huggingface/gguf": "^0.1.7",
"@huggingface/hub": "^0.15.1", "@huggingface/hub": "^0.15.1",
"@huggingface/tasks": "^0.11.6", "@huggingface/tasks": "^0.11.6",
+12 -6
View File
@@ -24,8 +24,8 @@ importers:
specifier: ^7.1.1 specifier: ^7.1.1
version: 7.1.2 version: 7.1.2
'@gpustack/core-ui': '@gpustack/core-ui':
specifier: ^1.0.40 specifier: ^1.0.42
version: 1.0.40(czdvzceysqw7iv6pct2ucnb23e) version: 1.0.42(czdvzceysqw7iv6pct2ucnb23e)
'@huggingface/gguf': '@huggingface/gguf':
specifier: ^0.1.7 specifier: ^0.1.7
version: 0.1.18 version: 0.1.18
@@ -281,7 +281,7 @@ importers:
version: 9.1.7 version: 9.1.7
less-loader: less-loader:
specifier: ^12.2.0 specifier: ^12.2.0
version: 12.3.2(less@4.6.4)(webpack@5.106.2(lightningcss@1.22.1)(postcss@8.5.14)) version: 12.3.2(less@4.1.3)(webpack@5.106.2(lightningcss@1.22.1)(postcss@8.5.14))
lint-staged: lint-staged:
specifier: ^15.2.2 specifier: ^15.2.2
version: 15.5.2 version: 15.5.2
@@ -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} 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 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.40': '@gpustack/core-ui@1.0.42':
resolution: {integrity: sha512-Ahd5GcKOulaU32gX//jIZJOWEgr2W1s6jS8UtRTsxZ53UPzBoKkfUnwyWkB2WBUSjvk4lntxvoC4kDefKXbd9w==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.40.tgz} resolution: {integrity: sha512-upMClTHU+xAqd8dlx0w1S9XWHlog5g1hcOCulTk2rmMXqgl66QHfqhEFhJnWIGe1xc8tEj6rW3r5Sirif+qswA==, tarball: https://registry.npmjs.org/@gpustack/core-ui/-/core-ui-1.0.42.tgz}
peerDependencies: peerDependencies:
'@ant-design/icons': ^6.1.0 '@ant-design/icons': ^6.1.0
'@ant-design/pro-components': 3.1.0-0 '@ant-design/pro-components': 3.1.0-0
@@ -10802,7 +10802,7 @@ snapshots:
'@formatjs/intl-utils@2.3.0': {} '@formatjs/intl-utils@2.3.0': {}
'@gpustack/core-ui@1.0.40(czdvzceysqw7iv6pct2ucnb23e)': '@gpustack/core-ui@1.0.42(czdvzceysqw7iv6pct2ucnb23e)':
dependencies: dependencies:
'@ant-design/icons': 6.2.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@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) '@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)
@@ -16496,6 +16496,12 @@ snapshots:
less: 4.1.3 less: 4.1.3
webpack: 5.106.2(lightningcss@1.22.1)(postcss@8.5.14) webpack: 5.106.2(lightningcss@1.22.1)(postcss@8.5.14)
less-loader@12.3.2(less@4.1.3)(webpack@5.106.2(lightningcss@1.22.1)(postcss@8.5.14)):
dependencies:
less: 4.1.3
optionalDependencies:
webpack: 5.106.2(lightningcss@1.22.1)(postcss@8.5.14)
less-loader@12.3.2(less@4.6.4)(webpack@5.106.2(lightningcss@1.22.1)(postcss@8.5.14)): less-loader@12.3.2(less@4.6.4)(webpack@5.106.2(lightningcss@1.22.1)(postcss@8.5.14)):
dependencies: dependencies:
less: 4.6.4 less: 4.6.4
+3
View File
@@ -51,6 +51,9 @@ export default {
withDescriptionPadding: '12px 16px', withDescriptionPadding: '12px 16px',
withDescriptionIconSize: 18 withDescriptionIconSize: 18
}, },
Card: {
headerHeight: 50
},
Menu: { Menu: {
iconSize: 16, iconSize: 16,
iconMarginInlineEnd: 12, iconMarginInlineEnd: 12,
+27 -13
View File
@@ -8,24 +8,38 @@ const findValidJSONStrings = (inputStr: string) => {
const openingBraceIndex = inputStr.indexOf('{', startIndex); const openingBraceIndex = inputStr.indexOf('{', startIndex);
if (openingBraceIndex === -1) break; // No more opening braces if (openingBraceIndex === -1) break; // No more opening braces
let closingBraceIndex = openingBraceIndex; // find the matching closing brace, ignoring braces inside string
// literals (e.g. a state_message containing `{`/`}`)
let closingBraceIndex = -1;
let braceCount = 0; let braceCount = 0;
let inString = false;
let escaped = false;
// find couple of braces for (let i = openingBraceIndex; i < inputStr.length; i++) {
while (closingBraceIndex < inputStr.length) { const char = inputStr[i];
if (inputStr[closingBraceIndex] === '{') { if (inString) {
braceCount++; if (escaped) {
} else if (inputStr[closingBraceIndex] === '}') { escaped = false;
braceCount--; } else if (char === '\\') {
escaped = true;
} else if (char === '"') {
inString = false;
} }
} else if (char === '"') {
inString = true;
} else if (char === '{') {
braceCount++;
} else if (char === '}') {
braceCount--;
if (braceCount === 0) { if (braceCount === 0) {
closingBraceIndex = i;
break; break;
} }
closingBraceIndex++; }
} }
if (braceCount !== 0) { if (closingBraceIndex === -1) {
// no matching closing brace // no matching closing brace yet, wait for more data
break; break;
} }
@@ -37,11 +51,11 @@ const findValidJSONStrings = (inputStr: string) => {
try { try {
const parsedData = JSON.parse(jsonString); const parsedData = JSON.parse(jsonString);
validJSONStrings.push(parsedData); validJSONStrings.push(parsedData);
startIndex = closingBraceIndex + 1;
} catch (error) { } catch (error) {
// mabye invalid JSON // skip the malformed segment instead of breaking, otherwise it jams
break; // the buffer and every later event on this stream is lost
} }
startIndex = closingBraceIndex + 1;
} }
return { return {
+4 -1
View File
@@ -43,8 +43,11 @@ export const createAxiosToken = (): CancelTokenSource => {
}; };
export const sliceData = (data: string, loaded: number, loadedSize: any) => { export const sliceData = (data: string, loaded: number, loadedSize: any) => {
// `loaded` is a byte count while `data` is a UTF-16 string; with any
// non-ASCII payload the two drift apart, so track consumed characters by
// string length only
const result = data.slice(loadedSize.current); const result = data.slice(loadedSize.current);
loadedSize.current = loaded; loadedSize.current = data.length;
return result; return result;
}; };
@@ -163,7 +163,11 @@ const PoolRows: React.FC<PoolRowsProps> = ({
key={col.dataIndex || col.key} key={col.dataIndex || col.key}
span={spanFor(col.dataIndex)} span={spanFor(col.dataIndex)}
style={{ style={{
color: 'var(--ant-color-text-secondary)' color: 'var(--ant-color-text-secondary)',
// CellContent shrinks to its content inside the flex
// cell, so its own align class can't center it —
// center at the cell level instead.
justifyContent: col.align
}} }}
> >
<CellContent <CellContent
@@ -153,7 +153,7 @@ const useClusterColumns = (
span: 3, span: 3,
render: (text: string, record: ClusterListItem) => ( render: (text: string, record: ClusterListItem) => (
<> <>
<AutoTooltip ghost title={text}> <AutoTooltip ghost title={text} minWidth={20}>
<span className="text-primary">{record.name}</span> <span className="text-primary">{record.name}</span>
</AutoTooltip> </AutoTooltip>
{record.is_default && ( {record.is_default && (
@@ -176,6 +176,7 @@ const useClusterColumns = (
dataIndex: 'provider', dataIndex: 'provider',
sorter: tableSorter(2), sorter: tableSorter(2),
span: spans.provider, span: spans.provider,
minWidth: 110,
render: (value: string) => ( render: (value: string) => (
<AutoTooltip ghost minWidth={20}> <AutoTooltip ghost minWidth={20}>
{ProviderLabelMap[value]} {ProviderLabelMap[value]}
@@ -185,7 +186,7 @@ const useClusterColumns = (
{ {
title: intl.formatMessage({ id: 'dashboard.totalgpus' }), title: intl.formatMessage({ id: 'dashboard.totalgpus' }),
dataIndex: 'gpus', dataIndex: 'gpus',
span: 2, width: 100,
sorter: tableSorter(3), sorter: tableSorter(3),
render: (value: number) => <span>{value}</span> render: (value: number) => <span>{value}</span>
}, },
@@ -194,13 +195,15 @@ const useClusterColumns = (
dataIndex: 'models', dataIndex: 'models',
sorter: tableSorter(4), sorter: tableSorter(4),
span: spans.deployments, span: spans.deployments,
maxWidth: 150,
render: (value: number) => <span>{value}</span> render: (value: number) => <span>{value}</span>
}, },
{ {
title: intl.formatMessage({ id: 'resources.nodes' }), title: intl.formatMessage({ id: 'resources.nodes' }),
dataIndex: 'workers', dataIndex: 'workers',
minWidth: 100,
maxWidth: 120,
sorter: tableSorter(5), sorter: tableSorter(5),
span: spans.workers,
render: (value: number, record: ClusterListItem) => ( render: (value: number, record: ClusterListItem) => (
<span> <span>
{record.ready_workers} / {record.workers} {record.ready_workers} / {record.workers}
@@ -211,6 +214,8 @@ const useClusterColumns = (
title: intl.formatMessage({ id: 'common.table.status' }), title: intl.formatMessage({ id: 'common.table.status' }),
dataIndex: 'state', dataIndex: 'state',
span: spans.status, span: spans.status,
minWidth: 80,
align: 'center',
render: (value: number, record: ClusterListItem) => ( render: (value: number, record: ClusterListItem) => (
<StatusTag <StatusTag
statusValue={{ statusValue={{
@@ -116,6 +116,7 @@ const usePoolsColumns = (
dataIndex: 'replicas', dataIndex: 'replicas',
span: 6, span: 6,
key: 'replicas', key: 'replicas',
align: 'center',
editable: { editable: {
valueType: 'number', valueType: 'number',
title: intl.formatMessage({ id: 'models.table.replicas.edit' }) title: intl.formatMessage({ id: 'models.table.replicas.edit' })
@@ -6,7 +6,7 @@ import { getGPUStackPlugin } from '@/plugins';
import { DownOutlined, QuestionCircleOutlined } from '@ant-design/icons'; import { DownOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { import {
AlertBlockInfo, AlertBlockInfo,
TooltipList, CardRadioGroup,
Transfer as TransferInner Transfer as TransferInner
} from '@gpustack/core-ui'; } from '@gpustack/core-ui';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
@@ -17,8 +17,6 @@ import {
Empty, Empty,
Flex, Flex,
Form, Form,
Radio,
RadioChangeEvent,
Tooltip Tooltip
} from 'antd'; } from 'antd';
import { import {
@@ -82,7 +80,8 @@ const Label = styled.div`
gap: 4px; gap: 4px;
font-weight: 500; font-weight: 500;
margin-bottom: 16px; margin-bottom: 16px;
font-size: 14px; font-size: 13px;
color: var(--ant-color-text-secondary);
`; `;
interface AccessControlFormProps { interface AccessControlFormProps {
@@ -231,9 +230,7 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
} }
}; };
const handleOnPolicyChange = async (e: RadioChangeEvent) => { const handleOnPolicyChange = async (policy: string) => {
console.log('policy changed:', e.target.value);
const policy = e.target.value;
if (policy === ALLOWED_PRINCIPALS_POLICY) { if (policy === ALLOWED_PRINCIPALS_POLICY) {
form.setFieldsValue({ users: formDataCacheRef.current?.users || [] }); form.setFieldsValue({ users: formDataCacheRef.current?.users || [] });
} else { } else {
@@ -399,39 +396,29 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
: undefined : undefined
}} }}
> >
<Label> <Label>{intl.formatMessage({ id: 'models.table.accessScope' })}</Label>
{intl.formatMessage({ id: 'models.table.accessScope' })}
<Tooltip
title={
<TooltipList
list={buildAccessScopeTips(
allowedUsersOverride,
prependedPolicies
)}
></TooltipList>
}
>
<QuestionCircleOutlined />
</Tooltip>
</Label>
<Flex <Form.Item<AccessControlFormData>
align="center" name="access_policy"
justify="space-between" style={{
style={{ marginBottom: 16, height: 40 }} marginBottom: 16
}}
> >
<Form.Item<AccessControlFormData> name="access_policy" noStyle> <CardRadioGroup
<Radio.Group
onChange={handleOnPolicyChange} onChange={handleOnPolicyChange}
options={[ options={[
...prependedPolicies.map((p) => ({ ...prependedPolicies.map((p) => ({
label: intl.formatMessage({ id: p.labelId }), label: intl.formatMessage({ id: p.labelId }),
description: intl.formatMessage({ id: p.tipsId ?? p.labelId }),
value: p.policyValue value: p.policyValue
})), })),
{ {
label: intl.formatMessage({ label: intl.formatMessage({
id: 'models.accessSettings.authed' id: 'models.accessSettings.authed'
}), }),
description: intl.formatMessage({
id: 'models.accessSettings.authed.tips'
}),
value: 'authed' value: 'authed'
}, },
allowedUsersOverride allowedUsersOverride
@@ -439,32 +426,52 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
label: intl.formatMessage({ label: intl.formatMessage({
id: allowedUsersOverride.labelId id: allowedUsersOverride.labelId
}), }),
description: intl.formatMessage({
id:
allowedUsersOverride.tipsId ??
'models.accessSettings.allowedUsers.tips'
}),
value: allowedUsersOverride.policyValue value: allowedUsersOverride.policyValue
} }
: { : {
label: intl.formatMessage({ label: intl.formatMessage({
id: 'models.accessSettings.allowedUsers' id: 'models.accessSettings.allowedUsers'
}), }),
description: intl.formatMessage({
id: 'models.accessSettings.allowedUsers.tips'
}),
value: ALLOWED_PRINCIPALS_POLICY value: ALLOWED_PRINCIPALS_POLICY
}, },
{ {
label: intl.formatMessage({ label: intl.formatMessage({
id: 'models.accessSettings.public' id: 'models.accessSettings.public'
}), }),
description: intl.formatMessage({
id: 'models.accessSettings.public.desc'
}),
value: 'public' value: 'public'
} }
]} ]}
></Radio.Group> />
</Form.Item> </Form.Item>
{allowedUsersOverride?.Action && {allowedUsersOverride?.Action && accessPolicy === overridePolicyValue && (
accessPolicy === overridePolicyValue && ( <Flex
justify="space-between"
align="center"
style={{ marginBottom: 8 }}
>
<Label style={{ marginBottom: 0 }}>
{intl.formatMessage({
id: 'models.accessSettings.grantedPrincipals'
})}
</Label>
<allowedUsersOverride.Action <allowedUsersOverride.Action
form={form} form={form}
routeId={currentData?.id} routeId={currentData?.id}
action={action} action={action}
/> />
)}
</Flex> </Flex>
)}
{accessPolicy === 'public' && ( {accessPolicy === 'public' && (
<div style={{ marginBlock: '16px 12px' }}> <div style={{ marginBlock: '16px 12px' }}>
<AlertBlockInfo <AlertBlockInfo
+21 -1
View File
@@ -248,7 +248,13 @@ const Models = forwardRef((props, ref) => {
chunkInstanceRequedtRef.current = setModelInstanceChunkRequest({ chunkInstanceRequedtRef.current = setModelInstanceChunkRequest({
url: `${MODEL_INSTANCE_API}`, url: `${MODEL_INSTANCE_API}`,
params: {}, params: {},
handler: updateInstanceHandler handler: updateInstanceHandler,
beforeReconnect() {
// treat the reconnect snapshot as the new baseline, otherwise
// instances deleted while the stream was down linger in the cache
// (their DELETE events are never re-sent)
cacheInsDataListRef.current = [];
}
}); });
} catch (error) { } catch (error) {
// ignore // ignore
@@ -452,6 +458,20 @@ const Models = forwardRef((props, ref) => {
}; };
}, []); }, []);
// watch events can still be lost (stream hiccup, reconnect gap); a low
// frequency relist keeps the instance cache eventually consistent, so a
// missed DELETE event can't leave a stale instance behind for good
useEffect(() => {
const timer = setInterval(() => {
if (!isPageHidden.current) {
getAllModelInstances();
}
}, 60 * 1000);
return () => {
clearInterval(timer);
};
}, []);
const setDisableExpand = useMemoizedFn((record: any) => { const setDisableExpand = useMemoizedFn((record: any) => {
return !record?.replicas; return !record?.replicas;
}); });
+31 -7
View File
@@ -153,26 +153,50 @@ const BasicForm: React.FC<BasicFormProps> = (props) => {
// Use the seed callback (not handleClusterChange) so this auto-pick refreshes // Use the seed callback (not handleClusterChange) so this auto-pick refreshes
// options without firing an evaluate request before a model is selected. // options without firing an evaluate request before a model is selected.
useEffect(() => { useEffect(() => {
if (!clusterOptions?.length) { // Options derive from clusterList: an empty source list means clusters
// are still loading — leave the field alone until they arrive.
if (!clusterList?.length) {
return; return;
} }
// Scope off the live form value, not the `useWatch` snapshot: the scope
// field's default lands in a child effect that flushes before this one,
// while the watch still reports the previous render's null — scoping off
// the watch would seed a cluster from the unscoped list here and only
// re-scope a render later.
const liveScopeOrgId = form.getFieldValue('organization_id') ?? null;
const scoped = clusterList.filter(
(item) =>
liveScopeOrgId == null || item.owner_principal_id === liveScopeOrgId
);
const current = form.getFieldValue('cluster_id'); const current = form.getFieldValue('cluster_id');
const stillValid = clusterOptions.some((c) => c.value === current); if (!scoped.length) {
// Clusters are loaded but the picked org owns none. Any leftover
// selection points at another org's cluster (seeded before the scope
// settled) and would make requests fail with "Cluster not found" —
// clear it so the required rule surfaces instead. Create only: an
// edit's cluster is existing data, not a seed.
if (action === PageAction.CREATE && current != null) {
form.setFieldValue('cluster_id', undefined);
}
return;
}
const stillValid = scoped.some((c) => c.value === current);
if (current != null && stillValid) { if (current != null && stillValid) {
return; return;
} }
const next = const next =
clusterOptions.find((c) => c.is_default)?.value ?? scoped.find((c) => c.is_default)?.value ??
clusterOptions.find((c) => c.state === ClusterStatusValueMap.Ready) scoped.find((c) => c.state === ClusterStatusValueMap.Ready)?.value ??
?.value ?? scoped[0]?.value ??
clusterOptions[0]?.value ??
null; null;
if (next == null || next === current) { if (next == null || next === current) {
return; return;
} }
form.setFieldValue('cluster_id', next); form.setFieldValue('cluster_id', next);
onClusterSeed?.(next); onClusterSeed?.(next);
}, [clusterOptions, form, onClusterSeed]); // `clusterOptions` is the re-run trigger for scope changes: it recomputes
// whenever the watched org scope or the cluster list settles.
}, [clusterOptions, clusterList, action, form, onClusterSeed]);
const clusterOptionRender = (option: any) => { const clusterOptionRender = (option: any) => {
const { data } = option; const { data } = option;