fix: parse download progress
This commit is contained in:
@@ -5,6 +5,7 @@ import Inner from './inner';
|
|||||||
interface LabelSelectorProps {
|
interface LabelSelectorProps {
|
||||||
labels: Record<string, any>;
|
labels: Record<string, any>;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
btnText?: string;
|
||||||
description?: React.ReactNode;
|
description?: React.ReactNode;
|
||||||
onChange?: (labels: Record<string, any>) => void;
|
onChange?: (labels: Record<string, any>) => void;
|
||||||
}
|
}
|
||||||
@@ -13,6 +14,7 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
|
|||||||
labels,
|
labels,
|
||||||
onChange,
|
onChange,
|
||||||
label,
|
label,
|
||||||
|
btnText,
|
||||||
description
|
description
|
||||||
}) => {
|
}) => {
|
||||||
const [labelsData, setLabelsData] = useState({});
|
const [labelsData, setLabelsData] = useState({});
|
||||||
@@ -48,6 +50,7 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
|
|||||||
return (
|
return (
|
||||||
<Inner
|
<Inner
|
||||||
label={label}
|
label={label}
|
||||||
|
btnText={btnText}
|
||||||
description={description}
|
description={description}
|
||||||
labels={labelsData}
|
labels={labelsData}
|
||||||
labelList={labelList}
|
labelList={labelList}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Wrapper from './wrapper';
|
|||||||
interface LabelSelectorProps {
|
interface LabelSelectorProps {
|
||||||
labels: Record<string, any>;
|
labels: Record<string, any>;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
btnText?: string;
|
||||||
labelList: Array<{ key: string; value: string }>;
|
labelList: Array<{ key: string; value: string }>;
|
||||||
onLabelListChange: (list: { key: string; value: string }[]) => void;
|
onLabelListChange: (list: { key: string; value: string }[]) => void;
|
||||||
onChange?: (labels: Record<string, any>) => void;
|
onChange?: (labels: Record<string, any>) => void;
|
||||||
@@ -20,6 +21,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
|||||||
onChange,
|
onChange,
|
||||||
onLabelListChange,
|
onLabelListChange,
|
||||||
label,
|
label,
|
||||||
|
btnText,
|
||||||
description
|
description
|
||||||
}) => {
|
}) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -97,7 +99,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
|||||||
>
|
>
|
||||||
<PlusOutlined className="font-size-14" />{' '}
|
<PlusOutlined className="font-size-14" />{' '}
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
id: 'common.button.addSelector'
|
id: btnText || 'common.button.addSelector'
|
||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import useSetChunkRequest from '@/hooks/use-chunk-request';
|
|||||||
import useContainerScroll from '@/hooks/use-container-scorll';
|
import useContainerScroll from '@/hooks/use-container-scorll';
|
||||||
import Convert from 'ansi-to-html';
|
import Convert from 'ansi-to-html';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
|
||||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
@@ -26,47 +25,59 @@ const LogsViewer: React.FC<LogsViewerProps> = (props) => {
|
|||||||
|
|
||||||
const convert = new Convert({
|
const convert = new Convert({
|
||||||
newline: true,
|
newline: true,
|
||||||
escapeXML: true
|
escapeXML: true,
|
||||||
|
stream: false
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateScrollerPosition();
|
updateScrollerPosition();
|
||||||
}, [logsContent]);
|
}, [logsContent]);
|
||||||
|
|
||||||
const getTrailingACount = useCallback((str: string) => {
|
const endsWithAnsiEscapeSequence = useCallback((str: string) => {
|
||||||
const match = str.match(/A+$/);
|
const ansiEscapeRegex = /\x1B\[[0-9;]*[A-Za-z]$/;
|
||||||
return match ? match[0].length : 0;
|
return ansiEscapeRegex.test(str);
|
||||||
}, []);
|
}, []);
|
||||||
const parseHtmlStr = useCallback((htmlStr: string) => {
|
const getCursorUpLines = useCallback((str: string) => {
|
||||||
const result: string[] = [];
|
const match = str.match(/\x1B\[(\d*)A$/);
|
||||||
const htmlStrArr = _.filter(
|
|
||||||
htmlStr?.split?.('<br/>'),
|
|
||||||
(item: string) => item
|
|
||||||
);
|
|
||||||
|
|
||||||
htmlStrArr.forEach((item: string, index: number) => {
|
if (match) {
|
||||||
const aCount = getTrailingACount(item);
|
return match[1] === '' ? 1 : parseInt(match[1], 10);
|
||||||
if (aCount > 0) {
|
} else {
|
||||||
console.log('aCount========', {
|
return null;
|
||||||
htmlStrArr,
|
}
|
||||||
aCount,
|
}, []);
|
||||||
item,
|
|
||||||
length: result.length,
|
const parseHtmlStr = useCallback((logStr: string) => {
|
||||||
result: [...result]
|
const result: string[] = [];
|
||||||
});
|
const lines = logStr?.split?.('\n');
|
||||||
const placeIndex = result.length - aCount;
|
|
||||||
result[placeIndex] = item.slice(0, -aCount);
|
lines.forEach((line: string, index: number) => {
|
||||||
|
const upCount = getCursorUpLines(line);
|
||||||
|
if (endsWithAnsiEscapeSequence(line)) {
|
||||||
|
if (upCount) {
|
||||||
|
const placeIndex = result.length - upCount;
|
||||||
|
result[placeIndex] = line;
|
||||||
|
} else {
|
||||||
|
result.push(line);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push(item);
|
if (line.includes('\r')) {
|
||||||
|
const parts = line.split('\r');
|
||||||
|
const lastLine = parts[parts.length - 1];
|
||||||
|
result.push(lastLine);
|
||||||
|
} else {
|
||||||
|
result.push(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result.map((item) => {
|
||||||
|
return convert.toHtml(item);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const updateContent = (newVal: string) => {
|
const updateContent = (newVal: string) => {
|
||||||
const htmlStr = `${convert.toHtml(newVal)}`;
|
const list = parseHtmlStr(newVal);
|
||||||
const list = parseHtmlStr(htmlStr);
|
|
||||||
setLogsContent(list);
|
setLogsContent(list);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
export const text = `reflection-llama-3.1-70b
|
|
||||||
Hugging Face / Reflection-Llama-3.1-70B.Q6_K*.gguf
|
|
||||||
0 / 1
|
|
||||||
2024-09-10 17:42:25
|
|
||||||
reflection-llama-3.1-70b-2cDWS
|
|
||||||
0.42%
|
|
||||||
2024-09-10 17:42:25
|
|
||||||
|
|
||||||
gemma2-27b
|
|
||||||
Ollama Library / gemma2:27b
|
|
||||||
0 / 1
|
|
||||||
2024-09-10 16:54:13
|
|
||||||
gemma2-27b-m37dz
|
|
||||||
58.98%
|
|
||||||
2024-09-10 16:54:13
|
|
||||||
|
|
||||||
查看日志
|
|
||||||
2024-09-10T17:42:27+08:00 - gpustack.worker.downloaders - INFO - Downloading model leafspark/Reflection-Llama-3.1-70B-GGUF/Reflection-Llama-3.1-70B.Q6_K*.gguf
|
|
||||||
|
|
||||||
Fetching 2 files: 0%| | 0/2 [00:00<?, ?it/s]
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.0G/39.9G [00:00<?, ?B/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.0G/39.9G [00:05<2:30:05, 1.98MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.0G/39.9G [00:10<2:26:57, 2.02MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.0G/39.9G [00:15<2:27:42, 2.01MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:20<2:23:48, 2.06MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:25<2:22:41, 2.08MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:30<2:22:08, 2.09MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:35<2:22:43, 2.08MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:40<2:22:49, 2.07MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:45<2:21:54, 2.09MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 55%|█████▌ | 22.1G/39.9G [00:50<2:21:42, 2.09MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.1G/39.9G [00:55<2:23:39, 2.06MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.1G/39.9G [01:01<2:25:09, 2.04MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.1G/39.9G [01:06<2:23:30, 2.06MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.2G/39.9G [01:11<2:26:31, 2.01MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.2G/39.9G [01:16<2:26:04, 2.02MB/s]A
|
|
||||||
|
|
||||||
(…)n-Llama-3.1-70B.Q6_K-00001-of-00002.gguf: 56%|█████▌ | 22.2G/39.9G [01:21<2:25:13, 2.03MB/s]A`;
|
|
||||||
|
|
||||||
export default text;
|
|
||||||
@@ -8,7 +8,7 @@ export default {
|
|||||||
'resources.table.hostname': 'Hostname',
|
'resources.table.hostname': 'Hostname',
|
||||||
'resources.table.key.tips': 'The same key exists.',
|
'resources.table.key.tips': 'The same key exists.',
|
||||||
'resources.form.advanced': 'Advanced',
|
'resources.form.advanced': 'Advanced',
|
||||||
'resources.form.enablePartialOffload': 'Allow Partial Offload',
|
'resources.form.enablePartialOffload': 'Allow CPU Offload',
|
||||||
'resources.form.placementStrategy': 'Placement Strategy',
|
'resources.form.placementStrategy': 'Placement Strategy',
|
||||||
'resources.form.workerSelector': 'Worker Selector',
|
'resources.form.workerSelector': 'Worker Selector',
|
||||||
'resources.form.enableDistributedInferenceAcrossWorkers':
|
'resources.form.enableDistributedInferenceAcrossWorkers':
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ const UpdateLabels: React.FC<ViewModalProps> = (props) => {
|
|||||||
id: 'resources.table.labels'
|
id: 'resources.table.labels'
|
||||||
})}
|
})}
|
||||||
labels={labels}
|
labels={labels}
|
||||||
|
btnText="common.button.addLabel"
|
||||||
onChange={handleLabelsChange}
|
onChange={handleLabelsChange}
|
||||||
></LabelSelector>
|
></LabelSelector>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const { Column } = Table;
|
|||||||
|
|
||||||
const ActionList = [
|
const ActionList = [
|
||||||
{
|
{
|
||||||
label: 'resources.button.edittags',
|
label: 'common.button.edit',
|
||||||
key: 'edit',
|
key: 'edit',
|
||||||
icon: <TagsOutlined />
|
icon: <TagsOutlined />
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user