diff --git a/csst_dfs_client/level1.py b/csst_dfs_client/level1.py index b92b01d61a7ad2abec4ac54c090c1f95818ee31b..cc6067096fd40f4e37836d41293eedd98beb9219 100644 --- a/csst_dfs_client/level1.py +++ b/csst_dfs_client/level1.py @@ -152,7 +152,7 @@ def update_prc_status(level1_id: str, file_type: str, prc_status: int, batch_id: """ return request.put(f"/api/level1/prc_status/{level1_id}", {'file_type': file_type, 'prc_status': prc_status, 'batch_id': batch_id}) -def write(local_file: Union[IO | str], +def write(local_file: Union[IO, str], module_id: Literal['MSC', 'IFS', 'MCI', 'HSTDM', 'CPIC'], level0_id: Optional[str | None], level1_id: Optional[str | None], @@ -168,7 +168,7 @@ def write(local_file: Union[IO | str], 将本地的1级数据文件写入到DFS中其他参数如rss_id, cube_id等,可通过extra_kwargs传入 Args: - local_file (Union[IO | str]): 文件路径或文件对象 + local_file (Union[IO, str]): 文件路径或文件对象 module_id ['MSC', 'IFS', 'MCI', 'HSTDM', 'CPIC']其中一个,代表: 模块ID level0_id (Optional[str | None]): 0级数据的ID默认为 None level1_id (Optional[str | None]): 1级数据的ID默认为 None @@ -199,6 +199,8 @@ def write(local_file: Union[IO | str], if not dataset or not batch_id: raise ValueError("dataset and batch_id is required") params.update(extra_kwargs) + if local_file is None: + raise ValueError("local_file is required") if isinstance(local_file, str): if not os.path.exists(local_file): raise FileNotFoundError(local_file) diff --git a/csst_dfs_client/level2.py b/csst_dfs_client/level2.py index b506ae1414482bb9c08f5d26de5ff59d59f8c158..af21f82b0b7b4c9fa8199050f2c45612900465a4 100644 --- a/csst_dfs_client/level2.py +++ b/csst_dfs_client/level2.py @@ -145,7 +145,7 @@ def update_prc_status_by_file_name(file_name: str, prc_status: int, batch_id: st """ return request.put(f"/api/level2/prc_status/file/{file_name}", {'prc_status': prc_status, 'batch_id': batch_id}) -def write(local_file: Union[IO | str], +def write(local_file: Union[IO, str], module_id: Literal['MSC', 'IFS', 'MCI', 'HSTDM', 'CPIC'], level0_id: Optional[str | None], level1_id: Optional[str | None], @@ -194,7 +194,9 @@ def write(local_file: Union[IO | str], 'dataset': dataset, 'batch_id': batch_id } - params.update(extra_kwargs) + params.update(extra_kwargs) + if local_file is None: + raise ValueError("local_file is required") if isinstance(local_file, str): if not os.path.exists(local_file): raise FileNotFoundError(local_file)