Unverified Commit 307f632b authored by Arthur's avatar Arthur Committed by GitHub
Browse files

[`CI update`] Try to use dockers and no cache (#29202)



* change cis

* nits

* update

* minor updates

* [push-ci-image]

* nit [push-ci-image]

* nitsssss

* [build-ci-image]

* [push-ci-image]

* [push-ci-image]

* both

* [push-ci-image]

* this?

* [push-ci-image]

* pypi-kenlm needs g++

* [push-ci-image]

* nit

* more nits [push-ci-image]

* nits [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* add vision

* [push-ci-image]

* [push-ci-image]

* add new dummy file but will need to update them [push-ci-image]

* [push-ci-image]

* show package size as well

* [push-ci-image]

* potentially ignore failures

* workflow updates

* nits [push-ci-image]

* [push-ci-image]

* fix consistency

* clean nciida triton

* also show big packages [push-ci-image]

* nit

* update

* another one

* line escape?

* add accelerate [push-ci-image]

* updates [push-ci-image]

* nits to run tests, no push-ci

* try to parse skip reason to make sure nothing is skipped that should no be skippped

* nit?

* always show skipped reasons

* nits

* better parsing of the test outputs

* action="store_true",

* failure on failed

* show matched

* debug

* update short summary with skipped, failed and errors

* nits

* nits

* coolu pdates

* remove docbuilder

* fix

* always run checks

* oups

* nits

* don't error out on library printing

* non zero exi codes

* no warning

* nit

* WAT?

* format nit

* [push-ci-image]

* fail if fail is needed

* [push-ci-image]

* sound file for torch light?

* [push-ci-image]

* order is important [push-ci-image]

* [push-ci-image] reduce even further

* [push-ci-image]

* use pytest rich !

* yes [push-ci-image]

* oupsy

* bring back the full traceback, but pytest rich should help

* nit

* [push-ci-image]

* re run

* nit

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* empty push to trigger

* [push-ci-image]

* nit? [push-ci-image]

* empty

* try to install timm with no deps

* [push-ci-image]

* oups [push-ci-image]

* [push-ci-image]

* [push-ci-image] ?

* [push-ci-image] open ssh client for git checkout fast

* empty for torch light

* updates [push-ci-image]

* nit

* @v4 for checkout

* [push-ci-image]

* [push-ci-image]

* fix fetch tests with parallelism

* [push-ci-image]

* more parallelism

* nit

* more nits

* empty to re-trigger

* empty to re-trigger

* split by timing

* did not work with previous commit

* junit.xml

* no path?

* mmm this?

* junitxml format

* split by timing

* nit

* fix junit family

* now we can test if the xunit1 is compatible!

* this?

* fully list tests

* update

* update

* oups

* finally

* use classname

* remove working directory to make sure the path does not interfere

* okay no juni should have the correct path

* name split?

* sort by classname is what make most sense

* some testing

* naem

* oups

* test something fun

* autodetect

* 18?

* nit

* file size?

* uip

* 4 is best

* update to see versions

* better print

* [push-ci-image]

* [push-ci-image]

* please install the correct keras version

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* uv is fucking me up

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* nits

* [push-ci-image]

* [push-ci-image]

* install issues an pins

* tapas as well

* nits

* more paralellism

* short tb

* soundfile

* soundfile

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* oups

* [push-ci-image]

* fix some things

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* use torch-light for hub

* small git lfs for hub job

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* fix tf tapas

* [push-ci-image]

* nits

* [push-ci-image]

* don't update the test

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* no use them

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* update tf proba

* [push-ci-image]

* [push-ci-image]

* woops

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* test with built dockers

* [push-ci-image]

* skip annoying tests

* revert fix copy

* update test values

* update

* last skip and fixup

* nit

* ALL GOOOD

* quality

* Update tests/models/layoutlmv2/test_image_processing_layoutlmv2.py

* Update docker/quality.dockerfile
Co-authored-by: default avatarLysandre Debut <hi@lysand.re>

* Update src/transformers/models/tapas/modeling_tf_tapas.py
Co-authored-by: default avatarLysandre Debut <hi@lysand.re>

* Apply suggestions from code review
Co-authored-by: default avatarLysandre Debut <hi@lysand.re>

* use torch-speed

* updates

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* [push-ci-image]

* fuck ken-lm [push-ci-image]

* [push-ci-image]

* [push-ci-image]

---------
Co-authored-by: default avatarLysandre Debut <hi@lysand.re>
parent 91d155ea
...@@ -12,7 +12,7 @@ jobs: ...@@ -12,7 +12,7 @@ jobs:
# Ensure running with CircleCI/huggingface # Ensure running with CircleCI/huggingface
check_circleci_user: check_circleci_user:
docker: docker:
- image: cimg/python:3.8.12 - image: python:3.10-slim
parallelism: 1 parallelism: 1
steps: steps:
- run: echo $CIRCLE_PROJECT_USERNAME - run: echo $CIRCLE_PROJECT_USERNAME
...@@ -26,13 +26,11 @@ jobs: ...@@ -26,13 +26,11 @@ jobs:
fetch_tests: fetch_tests:
working_directory: ~/transformers working_directory: ~/transformers
docker: docker:
- image: cimg/python:3.8.12 - image: huggingface/transformers-quality
parallelism: 1 parallelism: 1
steps: steps:
- checkout - checkout
- run: pip install --upgrade --upgrade-strategy eager pip - run: uv pip install -U -e .
- run: pip install -U --upgrade-strategy eager GitPython
- run: pip install -U --upgrade-strategy eager .
- run: mkdir -p test_preparation - run: mkdir -p test_preparation
- run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt
- store_artifacts: - store_artifacts:
...@@ -88,25 +86,22 @@ jobs: ...@@ -88,25 +86,22 @@ jobs:
echo "No tests to run, exiting early!" echo "No tests to run, exiting early!"
circleci-agent step halt circleci-agent step halt
fi fi
- run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt
- store_artifacts: - store_artifacts:
path: test_preparation/generated_config.txt path: test_preparation/generated_config.yml
- store_artifacts: - store_artifacts:
path: test_preparation/filtered_test_list_cross_tests.txt path: test_preparation/filtered_test_list_cross_tests.txt
- continuation/continue: - continuation/continue:
configuration_path: test_preparation/generated_config.yml configuration_path: test_preparation/generated_config.yml
# To run all tests for the nightly build # To run all tests for the nightly build
fetch_all_tests: fetch_all_tests:
working_directory: ~/transformers working_directory: ~/transformers
docker: docker:
- image: cimg/python:3.8.12 - image: huggingface/transformers-consistency
parallelism: 1 parallelism: 1
steps: steps:
- checkout - checkout
- run: pip install --upgrade --upgrade-strategy eager pip - run: uv pip install -e .
- run: pip install -U --upgrade-strategy eager GitPython
- run: pip install -U --upgrade-strategy eager .
- run: | - run: |
mkdir test_preparation mkdir test_preparation
echo -n "tests" > test_preparation/test_list.txt echo -n "tests" > test_preparation/test_list.txt
...@@ -126,7 +121,7 @@ jobs: ...@@ -126,7 +121,7 @@ jobs:
check_code_quality: check_code_quality:
working_directory: ~/transformers working_directory: ~/transformers
docker: docker:
- image: cimg/python:3.8.12 - image: huggingface/transformers-quality
resource_class: large resource_class: large
environment: environment:
TRANSFORMERS_IS_CI: yes TRANSFORMERS_IS_CI: yes
...@@ -134,24 +129,7 @@ jobs: ...@@ -134,24 +129,7 @@ jobs:
parallelism: 1 parallelism: 1
steps: steps:
- checkout - checkout
- restore_cache: - run: uv pip install -e .
keys:
- v0.7-code_quality-pip-{{ checksum "setup.py" }}
- v0.7-code-quality-pip
- restore_cache:
keys:
- v0.7-code_quality-site-packages-{{ checksum "setup.py" }}
- v0.7-code-quality-site-packages
- run: pip install --upgrade --upgrade-strategy eager pip
- run: pip install -U --upgrade-strategy eager .[all,quality]
- save_cache:
key: v0.7-code_quality-pip-{{ checksum "setup.py" }}
paths:
- '~/.cache/pip'
- save_cache:
key: v0.7-code_quality-site-packages-{{ checksum "setup.py" }}
paths:
- '~/.pyenv/versions/'
- run: - run:
name: Show installed libraries and their versions name: Show installed libraries and their versions
command: pip freeze | tee installed.txt command: pip freeze | tee installed.txt
...@@ -167,7 +145,7 @@ jobs: ...@@ -167,7 +145,7 @@ jobs:
check_repository_consistency: check_repository_consistency:
working_directory: ~/transformers working_directory: ~/transformers
docker: docker:
- image: cimg/python:3.8.12 - image: huggingface/transformers-consistency
resource_class: large resource_class: large
environment: environment:
TRANSFORMERS_IS_CI: yes TRANSFORMERS_IS_CI: yes
...@@ -175,24 +153,7 @@ jobs: ...@@ -175,24 +153,7 @@ jobs:
parallelism: 1 parallelism: 1
steps: steps:
- checkout - checkout
- restore_cache: - run: uv pip install -e .
keys:
- v0.7-repository_consistency-pip-{{ checksum "setup.py" }}
- v0.7-repository_consistency-pip
- restore_cache:
keys:
- v0.7-repository_consistency-site-packages-{{ checksum "setup.py" }}
- v0.7-repository_consistency-site-packages
- run: pip install --upgrade --upgrade-strategy eager pip
- run: pip install -U --upgrade-strategy eager .[all,quality]
- save_cache:
key: v0.7-repository_consistency-pip-{{ checksum "setup.py" }}
paths:
- '~/.cache/pip'
- save_cache:
key: v0.7-repository_consistency-site-packages-{{ checksum "setup.py" }}
paths:
- '~/.pyenv/versions/'
- run: - run:
name: Show installed libraries and their versions name: Show installed libraries and their versions
command: pip freeze | tee installed.txt command: pip freeze | tee installed.txt
......
...@@ -19,7 +19,7 @@ import os ...@@ -19,7 +19,7 @@ import os
import random import random
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
import glob
import yaml import yaml
...@@ -41,7 +41,6 @@ class EmptyJob: ...@@ -41,7 +41,6 @@ class EmptyJob:
def to_dict(self): def to_dict(self):
return { return {
"working_directory": "~/transformers",
"docker": copy.deepcopy(DEFAULT_DOCKER_IMAGE), "docker": copy.deepcopy(DEFAULT_DOCKER_IMAGE),
"steps":["checkout"], "steps":["checkout"],
} }
...@@ -61,7 +60,6 @@ class CircleCIJob: ...@@ -61,7 +60,6 @@ class CircleCIJob:
pytest_options: Dict[str, Any] = None pytest_options: Dict[str, Any] = None
resource_class: Optional[str] = "2xlarge" resource_class: Optional[str] = "2xlarge"
tests_to_run: Optional[List[str]] = None tests_to_run: Optional[List[str]] = None
working_directory: str = "~/transformers"
# This should be only used for doctest job! # This should be only used for doctest job!
command_timeout: Optional[int] = None command_timeout: Optional[int] = None
...@@ -92,7 +90,6 @@ class CircleCIJob: ...@@ -92,7 +90,6 @@ class CircleCIJob:
cache_branch_prefix = "pull" cache_branch_prefix = "pull"
job = { job = {
"working_directory": self.working_directory,
"docker": self.docker_image, "docker": self.docker_image,
"environment": env, "environment": env,
} }
...@@ -102,34 +99,14 @@ class CircleCIJob: ...@@ -102,34 +99,14 @@ class CircleCIJob:
job["parallelism"] = self.parallelism job["parallelism"] = self.parallelism
steps = [ steps = [
"checkout", "checkout",
{"attach_workspace": {"at": "~/transformers/test_preparation"}}, {"attach_workspace": {"at": "test_preparation"}},
{
"restore_cache": {
"keys": [
# check the fully-matched cache first
f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-" + '{{ checksum "setup.py" }}',
# try the partially-matched cache from `main`
f"v{self.cache_version}-{self.cache_name}-main-pip-",
# try the general partially-matched cache
f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-",
]
}
},
{
"restore_cache": {
"keys": [
f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-" + '{{ checksum "setup.py" }}',
f"v{self.cache_version}-{self.cache_name}-main-site-packages-",
f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-",
]
}
},
] ]
steps.extend([{"run": l} for l in self.install_steps]) steps.extend([{"run": l} for l in self.install_steps])
steps.extend([{"run": 'pip install "fsspec>=2023.5.0,<2023.10.0"'}]) steps.append({"run": {"name": "Show installed libraries and their size", "command": """du -h -d 1 "$(pip -V | cut -d ' ' -f 4 | sed 's/pip//g')" | grep -vE "dist-info|_distutils_hack|__pycache__" | sort -h | tee installed.txt || true"""}})
steps.extend([{"run": "pip install pytest-subtests"}]) steps.append({"run": {"name": "Show installed libraries and their versions", "command": """pip list --format=freeze | tee installed.txt || true"""}})
steps.append({"run": {"name": "Show installed libraries and their versions", "command": "pip freeze | tee installed.txt"}})
steps.append({"store_artifacts": {"path": "~/transformers/installed.txt"}}) steps.append({"run":{"name":"Show biggest libraries","command":"""dpkg-query --show --showformat='${Installed-Size}\t${Package}\n' | sort -rh | head -25 | sort -h | awk '{ package=$2; sub(".*/", "", package); printf("%.5f GB %s\n", $1/1024/1024, package)}' || true"""}})
steps.append({"store_artifacts": {"path": "installed.txt"}})
all_options = {**COMMON_PYTEST_OPTIONS, **self.pytest_options} all_options = {**COMMON_PYTEST_OPTIONS, **self.pytest_options}
pytest_flags = [f"--{key}={value}" if (value is not None or key in ["doctest-modules"]) else f"-{key}" for key, value in all_options.items()] pytest_flags = [f"--{key}={value}" if (value is not None or key in ["doctest-modules"]) else f"-{key}" for key, value in all_options.items()]
...@@ -138,11 +115,11 @@ class CircleCIJob: ...@@ -138,11 +115,11 @@ class CircleCIJob:
) )
steps.append({"run": {"name": "Create `test-results` directory", "command": "mkdir test-results"}}) steps.append({"run": {"name": "Create `test-results` directory", "command": "mkdir test-results"}})
test_command = "" test_command = ""
if self.command_timeout: if self.command_timeout:
test_command = f"timeout {self.command_timeout} " test_command = f"timeout {self.command_timeout} "
test_command += f"python -m pytest -rs --junitxml=test-results/junit.xml -n {self.pytest_num_workers} " + " ".join(pytest_flags) # junit familiy xunit1 is necessary to support splitting on test name or class name with circleci split
test_command += f"python3 -m pytest -rsfE -p no:warnings -o junit_family=xunit1 --tb=short --junitxml=test-results/junit.xml -n {self.pytest_num_workers} " + " ".join(pytest_flags)
if self.parallelism == 1: if self.parallelism == 1:
if self.tests_to_run is None: if self.tests_to_run is None:
...@@ -167,13 +144,11 @@ class CircleCIJob: ...@@ -167,13 +144,11 @@ class CircleCIJob:
if test.endswith(".py"): if test.endswith(".py"):
expanded_tests.append(test) expanded_tests.append(test)
elif test == "tests/models": elif test == "tests/models":
expanded_tests.extend([os.path.join(test, x) for x in os.listdir(test)]) expanded_tests.extend(glob.glob("tests/models/**/test*.py", recursive=True))
elif test == "tests/pipelines": elif test == "tests/pipelines":
expanded_tests.extend([os.path.join(test, x) for x in os.listdir(test)]) expanded_tests.extend([os.path.join(test, x) for x in os.listdir(test)])
else: else:
expanded_tests.append(test) expanded_tests.append(test)
# Avoid long tests always being collected together
random.shuffle(expanded_tests)
tests = " ".join(expanded_tests) tests = " ".join(expanded_tests)
# Each executor to run ~10 tests # Each executor to run ~10 tests
...@@ -190,13 +165,13 @@ class CircleCIJob: ...@@ -190,13 +165,13 @@ class CircleCIJob:
command = 'TESTS=$(circleci tests split tests.txt) && echo $TESTS > splitted_tests.txt' command = 'TESTS=$(circleci tests split tests.txt) && echo $TESTS > splitted_tests.txt'
steps.append({"run": {"name": "Split tests", "command": command}}) steps.append({"run": {"name": "Split tests", "command": command}})
steps.append({"store_artifacts": {"path": "~/transformers/tests.txt"}}) steps.append({"store_artifacts": {"path": "tests.txt"}})
steps.append({"store_artifacts": {"path": "~/transformers/splitted_tests.txt"}}) steps.append({"store_artifacts": {"path": "splitted_tests.txt"}})
test_command = "" test_command = ""
if self.timeout: if self.command_timeout:
test_command = f"timeout {self.timeout} " test_command = f"timeout {self.command_timeout} "
test_command += f"python -m pytest -rs -n {self.pytest_num_workers} " + " ".join(pytest_flags) test_command += f"python3 -m pytest -rsfE -p no:warnings --tb=short -o junit_family=xunit1 --junitxml=test-results/junit.xml -n {self.pytest_num_workers} " + " ".join(pytest_flags)
test_command += " $(cat splitted_tests.txt)" test_command += " $(cat splitted_tests.txt)"
if self.marker is not None: if self.marker is not None:
test_command += f" -m {self.marker}" test_command += f" -m {self.marker}"
...@@ -211,61 +186,17 @@ class CircleCIJob: ...@@ -211,61 +186,17 @@ class CircleCIJob:
# failure. # failure.
test_command = f"({test_command}) || true" test_command = f"({test_command}) || true"
else: else:
test_command = f"({test_command} | tee tests_output.txt) || true" test_command = f"({test_command} | tee tests_output.txt)"
steps.append({"run": {"name": "Run tests", "command": test_command}}) steps.append({"run": {"name": "Run tests", "command": test_command}})
# Deal with errors steps.append({"run": {"name": "Skipped tests", "when": "always", "command": f"python3 .circleci/parse_test_outputs.py --file tests_output.txt --skip"}})
check_test_command = f'if [ -s reports/{self.job_name}/errors.txt ]; ' steps.append({"run": {"name": "Failed tests", "when": "always", "command": f"python3 .circleci/parse_test_outputs.py --file tests_output.txt --fail"}})
check_test_command += 'then echo "Some tests errored out!"; echo ""; ' steps.append({"run": {"name": "Errors", "when": "always", "command": f"python3 .circleci/parse_test_outputs.py --file tests_output.txt --errors"}})
check_test_command += f'cat reports/{self.job_name}/errors.txt; '
check_test_command += 'echo ""; echo ""; '
py_command = f'import os; fp = open("reports/{self.job_name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("ERROR ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()'
check_test_command += f"$(python3 -c '{py_command}'); "
check_test_command += 'cat summary_short.txt; echo ""; exit -1; '
# Deeal with failed tests
check_test_command += f'elif [ -s reports/{self.job_name}/failures_short.txt ]; '
check_test_command += 'then echo "Some tests failed!"; echo ""; '
check_test_command += f'cat reports/{self.job_name}/failures_short.txt; '
check_test_command += 'echo ""; echo ""; '
py_command = f'import os; fp = open("reports/{self.job_name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("FAILED ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()'
check_test_command += f"$(python3 -c '{py_command}'); "
check_test_command += 'cat summary_short.txt; echo ""; exit -1; '
check_test_command += f'elif [ -s reports/{self.job_name}/stats.txt ]; then echo "All tests pass!"; '
# return code `124` means the previous (pytest run) step is timeout
if self.name == "pr_documentation_tests":
check_test_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; '
check_test_command += 'else echo "other fatal error"; echo ""; exit -1; fi;'
steps.append({"run": {"name": "Check test results", "command": check_test_command}})
steps.append({"store_test_results": {"path": "test-results"}}) steps.append({"store_test_results": {"path": "test-results"}})
steps.append({"store_artifacts": {"path": "tests_output.txt"}})
steps.append({"store_artifacts": {"path": "~/transformers/tests_output.txt"}}) steps.append({"store_artifacts": {"path": "test-results/junit.xml"}})
steps.append({"store_artifacts": {"path": "~/transformers/reports"}}) steps.append({"store_artifacts": {"path": "reports"}})
# save cache at the end: so pytest step runs before cache saving and we can see results earlier
steps.append(
{
"save_cache": {
"key": f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-pip-" + '{{ checksum "setup.py" }}',
"paths": ["~/.cache/pip"],
}
}
)
steps.append(
{
"save_cache": {
"key": f"v{self.cache_version}-{self.cache_name}-{cache_branch_prefix}-site-packages-" + '{{ checksum "setup.py" }}',
"paths": ["~/.pyenv/versions/"],
}
}
)
job["steps"] = steps job["steps"] = steps
return job return job
...@@ -278,18 +209,9 @@ class CircleCIJob: ...@@ -278,18 +209,9 @@ class CircleCIJob:
# JOBS # JOBS
torch_and_tf_job = CircleCIJob( torch_and_tf_job = CircleCIJob(
"torch_and_tf", "torch_and_tf",
docker_image=[{"image":"huggingface/transformers-torch-tf-light"}],
install_steps=["uv venv && uv pip install ."],
additional_env={"RUN_PT_TF_CROSS_TESTS": True}, additional_env={"RUN_PT_TF_CROSS_TESTS": True},
install_steps=[
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng git-lfs cmake",
"git lfs install",
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]",
"pip install -U --upgrade-strategy eager tensorflow_probability",
# Without --no-deps we can't pin dependency versions in the future
"pip install -U --upgrade-strategy eager --no-deps -e git+https://github.com/huggingface/accelerate@main#egg=accelerate",
# TODO: remove this one after fixing the dependency issue(s) above
"pip install -U --upgrade-strategy eager torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu",
],
marker="is_pt_tf_cross_test", marker="is_pt_tf_cross_test",
pytest_options={"rA": None, "durations": 0}, pytest_options={"rA": None, "durations": 0},
) )
...@@ -298,77 +220,53 @@ torch_and_tf_job = CircleCIJob( ...@@ -298,77 +220,53 @@ torch_and_tf_job = CircleCIJob(
torch_and_flax_job = CircleCIJob( torch_and_flax_job = CircleCIJob(
"torch_and_flax", "torch_and_flax",
additional_env={"RUN_PT_FLAX_CROSS_TESTS": True}, additional_env={"RUN_PT_FLAX_CROSS_TESTS": True},
install_steps=[ docker_image=[{"image":"huggingface/transformers-torch-jax-light"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", install_steps=["uv venv && uv pip install ."],
"pip install -U --upgrade-strategy eager --upgrade pip",
"pip install -U --upgrade-strategy eager .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]",
# Without --no-deps we can't pin dependency versions in the future
"pip install -U --upgrade-strategy eager --no-deps -e git+https://github.com/huggingface/accelerate@main#egg=accelerate",
],
marker="is_pt_flax_cross_test", marker="is_pt_flax_cross_test",
pytest_options={"rA": None, "durations": 0}, pytest_options={"rA": None, "durations": 0},
) )
torch_job = CircleCIJob( torch_job = CircleCIJob(
"torch", "torch",
install_steps=[ docker_image=[{"image": "huggingface/transformers-torch-light"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip", parallelism=6,
"pip install -U --upgrade-strategy eager .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]", pytest_num_workers=16
# Without --no-deps we can't pin dependency versions in the future
"pip install -U --upgrade-strategy eager --no-deps -e git+https://github.com/huggingface/accelerate@main#egg=accelerate",
],
parallelism=1,
pytest_num_workers=12,
) )
tf_job = CircleCIJob( tf_job = CircleCIJob(
"tf", "tf",
install_steps=[ docker_image=[{"image":"huggingface/transformers-tf-light"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng cmake", install_steps=["uv venv", "uv pip install -e."],
"pip install --upgrade --upgrade-strategy eager pip", parallelism=6,
"pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]", pytest_num_workers=16,
"pip install -U --upgrade-strategy eager tensorflow_probability",
],
parallelism=1,
) )
flax_job = CircleCIJob( flax_job = CircleCIJob(
"flax", "flax",
install_steps=[ docker_image=[{"image":"huggingface/transformers-jax-light"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip", parallelism=6,
"pip install -U --upgrade-strategy eager .[flax,testing,sentencepiece,flax-speech,vision]", pytest_num_workers=16
],
parallelism=1,
) )
pipelines_torch_job = CircleCIJob( pipelines_torch_job = CircleCIJob(
"pipelines_torch", "pipelines_torch",
additional_env={"RUN_PIPELINE_TESTS": True}, additional_env={"RUN_PIPELINE_TESTS": True},
install_steps=[ docker_image=[{"image":"huggingface/transformers-torch-light"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm,video]",
],
marker="is_pipeline_test", marker="is_pipeline_test",
pytest_num_workers=12,
) )
pipelines_tf_job = CircleCIJob( pipelines_tf_job = CircleCIJob(
"pipelines_tf", "pipelines_tf",
additional_env={"RUN_PIPELINE_TESTS": True}, additional_env={"RUN_PIPELINE_TESTS": True},
install_steps=[ docker_image=[{"image":"huggingface/transformers-tf-light"}],
"sudo apt-get -y update && sudo apt-get install -y cmake", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[sklearn,tf-cpu,testing,sentencepiece,vision]",
"pip install -U --upgrade-strategy eager tensorflow_probability",
],
marker="is_pipeline_test", marker="is_pipeline_test",
) )
...@@ -376,22 +274,8 @@ pipelines_tf_job = CircleCIJob( ...@@ -376,22 +274,8 @@ pipelines_tf_job = CircleCIJob(
custom_tokenizers_job = CircleCIJob( custom_tokenizers_job = CircleCIJob(
"custom_tokenizers", "custom_tokenizers",
additional_env={"RUN_CUSTOM_TOKENIZERS": True}, additional_env={"RUN_CUSTOM_TOKENIZERS": True},
install_steps=[ docker_image=[{"image": "huggingface/transformers-custom-tokenizers"}],
"sudo apt-get -y update && sudo apt-get install -y cmake", install_steps=["uv venv","uv pip install -e ."],
{
"name": "install jumanpp",
"command":
"wget https://github.com/ku-nlp/jumanpp/releases/download/v2.0.0-rc3/jumanpp-2.0.0-rc3.tar.xz\n"
"tar xvf jumanpp-2.0.0-rc3.tar.xz\n"
"mkdir jumanpp-2.0.0-rc3/bld\n"
"cd jumanpp-2.0.0-rc3/bld\n"
"sudo cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local\n"
"sudo make install\n",
},
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[ja,testing,sentencepiece,jieba,spacy,ftfy,rjieba]",
"python -m unidic download",
],
parallelism=None, parallelism=None,
resource_class=None, resource_class=None,
tests_to_run=[ tests_to_run=[
...@@ -406,14 +290,8 @@ examples_torch_job = CircleCIJob( ...@@ -406,14 +290,8 @@ examples_torch_job = CircleCIJob(
"examples_torch", "examples_torch",
additional_env={"OMP_NUM_THREADS": 8}, additional_env={"OMP_NUM_THREADS": 8},
cache_name="torch_examples", cache_name="torch_examples",
install_steps=[ docker_image=[{"image":"huggingface/transformers-examples-torch"}],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[sklearn,torch,sentencepiece,testing,torch-speech]",
"pip install -U --upgrade-strategy eager -r examples/pytorch/_tests_requirements.txt",
# Without --no-deps we can't pin dependency versions in the future
"pip install -U --upgrade-strategy eager --no-deps -e git+https://github.com/huggingface/accelerate@main#egg=accelerate",
],
pytest_num_workers=1, pytest_num_workers=1,
) )
...@@ -421,24 +299,20 @@ examples_torch_job = CircleCIJob( ...@@ -421,24 +299,20 @@ examples_torch_job = CircleCIJob(
examples_tensorflow_job = CircleCIJob( examples_tensorflow_job = CircleCIJob(
"examples_tensorflow", "examples_tensorflow",
cache_name="tensorflow_examples", cache_name="tensorflow_examples",
install_steps=[ docker_image=[{"image":"huggingface/transformers-examples-tf"}],
"sudo apt-get -y update && sudo apt-get install -y cmake", install_steps=["uv venv && uv pip install ."],
"pip install --upgrade --upgrade-strategy eager pip", parallelism=8
"pip install -U --upgrade-strategy eager .[sklearn,tensorflow,sentencepiece,testing]",
"pip install -U --upgrade-strategy eager -r examples/tensorflow/_tests_requirements.txt",
],
) )
hub_job = CircleCIJob( hub_job = CircleCIJob(
"hub", "hub",
additional_env={"HUGGINGFACE_CO_STAGING": True}, additional_env={"HUGGINGFACE_CO_STAGING": True},
docker_image=[{"image":"huggingface/transformers-torch-light"}],
install_steps=[ install_steps=[
"sudo apt-get -y update && sudo apt-get install git-lfs", "uv venv && uv pip install .",
'git config --global user.email "ci@dummy.com"', 'git config --global user.email "ci@dummy.com"',
'git config --global user.name "ci"', 'git config --global user.name "ci"',
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[torch,sentencepiece,testing,vision]",
], ],
marker="is_staging_test", marker="is_staging_test",
pytest_num_workers=1, pytest_num_workers=1,
...@@ -447,10 +321,11 @@ hub_job = CircleCIJob( ...@@ -447,10 +321,11 @@ hub_job = CircleCIJob(
onnx_job = CircleCIJob( onnx_job = CircleCIJob(
"onnx", "onnx",
docker_image=[{"image":"huggingface/transformers-torch-tf-light"}],
install_steps=[ install_steps=[
"sudo apt-get -y update && sudo apt-get install -y cmake", "uv venv && uv pip install .",
"pip install --upgrade --upgrade-strategy eager pip", "uv pip install --upgrade eager pip",
"pip install -U --upgrade-strategy eager .[torch,tf,testing,sentencepiece,onnxruntime,vision,rjieba]", "uv pip install .[torch,tf,testing,sentencepiece,onnxruntime,vision,rjieba]",
], ],
pytest_options={"k onnx": None}, pytest_options={"k onnx": None},
pytest_num_workers=1, pytest_num_workers=1,
...@@ -459,22 +334,8 @@ onnx_job = CircleCIJob( ...@@ -459,22 +334,8 @@ onnx_job = CircleCIJob(
exotic_models_job = CircleCIJob( exotic_models_job = CircleCIJob(
"exotic_models", "exotic_models",
install_steps=[ install_steps=["uv venv && uv pip install ."],
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev", docker_image=[{"image":"huggingface/transformers-exotic-models"}],
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager .[torch,testing,vision]",
"pip install -U --upgrade-strategy eager torchvision",
"pip install -U --upgrade-strategy eager scipy",
"pip install -U --upgrade-strategy eager 'git+https://github.com/facebookresearch/detectron2.git'",
"sudo apt install tesseract-ocr",
"pip install -U --upgrade-strategy eager pytesseract",
"pip install --upgrade-strategy eager sentencepiece",
"pip install -U --upgrade-strategy eager natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels",
"pip install -U --upgrade-strategy eager python-Levenshtein",
"pip install -U --upgrade-strategy eager opencv-python",
"pip install -U --upgrade-strategy eager nltk",
"pip uninstall -y torch torchvision torchaudio && pip install -U --upgrade-strategy eager 'torch<2.2.0' 'torchvision<0.17' 'torchaudio<2.2.0'"
],
tests_to_run=[ tests_to_run=[
"tests/models/*layoutlmv*", "tests/models/*layoutlmv*",
"tests/models/*nat", "tests/models/*nat",
...@@ -482,17 +343,16 @@ exotic_models_job = CircleCIJob( ...@@ -482,17 +343,16 @@ exotic_models_job = CircleCIJob(
"tests/models/udop", "tests/models/udop",
"tests/models/nougat", "tests/models/nougat",
], ],
pytest_num_workers=1, pytest_num_workers=12,
parallelism=4,
pytest_options={"durations": 100}, pytest_options={"durations": 100},
) )
repo_utils_job = CircleCIJob( repo_utils_job = CircleCIJob(
"repo_utils", "repo_utils",
install_steps=[ docker_image=[{"image":"huggingface/transformers-consistency"}],
"pip install --upgrade --upgrade-strategy eager pip", install_steps=["uv venv && uv pip install ."],
"pip install -U --upgrade-strategy eager .[quality,testing,torch]",
],
parallelism=None, parallelism=None,
pytest_num_workers=1, pytest_num_workers=1,
resource_class="large", resource_class="large",
...@@ -508,20 +368,9 @@ py_command = f"$(python3 -c '{py_command}')" ...@@ -508,20 +368,9 @@ py_command = f"$(python3 -c '{py_command}')"
command = f'echo "{py_command}" > pr_documentation_tests_temp.txt' command = f'echo "{py_command}" > pr_documentation_tests_temp.txt'
doc_test_job = CircleCIJob( doc_test_job = CircleCIJob(
"pr_documentation_tests", "pr_documentation_tests",
docker_image=[{"image":"huggingface/transformers-consistency"}],
additional_env={"TRANSFORMERS_VERBOSITY": "error", "DATASETS_VERBOSITY": "error", "SKIP_CUDA_DOCTEST": "1"}, additional_env={"TRANSFORMERS_VERBOSITY": "error", "DATASETS_VERBOSITY": "error", "SKIP_CUDA_DOCTEST": "1"},
install_steps=[ install_steps=[
"sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time ffmpeg",
"pip install --upgrade --upgrade-strategy eager pip",
"pip install -U --upgrade-strategy eager -e .[dev]",
# Without --no-deps we can't pin dependency versions in the future
"pip install -U --upgrade-strategy eager --no-deps -e git+https://github.com/huggingface/accelerate@main#egg=accelerate",
"pip install --upgrade --upgrade-strategy eager 'pytest<8.0.0' pytest-sugar",
"pip install -U --upgrade-strategy eager natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels",
"pip install -U --upgrade-strategy eager g2p-en",
# TODO: remove this one after fixing the dependency issue(s) above
"pip install -U --upgrade-strategy eager torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu",
"find -name __pycache__ -delete",
"find . -name \*.pyc -delete",
# Add an empty file to keep the test step running correctly even no file is selected to be tested. # Add an empty file to keep the test step running correctly even no file is selected to be tested.
"touch dummy.py", "touch dummy.py",
{ {
......
import re
import argparse
def parse_pytest_output(file_path):
skipped_tests = {}
skipped_count = 0
with open(file_path, 'r') as file:
for line in file:
match = re.match(r'^SKIPPED \[(\d+)\] (tests/.*): (.*)$', line)
if match:
skipped_count += 1
test_file, test_line, reason = match.groups()
skipped_tests[reason] = skipped_tests.get(reason, []) + [(test_file, test_line)]
for k,v in sorted(skipped_tests.items(), key=lambda x:len(x[1])):
print(f"{len(v):4} skipped because: {k}")
print("Number of skipped tests:", skipped_count)
def parse_pytest_failure_output(file_path):
failed_tests = {}
failed_count = 0
with open(file_path, 'r') as file:
for line in file:
match = re.match(r'^FAILED (tests/.*) - (.*): (.*)$', line)
if match:
failed_count += 1
_, error, reason = match.groups()
failed_tests[reason] = failed_tests.get(reason, []) + [error]
for k,v in sorted(failed_tests.items(), key=lambda x:len(x[1])):
print(f"{len(v):4} failed because `{v[0]}` -> {k}")
print("Number of failed tests:", failed_count)
if failed_count>0:
exit(1)
def parse_pytest_errors_output(file_path):
print(file_path)
error_tests = {}
error_count = 0
with open(file_path, 'r') as file:
for line in file:
match = re.match(r'^ERROR (tests/.*) - (.*): (.*)$', line)
if match:
error_count += 1
_, test_error, reason = match.groups()
error_tests[reason] = error_tests.get(reason, []) + [test_error]
for k,v in sorted(error_tests.items(), key=lambda x:len(x[1])):
print(f"{len(v):4} errored out because of `{v[0]}` -> {k}")
print("Number of errors:", error_count)
if error_count>0:
exit(1)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--file", help="file to parse")
parser.add_argument("--skip", action="store_true", help="show skipped reasons")
parser.add_argument("--fail", action="store_true", help="show failed tests")
parser.add_argument("--errors", action="store_true", help="show failed tests")
args = parser.parse_args()
if args.skip:
parse_pytest_output(args.file)
if args.fail:
parse_pytest_failure_output(args.file)
if args.errors:
parse_pytest_errors_output(args.file)
if __name__ == "__main__":
main()
\ No newline at end of file
name: Build pr ci-docker
on:
push:
branches:
- change-ci # for now let's only build on this branch
repository_dispatch:
workflow_call:
inputs:
image_postfix:
required: true
type: string
schedule:
- cron: "6 0 * * *"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-22.04
if: ${{ contains(github.event.head_commit.message, '[push-ci-image]') && '!cancelled()' }}
strategy:
matrix:
file: ["quality", "consistency", "custom-tokenizers", "torch-light", "tf-light", "exotic-models", "torch-tf-light", "torch-jax-light", "jax-light", "examples-torch", "examples-tf"]
continue-on-error: true
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Check out code
uses: actions/checkout@v4
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Build ${{ matrix.file }}.dockerfile
uses: docker/build-push-action@v5
with:
context: ./docker
build-args: |
REF=${{ github.sha }}
file: "./docker/${{ matrix.file }}.dockerfile"
push: true
tags: huggingface/transformers-${{ matrix.file }}
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y time git pkg-config make git-lfs
ENV VIRTUAL_ENV=/usr/local
RUN pip install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools GitPython
RUN uv pip install --no-cache-dir --upgrade 'torch' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir tensorflow-cpu tf-keras
RUN uv pip install --no-cache-dir "transformers[flax,quality,vision,testing]"
RUN git lfs install
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git cmake wget xz-utils build-essential g++5 libprotobuf-dev protobuf-compiler
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN wget https://github.com/ku-nlp/jumanpp/releases/download/v2.0.0-rc3/jumanpp-2.0.0-rc3.tar.xz
RUN tar xvf jumanpp-2.0.0-rc3.tar.xz
RUN mkdir jumanpp-2.0.0-rc3/bld
WORKDIR ./jumanpp-2.0.0-rc3/bld
RUN wget -LO catch.hpp https://github.com/catchorg/Catch2/releases/download/v2.13.8/catch.hpp
RUN mv catch.hpp ../libs/
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
RUN make install -j 10
RUN uv pip install --no-cache --upgrade 'torch' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir --no-deps accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir "transformers[ja,testing,sentencepiece,jieba,spacy,ftfy,rjieba]" unidic unidic-lite
# spacy is not used so not tested. Causes to failures. TODO fix later
RUN python3 -m unidic download
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt remove -y g++ cmake xz-utils libprotobuf-dev protobuf-compiler
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git
RUN apt-get install -y g++ cmake
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv
RUN uv pip install --no-cache-dir -U pip setuptools albumentations seqeval
RUN pip install --upgrade --no-cache-dir "transformers[tf-cpu,sklearn,testing,sentencepiece,tf-speech,vision]"
RUN uv pip install --no-cache-dir "protobuf==3.20.3"
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "transformers[sklearn,sentencepiece,vision,testing]" seqeval albumentations jiwer
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
ARG REF=main
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git libgl1-mesa-glx libgl1 g++ tesseract-ocr
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir --no-deps timm accelerate
RUN pip install -U --upgrade-strategy eager --no-cache-dir pytesseract python-Levenshtein opencv-python nltk
# RUN uv pip install --no-cache-dir natten==0.15.1+torch210cpu -f https://shi-labs.com/natten/wheels
RUN pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[testing, vision]" 'scikit-learn' 'torch-stft' 'nose' 'dataset'
# RUN git clone https://github.com/facebookresearch/detectron2.git
# RUN python3 -m pip install --no-cache-dir -e detectron2
RUN pip install 'git+https://github.com/facebookresearch/detectron2.git@92ae9f0b92aba5867824b4f12aa06a22a60a45d3'
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git g++ cmake
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir "scipy<1.13" "transformers[flax,testing,sentencepiece,flax-speech,vision]"
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git cmake g++
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir "transformers[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]"
RUN uv pip install --no-cache-dir "protobuf==3.20.3" tensorflow_probability
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git pkg-config openssh-client git
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "transformers[sklearn,sentencepiece,vision,testing]"
RUN pip uninstall -y transformers
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y time git
ENV VIRTUAL_ENV=/usr/local
RUN pip install uv && uv venv
RUN uv pip install --no-cache-dir -U pip setuptools GitPython transformers "ruff==0.1.5" urllib3
RUN apt-get install -y jq curl && apt-get clean && rm -rf /var/lib/apt/lists/*
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ pkg-config openssh-client git
RUN apt-get install -y cmake
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --upgrade --no-cache-dir "transformers[tf-cpu,sklearn,testing,sentencepiece,tf-speech,vision]"
RUN uv pip install --no-cache-dir "protobuf==3.20.3"
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-deps accelerate
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir "scipy<1.13" "transformers[flax, audio, sklearn,sentencepiece,vision,testing]"
# RUN pip install --no-cache-dir "scipy<1.13" "transformers[flax,testing,sentencepiece,flax-speech,vision]"
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git git-lfs
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-deps timm accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN uv pip install --no-cache-dir librosa "transformers[sklearn,sentencepiece,vision,testing]"
RUN pip uninstall -y transformers
\ No newline at end of file
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1
ARG REF=main
RUN echo ${REF}
USER root
RUN apt-get update && apt-get install -y --no-install-recommends libsndfile1-dev espeak-ng time git g++ cmake pkg-config openssh-client git git-lfs
ENV VIRTUAL_ENV=/usr/local
RUN pip --no-cache-dir install uv && uv venv && uv pip install --no-cache-dir -U pip setuptools
RUN uv pip install --no-cache-dir --no-deps accelerate --extra-index-url https://download.pytorch.org/whl/cpu
RUN pip install --no-cache-dir 'torch' 'torchvision' 'torchaudio' --index-url https://download.pytorch.org/whl/cpu
RUN git lfs install
RUN uv pip install --no-cache-dir pypi-kenlm
RUN pip install --no-cache-dir "git+https://github.com/huggingface/transformers.git@${REF}#egg=transformers[tf-cpu,sklearn,sentencepiece,vision,testing]"
RUN uv pip install --no-cache-dir "protobuf==3.20.3" librosa
RUN pip uninstall -y transformers
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
\ No newline at end of file
...@@ -116,7 +116,6 @@ _deps = [ ...@@ -116,7 +116,6 @@ _deps = [
"ftfy", "ftfy",
"fugashi>=1.0", "fugashi>=1.0",
"GitPython<3.1.19", "GitPython<3.1.19",
"hf-doc-builder>=0.3.0",
"huggingface-hub>=0.19.3,<1.0", "huggingface-hub>=0.19.3,<1.0",
"importlib_metadata", "importlib_metadata",
"ipadic>=1.0.0,<2.0", "ipadic>=1.0.0,<2.0",
...@@ -126,7 +125,7 @@ _deps = [ ...@@ -126,7 +125,7 @@ _deps = [
"jieba", "jieba",
"kenlm", "kenlm",
# Keras pin - this is to make sure Keras 3 doesn't destroy us. Remove or change when we have proper support. # Keras pin - this is to make sure Keras 3 doesn't destroy us. Remove or change when we have proper support.
"keras<2.16", "keras>2.9,<2.16",
"keras-nlp>=0.3.1", "keras-nlp>=0.3.1",
"librosa", "librosa",
"nltk", "nltk",
...@@ -169,9 +168,10 @@ _deps = [ ...@@ -169,9 +168,10 @@ _deps = [
"sudachidict_core>=20220729", "sudachidict_core>=20220729",
"tensorboard", "tensorboard",
# TensorFlow pin. When changing this value, update examples/tensorflow/_tests_requirements.txt accordingly # TensorFlow pin. When changing this value, update examples/tensorflow/_tests_requirements.txt accordingly
"tensorflow-cpu>=2.6,<2.16", "tensorflow-cpu>2.9,<2.16",
"tensorflow>=2.6,<2.16", "tensorflow>2.9,<2.16",
"tensorflow-text<2.16", "tensorflow-text<2.16",
"tensorflow-probability<2.16",
"tf2onnx", "tf2onnx",
"timeout-decorator", "timeout-decorator",
"timm", "timm",
...@@ -185,6 +185,7 @@ _deps = [ ...@@ -185,6 +185,7 @@ _deps = [
"unidic_lite>=1.0.7", "unidic_lite>=1.0.7",
"urllib3<2.0.0", "urllib3<2.0.0",
"uvicorn", "uvicorn",
"pytest-rich",
] ]
...@@ -258,7 +259,7 @@ extras["ja"] = deps_list("fugashi", "ipadic", "unidic_lite", "unidic", "sudachip ...@@ -258,7 +259,7 @@ extras["ja"] = deps_list("fugashi", "ipadic", "unidic_lite", "unidic", "sudachip
extras["sklearn"] = deps_list("scikit-learn") extras["sklearn"] = deps_list("scikit-learn")
extras["tf"] = deps_list("tensorflow", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp") extras["tf"] = deps_list("tensorflow", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp")
extras["tf-cpu"] = deps_list("tensorflow-cpu", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp") extras["tf-cpu"] = deps_list("keras", "tensorflow-cpu", "onnxconverter-common", "tf2onnx", "tensorflow-text", "keras-nlp", "tensorflow-probability")
extras["torch"] = deps_list("torch", "accelerate") extras["torch"] = deps_list("torch", "accelerate")
extras["accelerate"] = deps_list("accelerate") extras["accelerate"] = deps_list("accelerate")
...@@ -302,6 +303,7 @@ extras["sentencepiece"] = deps_list("sentencepiece", "protobuf") ...@@ -302,6 +303,7 @@ extras["sentencepiece"] = deps_list("sentencepiece", "protobuf")
extras["testing"] = ( extras["testing"] = (
deps_list( deps_list(
"pytest", "pytest",
"pytest-rich",
"pytest-xdist", "pytest-xdist",
"timeout-decorator", "timeout-decorator",
"parameterized", "parameterized",
...@@ -315,8 +317,6 @@ extras["testing"] = ( ...@@ -315,8 +317,6 @@ extras["testing"] = (
"rouge-score", "rouge-score",
"nltk", "nltk",
"GitPython", "GitPython",
"hf-doc-builder",
"protobuf", # Can be removed once we can unpin protobuf
"sacremoses", "sacremoses",
"rjieba", "rjieba",
"beautifulsoup4", "beautifulsoup4",
...@@ -330,7 +330,7 @@ extras["testing"] = ( ...@@ -330,7 +330,7 @@ extras["testing"] = (
extras["deepspeed-testing"] = extras["deepspeed"] + extras["testing"] + extras["optuna"] + extras["sentencepiece"] extras["deepspeed-testing"] = extras["deepspeed"] + extras["testing"] + extras["optuna"] + extras["sentencepiece"]
extras["quality"] = deps_list("datasets", "isort", "ruff", "GitPython", "hf-doc-builder", "urllib3") extras["quality"] = deps_list("datasets", "isort", "ruff", "GitPython", "urllib3")
extras["all"] = ( extras["all"] = (
extras["tf"] extras["tf"]
...@@ -348,11 +348,6 @@ extras["all"] = ( ...@@ -348,11 +348,6 @@ extras["all"] = (
+ extras["video"] + extras["video"]
) )
# Might need to add doc-builder and some specific deps in the future
extras["docs_specific"] = ["hf-doc-builder"]
# "docs" needs "all" to resolve all the references
extras["docs"] = extras["all"] + extras["docs_specific"]
extras["dev-torch"] = ( extras["dev-torch"] = (
extras["testing"] extras["testing"]
...@@ -367,7 +362,6 @@ extras["dev-torch"] = ( ...@@ -367,7 +362,6 @@ extras["dev-torch"] = (
+ extras["codecarbon"] + extras["codecarbon"]
+ extras["quality"] + extras["quality"]
+ extras["ja"] + extras["ja"]
+ extras["docs_specific"]
+ extras["sklearn"] + extras["sklearn"]
+ extras["modelcreation"] + extras["modelcreation"]
+ extras["onnxruntime"] + extras["onnxruntime"]
...@@ -379,7 +373,6 @@ extras["dev-tensorflow"] = ( ...@@ -379,7 +373,6 @@ extras["dev-tensorflow"] = (
+ extras["tokenizers"] + extras["tokenizers"]
+ extras["vision"] + extras["vision"]
+ extras["quality"] + extras["quality"]
+ extras["docs_specific"]
+ extras["sklearn"] + extras["sklearn"]
+ extras["modelcreation"] + extras["modelcreation"]
+ extras["onnx"] + extras["onnx"]
...@@ -390,7 +383,6 @@ extras["dev"] = ( ...@@ -390,7 +383,6 @@ extras["dev"] = (
+ extras["testing"] + extras["testing"]
+ extras["quality"] + extras["quality"]
+ extras["ja"] + extras["ja"]
+ extras["docs_specific"]
+ extras["sklearn"] + extras["sklearn"]
+ extras["modelcreation"] + extras["modelcreation"]
) )
...@@ -463,3 +455,18 @@ setup( ...@@ -463,3 +455,18 @@ setup(
], ],
cmdclass={"deps_table_update": DepsTableUpdateCommand}, cmdclass={"deps_table_update": DepsTableUpdateCommand},
) )
extras["tests_torch"] = deps_list()
extras["tests_tf"] = deps_list()
extras["tests_flax"] = deps_list()
extras["tests_torch_and_tf"] = deps_list()
extras["tests_torch_and_flax"] = deps_list()
extras["tests_hub"] = deps_list()
extras["tests_pipelines_torch"] = deps_list()
extras["tests_pipelines_tf"] = deps_list()
extras["tests_onnx"] = deps_list()
extras["tests_examples_torch"] = deps_list()
extras["tests_examples_tf"] = deps_list()
extras["tests_custom_tokenizers"] = deps_list()
extras["tests_exotic_models"] = deps_list()
extras["consistency"] = deps_list()
\ No newline at end of file
...@@ -23,7 +23,6 @@ deps = { ...@@ -23,7 +23,6 @@ deps = {
"ftfy": "ftfy", "ftfy": "ftfy",
"fugashi": "fugashi>=1.0", "fugashi": "fugashi>=1.0",
"GitPython": "GitPython<3.1.19", "GitPython": "GitPython<3.1.19",
"hf-doc-builder": "hf-doc-builder>=0.3.0",
"huggingface-hub": "huggingface-hub>=0.19.3,<1.0", "huggingface-hub": "huggingface-hub>=0.19.3,<1.0",
"importlib_metadata": "importlib_metadata", "importlib_metadata": "importlib_metadata",
"ipadic": "ipadic>=1.0.0,<2.0", "ipadic": "ipadic>=1.0.0,<2.0",
...@@ -32,7 +31,7 @@ deps = { ...@@ -32,7 +31,7 @@ deps = {
"jaxlib": "jaxlib>=0.4.1,<=0.4.13", "jaxlib": "jaxlib>=0.4.1,<=0.4.13",
"jieba": "jieba", "jieba": "jieba",
"kenlm": "kenlm", "kenlm": "kenlm",
"keras": "keras<2.16", "keras": "keras>2.9,<2.16",
"keras-nlp": "keras-nlp>=0.3.1", "keras-nlp": "keras-nlp>=0.3.1",
"librosa": "librosa", "librosa": "librosa",
"nltk": "nltk", "nltk": "nltk",
...@@ -74,9 +73,10 @@ deps = { ...@@ -74,9 +73,10 @@ deps = {
"sudachipy": "sudachipy>=0.6.6", "sudachipy": "sudachipy>=0.6.6",
"sudachidict_core": "sudachidict_core>=20220729", "sudachidict_core": "sudachidict_core>=20220729",
"tensorboard": "tensorboard", "tensorboard": "tensorboard",
"tensorflow-cpu": "tensorflow-cpu>=2.6,<2.16", "tensorflow-cpu": "tensorflow-cpu>2.9,<2.16",
"tensorflow": "tensorflow>=2.6,<2.16", "tensorflow": "tensorflow>2.9,<2.16",
"tensorflow-text": "tensorflow-text<2.16", "tensorflow-text": "tensorflow-text<2.16",
"tensorflow-probability": "tensorflow-probability<2.16",
"tf2onnx": "tf2onnx", "tf2onnx": "tf2onnx",
"timeout-decorator": "timeout-decorator", "timeout-decorator": "timeout-decorator",
"timm": "timm", "timm": "timm",
...@@ -90,4 +90,5 @@ deps = { ...@@ -90,4 +90,5 @@ deps = {
"unidic_lite": "unidic_lite>=1.0.7", "unidic_lite": "unidic_lite>=1.0.7",
"urllib3": "urllib3<2.0.0", "urllib3": "urllib3<2.0.0",
"uvicorn": "uvicorn", "uvicorn": "uvicorn",
"pytest-rich": "pytest-rich",
} }
...@@ -63,6 +63,15 @@ if is_tensorflow_probability_available(): ...@@ -63,6 +63,15 @@ if is_tensorflow_probability_available():
"It seems you have `tensorflow_probability` installed with the wrong tensorflow version." "It seems you have `tensorflow_probability` installed with the wrong tensorflow version."
"Please try to reinstall it following the instructions here: https://github.com/tensorflow/probability." "Please try to reinstall it following the instructions here: https://github.com/tensorflow/probability."
) )
else:
try:
import tensorflow_probability as tfp
# On the first call, check whether a compatible version of TensorFlow is installed
# TensorFlow Probability depends on a recent stable release of TensorFlow
_ = tfp.distributions.Normal(loc=0.0, scale=1.0)
except ImportError:
pass
_CHECKPOINT_FOR_DOC = "nvidia/groupvit-gcc-yfcc" _CHECKPOINT_FOR_DOC = "nvidia/groupvit-gcc-yfcc"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment