Skip to content
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
28 changes: 17 additions & 11 deletions .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,26 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies

# Setup venv
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.
- name: Setup venv + uv
run: |
pip install --upgrade pip
pip install .[dev]
- run: ruff check tests src contrib # linter
- run: ruff format --check tests src contrib # formatter
- run: python utils/check_contrib_list.py
- run: python utils/check_static_imports.py
- run: python utils/generate_async_inference_client.py
- run: python utils/generate_inference_types.py
pip install --upgrade uv
uv venv

- name: Install dependencies
run: uv pip install "huggingface_hub[dev] @ ."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to do uv pip install --system "huggingface_hub[dev] @ ." on the latest release, if you want to remove the virtualenv (per the PR summary), but using a virtualenv is also good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @charliermarsh! I just saw the issue has been merged on uv's repo 🎉. Thanks for the direct ping here ❤️

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course! It's pretty new so of course ping if you see issues with it.

- run: .venv/bin/ruff check tests src contrib # linter
- run: .venv/bin/ruff format --check tests src contrib # formatter
- run: .venv/bin/python utils/check_contrib_list.py
- run: .venv/bin/python utils/check_static_imports.py
- run: .venv/bin/python utils/generate_async_inference_client.py
- run: .venv/bin/python utils/generate_inference_types.py

# Run type checking at least on huggingface_hub root file to check all modules
# that can be lazy-loaded actually exist.
- run: mypy src/huggingface_hub/__init__.py --follow-imports=silent --show-traceback
- run: .venv/bin/mypy src/huggingface_hub/__init__.py --follow-imports=silent --show-traceback

# Run mypy on full package
- run: mypy src
- run: .venv/bin/mypy src
40 changes: 23 additions & 17 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Setup venv
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.
- name: Setup venv + uv
run: |
pip install --upgrade uv
uv venv

# Install dependencies
- name: Configure and install dependencies
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .[testing]
uv pip install "huggingface_hub[testing] @ ."

case "${{ matrix.test_name }}" in

Expand All @@ -63,25 +69,22 @@ jobs:
;;

fastai | torch)
pip install .[${{ matrix.test_name }}]
uv pip install "huggingface_hub[${{ matrix.test_name }}] @ ."
;;

tensorflow)
sudo apt update
sudo apt install -y graphviz
pip install .[tensorflow]
uv pip install "huggingface_hub[tensorflow] @ ."
;;

esac

# Easy debugging if CI is broken
- name: Pip freeze
run: pip freeze

# Run tests
- name: Run tests
working-directory: ./src # For code coverage to work
run: |
source ../.venv/bin/activate
PYTEST="python -m pytest --cov=./huggingface_hub --cov-report=xml:../coverage.xml --vcr-record=none --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504||not less than or equal to 0.01)'"

case "${{ matrix.test_name }}" in
Expand Down Expand Up @@ -148,20 +151,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

# Install dependencies
- name: Configure and install dependencies
# Setup venv
# TODO: revisit when https://github.com/astral-sh/uv/issues/1526 is addressed.
- name: Setup venv + uv
run: |
pip install --upgrade pip
pip install .[testing]
pip install --upgrade uv
uv venv

# Easy debugging if CI is broken
- name: Pip freeze
run: pip freeze
# Install dependencies
- name: Install dependencies
run: uv pip install "huggingface_hub[testing] @ ."

# Run tests
- name: Run tests
working-directory: ./src # For code coverage to work
run: python -m pytest -n 4 --cov=./huggingface_hub --cov-report=xml:../coverage.xml --vcr-record=none --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504|not less than or equal to 0.01)' ../tests
run: |
..\.venv\Scripts\activate
python -m pytest -n 4 --cov=./huggingface_hub --cov-report=xml:../coverage.xml --vcr-record=none --reruns 5 --reruns-delay 1 --only-rerun '(OSError|Timeout|HTTPError.*502|HTTPError.*504|not less than or equal to 0.01)' ../tests

# Upload code coverage
- name: Upload coverage reports to Codecov with GitHub Action
Expand Down