From 317f815eb66843ce0030a6b745b47a9c8fb492ab Mon Sep 17 00:00:00 2001 From: Wei Ouyang Date: Mon, 25 Nov 2024 03:02:01 -0800 Subject: [PATCH] rename path to file_path --- docs/artifact-manager.md | 4 ++-- hypha/artifact.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/artifact-manager.md b/docs/artifact-manager.md index b5030d3f..857b039c 100644 --- a/docs/artifact-manager.md +++ b/docs/artifact-manager.md @@ -492,14 +492,14 @@ await artifact_manager.remove_file(artifact_id="other_workspace/example-dataset" --- -### `get_file(artifact_id: str, path: str, silent: bool = False) -> str` +### `get_file(artifact_id: str, file_path: str, silent: bool = False) -> str` Generates a pre-signed URL to download a file from the artifact stored in S3. **Parameters:** - `artifact_id`: The id of the artifact to download the file from. It can be an uuid generated by `create` or `edit` function, or it can be an alias of the artifact under the current workspace. If you want to refer to an artifact in another workspace, you should use the full alias in the format of `"workspace_id/alias"`. -- `path`: The relative path of the file to download (e.g., `"data.csv"`). +- `file_path`: The relative path of the file to download (e.g., `"data.csv"`). - `silent`: A boolean to suppress the download count increment. Default is `False`. **Returns:** A pre-signed URL for downloading the file. diff --git a/hypha/artifact.py b/hypha/artifact.py index e023cd66..731e95b9 100644 --- a/hypha/artifact.py +++ b/hypha/artifact.py @@ -2252,7 +2252,7 @@ async def remove_file(self, artifact_id, file_path, context: dict): await session.close() async def get_file( - self, artifact_id, path, silent=False, version=None, context: dict = None + self, artifact_id, file_path, silent=False, version=None, context: dict = None ): """Generate a pre-signed URL to download a file from an artifact in S3.""" if context is None or "ws" not in context: @@ -2273,7 +2273,7 @@ async def get_file( file_key = safe_join( s3_config["prefix"], artifact.workspace, - f"{self._artifacts_dir}/{artifact.id}/v{version_index}/{path}", + f"{self._artifacts_dir}/{artifact.id}/v{version_index}/{file_path}", ) try: await s3_client.head_object( @@ -2281,7 +2281,7 @@ async def get_file( ) except ClientError: raise FileNotFoundError( - f"File '{path}' does not exist in the artifact." + f"File '{file_path}' does not exist in the artifact." ) presigned_url = await s3_client.generate_presigned_url( "get_object", @@ -2299,7 +2299,7 @@ async def get_file( download_weights = artifact.config.get("download_weights", {}) else: download_weights = {} - download_weight = download_weights.get(path) or 0 + download_weight = download_weights.get(file_path) or 0 if download_weight > 0: await self._increment_stat( session,