Skip to content

Commit

Permalink
Migrate from deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlthome committed Nov 9, 2023
1 parent 2e89edb commit 8210cd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/pmqd/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import pandas as pd
import torchaudio
from torch.utils.data import Dataset
from torchaudio.datasets.utils import download_url, extract_archive
from torch.hub import download_url_to_file as download_url
from torchaudio.datasets.utils import _extract_tar

from . import checksums

Expand Down Expand Up @@ -56,10 +57,10 @@ def __init__(
if download:
if not self._audio_path.exists():
if not archive.is_file():
download_url(url_audio, root, hash_value=CHECKSUM_AUDIO)
extract_archive(archive)
download_url(url_audio, str(root), hash_prefix=CHECKSUM_AUDIO)
_extract_tar(str(archive))
if not self._metadata_path.is_file():
download_url(url_metadata, root, hash_value=CHECKSUM_METADATA)
download_url(url_metadata, str(root), hash_prefix=CHECKSUM_METADATA)

if not self._metadata_path.is_file():
raise FileNotFoundError(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_torchaudio_no_dowload(tmp_path: Path):


def test_torchaudio_download(tmp_path: Path, dummy_data: Dict[str, Path]):
def mock_download_url(url: str, download_folder: str, hash_value: str) -> None:
def mock_download_url(url: str, download_folder: str, hash_prefix: str) -> None:
filename = os.path.basename(url)
shutil.copy(dummy_data[filename], download_folder)

Expand Down

0 comments on commit 8210cd3

Please sign in to comment.