From 0d56d4ae996d887ac577af44dc13ffa493169ec3 Mon Sep 17 00:00:00 2001 From: jstzwj <1103870790@qq.com> Date: Mon, 8 Jul 2024 23:02:04 +0800 Subject: [PATCH] add tests --- .github/workflows/dev.yml | 2 +- .github/workflows/release.yml | 4 ++-- README.md | 7 ++++--- README_zh.md | 7 ++++--- pyproject.toml | 2 +- requirements.txt | 3 ++- tests/simple_test.py | 15 +++++++++++++++ 7 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 tests/simple_test.py diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 6475c93..a660bb5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -35,4 +35,4 @@ jobs: - name: Test Olah run: | cd ${{ github.workspace }} - python -m unittest discover olah/tests + python -m unittest discover tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0fa9e6f..8c6bc16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ run-name: Olah GitHub Actions to release on: push: tags: - - "[0-9]+.[0-9]+.[0-9]+" + - "v*" jobs: build: @@ -36,7 +36,7 @@ jobs: - name: Test Olah run: | cd ${{ github.workspace }} - python -m unittest discover olah/tests + python -m unittest discover tests - name: Build Olah run: | diff --git a/README.md b/README.md index eeb24e6..db4dd7f 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,10 @@ $env:HF_ENDPOINT = "http://localhost:8090" ``` Starting from now on, all download operations in the HuggingFace library will be proxied through this mirror site. +```bash +pip install -U huggingface_hub +``` + ```python from huggingface_hub import snapshot_download @@ -64,9 +68,6 @@ snapshot_download(repo_id='Qwen/Qwen-7B', repo_type='model', ``` Or you can download models and datasets by using huggingface cli. -```bash -pip install -U huggingface_hub -``` Download GPT2: ```bash diff --git a/README_zh.md b/README_zh.md index 5794884..1267b82 100644 --- a/README_zh.md +++ b/README_zh.md @@ -52,6 +52,10 @@ $env:HF_ENDPOINT = "http://localhost:8090" ``` 从现在开始,HuggingFace库中的所有下载操作都将通过此镜像站点代理进行。 +```bash +pip install -U huggingface_hub +``` + ```python from huggingface_hub import snapshot_download @@ -62,9 +66,6 @@ snapshot_download(repo_id='Qwen/Qwen-7B', repo_type='model', ``` 或者你也可以使用huggingface cli直接下载模型和数据集. -```bash -pip install -U huggingface_hub -``` 下载GPT2: ```bash diff --git a/pyproject.toml b/pyproject.toml index 5e28fa4..227a823 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["black==23.3.0", "pylint==2.8.2"] +dev = ["black==23.3.0", "pylint==2.8.2", "pytest==8.2.2"] [project.urls] "Homepage" = "https://github.com/vtuber-plan/olah" diff --git a/requirements.txt b/requirements.txt index 531f43e..4671c08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ fastapi httpx pydantic==1.10.8 -toml==0.10.2 \ No newline at end of file +toml==0.10.2 +huggingface_hub==0.23.3 \ No newline at end of file diff --git a/tests/simple_test.py b/tests/simple_test.py new file mode 100644 index 0000000..336dc7b --- /dev/null +++ b/tests/simple_test.py @@ -0,0 +1,15 @@ +import os +import subprocess +import time + +from huggingface_hub import snapshot_download + +def test_simple(): + process = subprocess.Popen(['python', '-m', 'olah.server']) + + os.environ['HF_ENDPOINT'] = 'http://localhost:8090' + snapshot_download(repo_id='Nerfgun3/bad_prompt', repo_type='dataset', + local_dir='./dataset_dir', max_workers=8) + + # 终止子进程 + process.terminate() \ No newline at end of file