Skip to content

Commit

Permalink
Support python 3.12 (#2605)
Browse files Browse the repository at this point in the history
* running CI with python 3.12

* test tensorflow with python 3.12

* remove deprecated assertEquals

* run torch 1.* tests only on python 3.8

* fix workflow

* skip completion test

* update skipping comment

* Run CI on python 3.13 and update docs

* Revert "Run CI on python 3.13 and update docs"

This reverts commit e9a03bf.
  • Loading branch information
hanouticelina authored Oct 15, 2024
1 parent a4bc2e5 commit 9bb6bd6
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_repocard_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
python-version: 3.12

# Install dependencies
- name: Configure and install dependencies
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
test_name:
[
"Repository only",
"Everything else",
"torch_1.11",
"torch_latest",
]
include:
- python-version: "3.11" # LFS not ran on 3.8
- python-version: "3.12" # LFS not ran on 3.8
test_name: "lfs"
- python-version: "3.8"
test_name: "fastai" # fastai not supported on 3.11 -> test it on 3.10
- python-version: "3.10"
test_name: "fastai"
- python-version: "3.10" # fastai not supported on 3.12 and 3.11 -> test it on 3.10
test_name: "fastai"
- python-version: "3.8"
test_name: "tensorflow" # Tensorflow not supported on 3.11 -> test it on 3.10
- python-version: "3.10"
test_name: "tensorflow"

- python-version: "3.10" # tensorflow not supported on 3.12 -> test it on 3.10
test_name: "tensorflow"
- python-version: "3.8" # test torch~=1.11 on python 3.8 only.
test_name: "Python 3.8, torch_1.11"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
uv pip install --upgrade torch
;;
torch_1.11)
"Python 3.8, torch_1.11")
uv pip install "huggingface_hub[torch] @ ."
uv pip install torch~=1.11
;;
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
eval "$PYTEST ../tests/test_serialization.py"
;;
torch_1.11 | torch_latest)
"Python 3.8, torch_1.11" | torch_latest)
eval "$PYTEST ../tests/test_hub_mixin*"
eval "$PYTEST ../tests/test_serialization.py"
;;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cn/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ cd huggingface_hub
pip install -e .
```

这些命令将你克隆存储库的文件夹与你的 Python 库路径链接起来。Python 现在将除了正常的库路径之外,还会在你克隆到的文件夹中查找。例如,如果你的 Python 包通常安装在`./.venv/lib/python3.11/site-packages/`中,Python 还会搜索你克隆的文件夹`./huggingface_hub/`
这些命令将你克隆存储库的文件夹与你的 Python 库路径链接起来。Python 现在将除了正常的库路径之外,还会在你克隆到的文件夹中查找。例如,如果你的 Python 包通常安装在`./.venv/lib/python3.12/site-packages/`中,Python 还会搜索你克隆的文件夹`./huggingface_hub/`

## 通过 conda 安装

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ cd huggingface_hub
pip install -e .
```

Diese Befehle verknüpfen den Ordner, in den Sie das Repository geklont haben, mit Ihren Python-Bibliothekspfaden. Python wird nun zusätzlich zu den normalen Bibliothekspfaden im geklonten Ordner suchen. Wenn Ihre Python-Pakete normalerweise in `./.venv/lib/python3.11/site-packages/` installiert sind, wird Python auch den geklonten Ordner `./huggingface_hub/` durchsuchen.
Diese Befehle verknüpfen den Ordner, in den Sie das Repository geklont haben, mit Ihren Python-Bibliothekspfaden. Python wird nun zusätzlich zu den normalen Bibliothekspfaden im geklonten Ordner suchen. Wenn Ihre Python-Pakete normalerweise in `./.venv/lib/python3.12/site-packages/` installiert sind, wird Python auch den geklonten Ordner `./huggingface_hub/` durchsuchen.

## Installieren mit conda

Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pip install -e .

These commands will link the folder you cloned the repository to and your Python library paths.
Python will now look inside the folder you cloned to in addition to the normal library paths.
For example, if your Python packages are typically installed in `./.venv/lib/python3.11/site-packages/`,
For example, if your Python packages are typically installed in `./.venv/lib/python3.12/site-packages/`,
Python will also search the folder you cloned `./huggingface_hub/`.

