Commit eb1ca1fa authored by Wei Shoulin's avatar Wei Shoulin
Browse files

local_file check

parent 0603a95d
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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)        
+4 −2
Original line number Diff line number Diff line
@@ -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],
@@ -195,6 +195,8 @@ def write(local_file: Union[IO | str],
        'batch_id': batch_id
    }
    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)