Skip to content

Commit

Permalink
Backport PR scverse#2615: feat(hub): add unsigned arg to hubmodel s3 …
Browse files Browse the repository at this point in the history
…pull
  • Loading branch information
martinkim0 authored and meeseeksmachine committed Mar 19, 2024
1 parent 955651b commit 5365fec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/release_notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ is available in the [commit logs](https://github.com/scverse/scvi-tools/commits/
in {func}`scvi.autotune.run_autotune` {pr}`2605`.
- Add {class}`scvi.external.VELOVI` for RNA velocity estimation using variational inference
{pr}`2611`.
- Add `unsigned` argument to {meth}`scvi.hub.HubModel.pull_from_s3` to allow for unsigned
downloads of models from AWS S3 {pr}`2615`.

#### Changed

Expand Down
7 changes: 7 additions & 0 deletions scvi/hub/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def pull_from_s3(
s3_path: str,
pull_anndata: bool = True,
cache_dir: str | None = None,
unsigned: bool = False,
**kwargs,
) -> HubModel:
"""Download a :class:`~scvi.hub.HubModel` from an S3 bucket.
Expand All @@ -312,6 +313,9 @@ def pull_from_s3(
cache_dir
The directory where the downloaded model files will be cached. Defaults to a temporary
directory created with :func:`tempfile.mkdtemp`.
unsigned
Whether to use unsigned requests. If ``True`` and ``config`` is passed in ``kwargs``,
``config`` will be overwritten.
**kwargs
Keyword arguments passed into :func:`~boto3.client`.
Expand All @@ -320,7 +324,10 @@ def pull_from_s3(
The pretrained model specified by the given S3 bucket and path.
"""
from boto3 import client
from botocore import UNSIGNED, config

if unsigned:
kwargs["config"] = config.Config(signature_version=UNSIGNED)
cache_dir = cache_dir or tempfile.mkdtemp()
s3 = client("s3", **kwargs)

Expand Down

0 comments on commit 5365fec

Please sign in to comment.