Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when no backup URL provided #1527

Merged
merged 2 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release_notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ is available in the [commit logs](https://github.com/YosefLab/scvi-tools/commits
```{toctree}
:maxdepth: 2

v0.16.2
v0.16.1
v0.16.0
```
Expand Down
19 changes: 19 additions & 0 deletions docs/release_notes/v0.16.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# New in 0.16.2 (2022-MM-DD)

## Changes

## Breaking changes

## Bug Fixes
- Raise appropriate error when `backup_url` is not provided and file is missing on {meth}`~scvi.model.base.BaseModelClass.load` ([#1527]).

## Contributors

- [@jjhong922]
- [@adamgayoso]

[#1527]: https://github.com/YosefLab/scvi-tools/pull/1527


[@adamgayoso]: https://github.com/adamgayoso
[@jjhong922]: https://github.com/jjhong922
10 changes: 8 additions & 2 deletions scvi/data/_download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import os
import urllib
from typing import Optional

import numpy as np

Expand All @@ -9,10 +10,15 @@
logger = logging.getLogger(__name__)


def _download(url: str, save_path: str, filename: str):
def _download(url: Optional[str], save_path: str, filename: str):
"""Writes data from url to file."""
if os.path.exists(os.path.join(save_path, filename)):
logger.info("File %s already downloaded" % (os.path.join(save_path, filename)))
logger.info(f"File {os.path.join(save_path, filename)} already downloaded")
return
elif url is None:
logger.info(
f"No backup URL provided for missing file {os.path.join(save_path, filename)}"
)
return
req = urllib.request.Request(url, headers={"User-Agent": "Magic Browser"})
try:
Expand Down