Skip to content

Commit

Permalink
rename path to file_path
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway committed Nov 25, 2024
1 parent bd48754 commit 317f815
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/artifact-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions hypha/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -2273,15 +2273,15 @@ 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(
Bucket=s3_config["bucket"], Key=file_key
)
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",
Expand All @@ -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,
Expand Down

0 comments on commit 317f815

Please sign in to comment.