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

Support Python 3.12 #236

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
7 changes: 7 additions & 0 deletions .coveragerc.python3.12
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[report]
exclude_lines =
pragma: no cover
pragma: no Linux cover
omit =
audbackend/core/api.py
audbackend/core/backend/artifactory.py
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
python-version: '3.9'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -48,16 +50,22 @@ jobs:
run: |
pip install -r requirements.txt

- name: Test with pytest
- name: Test with pytest for Python <3.12
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }}
run: |
python -m pytest --cov-config=.coveragerc.${{ runner.os }}
if: matrix.python-version != '3.12'

- name: Test with pytest for Python 3.12
run: |
python -m pytest --cov-config=.coveragerc.python3.12 --ignore=audbackend/core/backend/artifactory.py --ignore=tests/test_backend_artifactory.py
if: matrix.python-version == '3.12'

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-latest' and matrix.python-version != '3.12'
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ the requested data structure
in a repository
on a storage system,
such as a file system
or Artifactory_.
or MinIO_.

Have a look at the installation_ and usage_ instructions.

.. _Artifactory: https://jfrog.com/artifactory/
.. _MinIO: https://min.io
.. _backends: https://audeering.github.io/audbackend/api/audbackend.backend.html
.. _interfaces: https://audeering.github.io/audbackend/api/audbackend.interface.html
.. _installation: https://audeering.github.io/audbackend/install.html
Expand Down
4 changes: 4 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ e.g. :class:`audbackend.backend.Artifactory`
.. code-block:: bash

$ pip install audbackend[artifactory]

Note,
in Python 3.12 the :class:`audbackend.backend.Artifactory`
backend is no longer available.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ classifiers = [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering',
]
dependencies = [
Expand All @@ -37,13 +38,13 @@ dynamic = ['version']

[project.optional-dependencies]
artifactory = [
'dohq-artifactory >=0.10.0',
'dohq-artifactory >=0.10.0; python_version < "3.12"',
]
minio = [
'minio',
]
all = [
'dohq-artifactory >=0.10.0',
'dohq-artifactory >=0.10.0; python_version < "3.12"',
'minio',
]

Expand Down
28 changes: 17 additions & 11 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest

import audeer
Expand All @@ -6,25 +8,29 @@


@pytest.mark.parametrize(
"name, host, repository, cls",
"name, host, repository, expected_class",
[
(
"file-system",
"file-system",
f"unittest-{audeer.uid()[:8]}",
audbackend.backend.FileSystem,
"audbackend.backend.FileSystem",
),
(
pytest.param(
"artifactory",
"artifactory",
f"unittest-{audeer.uid()[:8]}",
audbackend.backend.Artifactory,
"audbackend.backend.Artifactory",
marks=pytest.mark.skipif(
sys.version_info > (3, 11),
reason="Requires Python 3.11 or lower",
),
),
(
"minio",
"minio",
f"unittest-{audeer.uid()[:8]}",
audbackend.backend.Minio,
"audbackend.backend.Minio",
),
pytest.param( # backend does not exist
"bad-backend",
Expand All @@ -34,22 +40,22 @@
marks=pytest.mark.xfail(raises=ValueError),
),
pytest.param( # host does not exist
"artifactory",
"minio",
"bad-host",
"repo",
None,
marks=pytest.mark.xfail(raises=audbackend.BackendError),
),
pytest.param( # invalid repository name
"artifactory",
"artifactory",
"minio",
"minio",
"bad/repo",
None,
marks=pytest.mark.xfail(raises=audbackend.BackendError),
),
],
)
def test_api(hosts, name, host, repository, cls):
def test_api(hosts, name, host, repository, expected_class):
if host is not None and host in hosts:
host = hosts[name]

Expand Down Expand Up @@ -84,15 +90,15 @@ def test_api(hosts, name, host, repository, cls):
with pytest.warns(UserWarning, match=create_warning):
interface = audbackend.create(name, host, repository)
assert isinstance(interface, audbackend.interface.Versioned)
assert isinstance(interface.backend, cls)
assert str(interface.backend).startswith(expected_class)

with pytest.raises(audbackend.BackendError, match=error_msg):
with pytest.warns(UserWarning, match=create_warning):
audbackend.create(name, host, repository)

with pytest.warns(UserWarning, match=access_warning):
interface = audbackend.access(name, host, repository)
assert isinstance(interface.backend, cls)
assert str(interface.backend).startswith(expected_class)

with pytest.warns(UserWarning, match=delete_warning):
audbackend.delete(name, host, repository)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_interface_unversioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

# Backend-interface combinations to use in all tests
backend_interface_combinations = [
(audbackend.backend.Artifactory, audbackend.interface.Unversioned),
(audbackend.backend.FileSystem, audbackend.interface.Unversioned),
(audbackend.backend.Minio, audbackend.interface.Unversioned),
(SingleFolder, audbackend.interface.Unversioned),
]
if hasattr(audbackend.backend, "Artifactory"):
backend_interface_combinations.append(
(audbackend.backend.Artifactory, audbackend.interface.Unversioned)
)
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="function", autouse=False)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_legacy_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

def test_legacy_import(hosts):
audbackend.Backend("host", "repo")
audbackend.Artifactory(hosts["artifactory"], "repo")
audbackend.FileSystem(hosts["file-system"], "repo")
if hasattr(audbackend, "Artifactory"):
audbackend.Artifactory(hosts["artifactory"], "repo")
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved
hagenw marked this conversation as resolved.
Show resolved Hide resolved