## Install with conda
Expand Down
6 changes: 3 additions & 3 deletions docs/source/fr/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pip install 'huggingface_hub[cli,torch]'
Voici une liste des dépendances optionnelles dans `huggingface_hub`:
- `cli` fournit une interface d'invite de commande plus pratique pour `huggingface_hub`.
- `fastai`, `torch` et `tensorflow` sont des dépendances pour utiliser des fonctionnalités spécifiques à un framework.
- `dev` permet de contribuer à la librairie. Cette dépendance inclut `testing` (pour lancer des tests), `typing` (pour lancer le vérifieur de type) et `quality` (pour lancer des linters).
- `dev` permet de contribuer à la librairie. Cette dépendance inclut `testing` (pour lancer des tests), `typing` (pour lancer le vérifieur de type) et `quality` (pour lancer des linters).



Expand Down Expand Up @@ -104,7 +104,7 @@ pip install -e .

Python regardera maintenant à l'intérieur du dossier dans lequel vous avez cloné le dépôt en
plus des chemins de librairie classiques. Par exemple, si vos packages Python sont installés dans
`./.venv/lib/python3.11/site-packages/`, Python regardera aussi dans le dossier que vous avez
`./.venv/lib/python3.12/site-packages/`, Python regardera aussi dans le dossier que vous avez
cloné `./huggingface_hub/`.

## Installation avec conda
Expand Down Expand Up @@ -158,4 +158,4 @@ pour que nous cherchions une solution.

Une fois que `huggingface_hub` est installé correctement sur votre machine, vous aurez peut-être besoin de
[configurer les variables d'environnement](package_reference/environment_variables) ou de [lire un de nos guides](guides/overview)
pour vous lancer.
pour vous lancer.
2 changes: 1 addition & 1 deletion docs/source/hi/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pip install -e .

ये कमांड उस फ़ोल्डर को लिंक करेंगे जिसे आपने रिपॉजिटरी में क्लोन किया है और आपके पायथन लाइब्रेरी पथ।
पाइथॉन अब सामान्य लाइब्रेरी पथों के अलावा आपके द्वारा क्लोन किए गए फ़ोल्डर के अंदर भी देखेगा।
उदाहरण के लिए, यदि आपके पायथन पैकेज आमतौर पर `./.venv/lib/python3.11/site-packages/` में स्थापित हैं,
उदाहरण के लिए, यदि आपके पायथन पैकेज आमतौर पर `./.venv/lib/python3.12/site-packages/` में स्थापित हैं,
पायथन आपके द्वारा क्लोन किए गए फ़ोल्डर `./huggingface_hub/` को भी खोजेगा।

## कोंडा के साथ स्थापित करें
Expand Down
2 changes: 1 addition & 1 deletion docs/source/ko/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pip install -e .

이렇게 클론한 레포지토리 폴더와 Python 경로를 연결합니다.
이제 Python은 일반적인 라이브러리 경로 외에도 복제된 폴더 내부를 찾습니다.
예를 들어 파이썬 패키지가 일반적으로 `./.venv/lib/python3.11/site-packages/`에 설치되어 있다면, Python은 복제된 폴더 `./huggingface_hub/`도 검색하게 됩니다.
예를 들어 파이썬 패키지가 일반적으로 `./.venv/lib/python3.12/site-packages/`에 설치되어 있다면, Python은 복제된 폴더 `./huggingface_hub/`도 검색하게 됩니다.

## conda로 설치하기 [[install-with-conda]]

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def get_version() -> str:
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
include_package_data=True,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_init_lazy_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@


class TestHuggingfaceHubInit(unittest.TestCase):
@unittest.skip(
reason="`jedi.Completion.get_signatures()` output differs between Python 3.12 and earlier versions, affecting test consistency"
)
def test_autocomplete_on_root_imports(self) -> None:
"""Test autocomplete with `huggingface_hub` works with Jedi.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_snapshot_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_download_model_local_only(self):
snapshot_download(self.repo_id, local_dir=tmpdir)
# now load from local_dir
storage_folder = snapshot_download(self.repo_id, local_dir=tmpdir, local_files_only=True)
self.assertEquals(str(tmpdir), storage_folder)
self.assertEqual(str(tmpdir), storage_folder)

def test_download_model_to_local_dir_with_offline_mode(self):
"""Test that an already downloaded folder is returned when there is a connection error"""
Expand All @@ -161,7 +161,7 @@ def test_download_model_to_local_dir_with_offline_mode(self):
for offline_mode in OfflineSimulationMode:
with offline(mode=offline_mode):
storage_folder = snapshot_download(self.repo_id, local_dir=tmpdir)
self.assertEquals(str(tmpdir), storage_folder)
self.assertEqual(str(tmpdir), storage_folder)

def test_download_model_offline_mode_not_in_local_dir(self):
"""Test when connection error but local_dir is empty."""
Expand Down

0 comments on commit 9bb6bd6

Please sign in to comment.