Skip to content

Commit df162a5

Browse files
authored
支持文件元数据透传 (#414)
* 支持界面展示报错 * 支持文件元数据透传
1 parent 730452e commit df162a5

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

frontend/src/i18n/locales/en/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,8 @@
14321432
"processedFileType": "Processed File Type",
14331433
"beforeSize": "Before Size",
14341434
"afterSize": "After Size",
1435+
"result": "Result",
1436+
"resultDetail": "Result Detail",
14351437
"status": "Status",
14361438
"actions": "Actions",
14371439
"searchFileName": "Search file name",

frontend/src/i18n/locales/zh/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,8 @@
14321432
"processedFileType": "处理后文件类型",
14331433
"beforeSize": "处理前大小",
14341434
"afterSize": "处理后大小",
1435+
"result": "处理结果",
1436+
"resultDetail": "处理结果详情",
14351437
"status": "状态",
14361438
"actions": "操作",
14371439
"searchFileName": "搜索文件名",

frontend/src/pages/DataCleansing/Detail/components/FileTable.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,53 @@ export default function FileTable({result, fetchTaskResult}) {
262262
<span className="font-mono text-sm">{formatFileSize(number)}</span>
263263
),
264264
},
265+
{
266+
title: t("dataCleansing.detail.fileTable.result"),
267+
dataIndex: "result",
268+
key: "result",
269+
width: 200,
270+
render: (text: string) => {
271+
if (!text) return <span className="text-gray-400">-</span>;
272+
273+
try {
274+
const parsed = JSON.parse(text);
275+
const jsonString = JSON.stringify(parsed, null, 2);
276+
const displayText = typeof parsed === 'object'
277+
? (Array.isArray(parsed) ? `[${parsed.length} items]` : '{...}')
278+
: String(parsed);
279+
280+
return (
281+
<Popover
282+
content={
283+
<pre className="max-w-md max-h-64 overflow-auto text-xs bg-gray-50 p-2 rounded">
284+
{jsonString}
285+
</pre>
286+
}
287+
title={t("dataCleansing.detail.fileTable.resultDetail")}
288+
trigger="click"
289+
>
290+
<span className="font-mono text-sm text-blue-600 cursor-pointer hover:text-blue-800">
291+
{displayText}
292+
</span>
293+
</Popover>
294+
);
295+
} catch {
296+
const displayText = text.length > 30 ? text.substring(0, 30) + '...' : text;
297+
return (
298+
<Popover
299+
content={<div className="max-w-md text-sm">{text}</div>}
300+
title={t("dataCleansing.detail.fileTable.resultDetail")}
301+
trigger="click"
302+
disabled={text.length <= 30}
303+
>
304+
<span className="font-mono text-sm cursor-default">
305+
{displayText}
306+
</span>
307+
</Popover>
308+
);
309+
}
310+
},
311+
},
265312
{
266313
title: t("dataCleansing.detail.fileTable.status"),
267314
dataIndex: "status",

runtime/datamate-python/app/module/cleaning/service/cleaning_task_service.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ async def scan_dataset(
326326
target_file_path.parent.mkdir(parents=True, exist_ok=True)
327327

328328
query = text("""
329-
SELECT id, file_name, file_path, file_type, file_size
329+
SELECT id, file_name, file_path, file_type, file_size, metadata
330330
FROM t_dm_dataset_files
331331
WHERE dataset_id = :dataset_id
332332
ORDER BY created_at
@@ -340,12 +340,22 @@ async def scan_dataset(
340340
if succeed_files and file.id in succeed_files:
341341
continue
342342

343+
metadata_dict = {}
344+
if file.metadata:
345+
try:
346+
parsed = json.loads(file.metadata)
347+
if isinstance(parsed, dict):
348+
metadata_dict = parsed
349+
except (json.JSONDecodeError, TypeError):
350+
pass
351+
343352
file_info = {
344353
"fileId": file.id,
345354
"fileName": file.file_name,
346355
"filePath": file.file_path,
347356
"fileType": file.file_type,
348357
"fileSize": file.file_size,
358+
"metadata": metadata_dict,
349359
}
350360
f.write(json.dumps(file_info, ensure_ascii=False) + "\n")
351361

runtime/python-executor/datamate/wrappers/executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def load_meta(self, line):
4343
meta["sourceFileType"] = meta.get("fileType")
4444
if meta.get("fileSize"):
4545
meta["sourceFileSize"] = meta.get("fileSize")
46+
else:
47+
meta["sourceFileSize"] = 0
4648
if not meta.get("totalPageNum"):
4749
meta["totalPageNum"] = 0
4850
if not meta.get("extraFilePath"):

0 commit comments

Comments
 (0)