From 69406249cb62253f5e08c414348fd6bc2ce81b90 Mon Sep 17 00:00:00 2001
From: Bin <bin.zheng@slooong.com>
Date: 星期三, 17 十二月 2025 11:13:23 +0800
Subject: [PATCH] 测试脚本_3
---
label_studio/data_export/mixins.py | 50 +++++++++++++++++++++++++-------------------------
1 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/label_studio/data_export/mixins.py b/label_studio/data_export/mixins.py
index d251861..9246a32 100644
--- a/label_studio/data_export/mixins.py
+++ b/label_studio/data_export/mixins.py
@@ -352,19 +352,19 @@
upload_dir = os.path.join(settings.MEDIA_ROOT, settings.UPLOAD_DIR)
# 调试日志:打印关键参数
- logger.info(f'[COCO Export Debug] ========== Export Started ==========')
- logger.info(f'[COCO Export Debug] Project ID: {self.project.id}')
- logger.info(f'[COCO Export Debug] Export format: {to_format}')
- logger.info(f'[COCO Export Debug] download_resources: {download_resources}')
- logger.info(f'[COCO Export Debug] hostname: {hostname}')
- logger.info(f'[COCO Export Debug] upload_dir: {upload_dir}')
- logger.info(f'[COCO Export Debug] upload_dir exists: {os.path.exists(upload_dir)}')
+ logger.error(f'[COCO Export Debug] ========== Export Started ==========')
+ logger.error(f'[COCO Export Debug] Project ID: {self.project.id}')
+ logger.error(f'[COCO Export Debug] Export format: {to_format}')
+ logger.error(f'[COCO Export Debug] download_resources: {download_resources}')
+ logger.error(f'[COCO Export Debug] hostname: {hostname}')
+ logger.error(f'[COCO Export Debug] upload_dir: {upload_dir}')
+ logger.error(f'[COCO Export Debug] upload_dir exists: {os.path.exists(upload_dir)}')
if os.path.exists(upload_dir):
- logger.info(f'[COCO Export Debug] upload_dir contents: {os.listdir(upload_dir)}')
- logger.info(f'[COCO Export Debug] tmp_dir: {tmp_dir}')
- logger.info(f'[COCO Export Debug] out_dir: {out_dir}')
- logger.info(f'[COCO Export Debug] settings.MEDIA_ROOT: {settings.MEDIA_ROOT}')
- logger.info(f'[COCO Export Debug] settings.UPLOAD_DIR: {settings.UPLOAD_DIR}')
+ logger.error(f'[COCO Export Debug] upload_dir contents: {os.listdir(upload_dir)}')
+ logger.error(f'[COCO Export Debug] tmp_dir: {tmp_dir}')
+ logger.error(f'[COCO Export Debug] out_dir: {out_dir}')
+ logger.error(f'[COCO Export Debug] settings.MEDIA_ROOT: {settings.MEDIA_ROOT}')
+ logger.error(f'[COCO Export Debug] settings.UPLOAD_DIR: {settings.UPLOAD_DIR}')
converter = Converter(
config=self.project.get_parsed_config(),
@@ -378,30 +378,30 @@
input_name = pathlib.Path(self.file.name).name
input_file_path = pathlib.Path(tmp_dir) / input_name
- logger.info(f'[COCO Export Debug] input_name: {input_name}')
- logger.info(f'[COCO Export Debug] input_file_path: {input_file_path}')
+ logger.error(f'[COCO Export Debug] input_name: {input_name}')
+ logger.error(f'[COCO Export Debug] input_file_path: {input_file_path}')
with open(input_file_path, 'wb') as file_:
file_.write(self.file.open().read())
- logger.info(f'[COCO Export Debug] Starting converter.convert...')
+ logger.error(f'[COCO Export Debug] Starting converter.convert...')
converter.convert(input_file_path, out_dir, to_format, is_dir=False)
- logger.info(f'[COCO Export Debug] Converter.convert completed')
+ logger.error(f'[COCO Export Debug] Converter.convert completed')
files = get_all_files_from_dir(out_dir)
dirs = get_all_dirs_from_dir(out_dir)
- logger.info(f'[COCO Export Debug] Output files: {files}')
- logger.info(f'[COCO Export Debug] Output dirs: {dirs}')
+ logger.error(f'[COCO Export Debug] Output files: {files}')
+ logger.error(f'[COCO Export Debug] Output dirs: {dirs}')
# 检查是否有 images 目录
images_dir = out_dir / 'images'
if images_dir.exists():
image_files = list(images_dir.glob('*'))
- logger.info(f'[COCO Export Debug] images/ directory exists with {len(image_files)} files')
- logger.info(f'[COCO Export Debug] Image files: {[f.name for f in image_files]}')
+ logger.error(f'[COCO Export Debug] images/ directory exists with {len(image_files)} files')
+ logger.error(f'[COCO Export Debug] Image files: {[f.name for f in image_files]}')
else:
- logger.warning(f'[COCO Export Debug] images/ directory does NOT exist')
+ logger.error(f'[COCO Export Debug] images/ directory does NOT exist')
if len(files) == 0 and len(dirs) == 0:
logger.error(f'[COCO Export Debug] No files or dirs in output')
@@ -409,15 +409,15 @@
elif len(files) == 1 and len(dirs) == 0:
output_file = files[0]
filename = pathlib.Path(input_name).stem + pathlib.Path(output_file).suffix
- logger.info(f'[COCO Export Debug] Single file output: {output_file}')
+ logger.error(f'[COCO Export Debug] Single file output: {output_file}')
else:
- logger.info(f'[COCO Export Debug] Creating zip archive...')
+ logger.error(f'[COCO Export Debug] Creating zip archive...')
shutil.make_archive(out_dir, 'zip', out_dir)
output_file = pathlib.Path(tmp_dir) / (str(out_dir.stem) + '.zip')
filename = pathlib.Path(input_name).stem + '.zip'
- logger.info(f'[COCO Export Debug] Zip archive created: {output_file}')
+ logger.error(f'[COCO Export Debug] Zip archive created: {output_file}')
- logger.info(f'[COCO Export Debug] ========== Export Completed ==========')
+ logger.error(f'[COCO Export Debug] ========== Export Completed ===========')
# TODO(jo): can we avoid the `f.read()` here?
with open(output_file, mode='rb') as f:
--
Gitblit v1.9.3