diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..ff7a00b --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml index a4903af..e07d20e 100644 --- a/.github/workflows/tox.yaml +++ b/.github/workflows/tox.yaml @@ -1,39 +1,17 @@ -name: Tox -on: [push] +on: push +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true jobs: - # Based on https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache docker: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Run tests in docker build - uses: docker/build-push-action@v2 + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v5 with: context: . file: Dockerfile target: tests - push: false - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 24a2839..dd51043 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6.9 AS main +FROM python:3.8 AS main # Install binary dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/src/pmqd/torch.py b/src/pmqd/torch.py index 98d2ec6..113e201 100644 --- a/src/pmqd/torch.py +++ b/src/pmqd/torch.py @@ -8,8 +8,9 @@ import pandas as pd import torchaudio +from torch.hub import download_url_to_file as download_url from torch.utils.data import Dataset -from torchaudio.datasets.utils import download_url, extract_archive +from torchaudio.datasets.utils import _extract_tar from . import checksums @@ -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( diff --git a/tests/test_torch.py b/tests/test_torch.py index 6b77d7e..0464b9c 100644 --- a/tests/test_torch.py +++ b/tests/test_torch.py @@ -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) @@ -35,6 +35,6 @@ def mock_download_url(url: str, download_folder: str, hash_value: str) -> None: assert isinstance(example["rating"], float) # Check that files are not downloaded again - with patch("torchaudio.datasets.utils.download_url") as patched: + with patch("pmqd.torch.download_url") as patched: dataset = PMQD(root=tmp_path, download=True) patched.assert_not_called() diff --git a/tox.ini b/tox.ini index 735c88b..8024108 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py36 +envlist = py38 [testenv] ignore_errors = true @@ -15,6 +15,8 @@ deps = mypy pydocstyle pytest + dill + types-all commands = # Check formatting