fix: query catalog spec, default_version check

This commit is contained in:
jialin
2025-12-12 17:08:30 +08:00
parent cb43131ccb
commit 0500dd2e35
19 changed files with 86 additions and 23 deletions
+22 -2
View File
@@ -110,24 +110,44 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
const jsonData = yaml2Json(content);
const exsistingVersions = Object.keys(jsonData.version_configs || {});
// Check backend version rules
if (
actionStatus.isBuiltIn &&
exsistingVersions.find((v) => !v.endsWith('-custom'))
exsistingVersions.find((v) => !v?.endsWith('-custom'))
) {
setError(intl.formatMessage({ id: 'backend.version.no.tips' }));
return false;
}
// Check custom backend name rule
if (
!actionStatus.isBuiltIn &&
actionStatus.action === PageAction.CREATE &&
!jsonData.backend_name.endsWith('-custom')
!jsonData.backend_name?.endsWith('-custom')
) {
setError(intl.formatMessage({ id: 'backend.backend.rules.custom' }));
return false;
}
// Check default version exists
if (
jsonData.default_version &&
!exsistingVersions.includes(jsonData.default_version) &&
!actionStatus.isBuiltIn
) {
// the default_version must be in [existingVersions]
setError(
intl.formatMessage(
{ id: 'backend.version.default.not.exists' },
{ versions: exsistingVersions.join(', ') }
)
);
return false;
}
return content;
} catch (error) {
setError((error as Error).message);
return false;
}
};
@@ -88,12 +88,12 @@ const ViewerEditor: React.FC<ViewerProps> = forwardRef((props, ref) => {
}
};
// Currently, do not use this function, but keep it for future validation needs
const getMarkers = () => {
const uri = editorRef.current?.getModel()?.uri;
const markers = monacoRef.current?.editor.getModelMarkers({
resource: uri
});
console.log('Validation markers:', uri, markers);
return markers;
};
+1 -1
View File
@@ -367,7 +367,7 @@ export async function queryCatalogList(
}
export async function queryCatalogItemSpec(
params: { id: number; cluster_id: number },
params: { id: number; cluster_id: number | null },
options?: any
) {
return request<Global.PageResponse<CatalogSpec>>(
+4 -1
View File
@@ -198,7 +198,10 @@ const Catalog: React.FC = () => {
const getCatalogSource = async () => {
try {
const id = dataSource.dataList?.[0]?.id;
const res: any = await queryCatalogItemSpec({ id, cluster_id: 0 });
const res: any = await queryCatalogItemSpec({
id,
cluster_id: null
});
sourceRef.current = res?.items?.[0]?.source;
} catch (error) {}
};
@@ -250,6 +250,16 @@ const AddModal: React.FC<AddModalProps> = (props) => {
cluster_id: clusterId,
name
});
// If no avaliable gpus for the model, show warning message
if (!res.items.length) {
setWarningStatus({
show: true,
type: 'warning',
message: intl.formatMessage({ id: 'models.catalog.nogpus.tips' })
});
return;
}
handleCheckCompatibility(allValues);
} catch (error) {
// ignore
-1
View File
@@ -103,7 +103,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const [form] = Form.useForm();
const intl = useIntl();
const [activeKey, setActiveKey] = React.useState<string[]>([]);
const scheduleType = Form.useWatch('scheduleType', form);
const [target, setTarget] = React.useState<string>(TABKeysMap.BASIC);
console.log('scroller instance in form:', osInstance, scrollEventElement);
+6 -1
View File
@@ -296,7 +296,12 @@ export const useCheckCompatibility = () => {
title: intl.formatMessage({ id: 'models.form.check.passed' }),
message: intl.formatMessage({ id: messageId }, { ram, vram })
};
} else if (othersAvailable) {
} else if (
othersAvailable &&
!scheduling_messages?.length &&
!compatibility_messages?.length
) {
// no specific messages, but other clusters are available
msgData = {
title: intl.formatMessage({
id: 'models.form.check.clusterUnavailable'
+4 -1
View File
@@ -24,11 +24,14 @@ export const login = async (
};
export const logout = async (userInfo?: any) => {
await request(`${AUTH_API}/logout`, {
const res = await request(`${AUTH_API}/logout`, {
method: 'POST'
});
clearStorageUserSettings();
clearAtomStorage(userAtom);
if (res.logout_url) {
window.location.href = res.logout_url;
}
return;
};