From e33b5fa1f029de321e8e84980588bdeb97ab4a16 Mon Sep 17 00:00:00 2001 From: Joao Gante Date: Thu, 22 Aug 2024 10:49:44 +0000 Subject: [PATCH 1/3] separate step to download nltk files --- .circleci/create_circleci_config.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.circleci/create_circleci_config.py b/.circleci/create_circleci_config.py index d783488caecc..70eb3908544a 100644 --- a/.circleci/create_circleci_config.py +++ b/.circleci/create_circleci_config.py @@ -121,13 +121,18 @@ def to_dict(self): ) steps.append({"run": {"name": "Create `test-results` directory", "command": "mkdir test-results"}}) + + # Examples special case: we need to download NLTK files in advance to avoid cuncurrency issues + if "examples" in self.name: + steps.append({"run": {"name": "Download NLTK files", "command": """python -c "import nltk; nltk.download('punkt', quiet=True)" """}}) + test_command = "" if self.command_timeout: test_command = f"timeout {self.command_timeout} " - # 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: + # 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.tests_to_run is None: test_command += " << pipeline.parameters.tests_to_run >>" else: @@ -185,9 +190,6 @@ def to_dict(self): steps.append({"store_artifacts": {"path": "tests.txt"}}) steps.append({"store_artifacts": {"path": "splitted_tests.txt"}}) - test_command = "" - if self.command_timeout: - test_command = f"timeout {self.command_timeout} " 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)" if self.marker is not None: @@ -327,7 +329,7 @@ def job_name(self): cache_name="tensorflow_examples", docker_image=[{"image":"huggingface/transformers-examples-tf"}], install_steps=["uv venv && uv pip install . && uv pip install -r examples/tensorflow/_tests_requirements.txt"], - parallelism=8 + parallelism=8, ) From 2a9915fc1db5e08e30b63ec989dde6989a55723d Mon Sep 17 00:00:00 2001 From: Joao Gante Date: Thu, 22 Aug 2024 11:46:30 +0000 Subject: [PATCH 2/3] duplicated --- .circleci/create_circleci_config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/create_circleci_config.py b/.circleci/create_circleci_config.py index 70eb3908544a..6dbf7288030e 100644 --- a/.circleci/create_circleci_config.py +++ b/.circleci/create_circleci_config.py @@ -129,10 +129,10 @@ def to_dict(self): test_command = "" if self.command_timeout: test_command = f"timeout {self.command_timeout} " + # 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 --tb=short -o junit_family=xunit1 --junitxml=test-results/junit.xml -n {self.pytest_num_workers} " + " ".join(pytest_flags) if self.parallelism == 1: - # 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.tests_to_run is None: test_command += " << pipeline.parameters.tests_to_run >>" else: @@ -190,7 +190,6 @@ def to_dict(self): steps.append({"store_artifacts": {"path": "tests.txt"}}) steps.append({"store_artifacts": {"path": "splitted_tests.txt"}}) - 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)" if self.marker is not None: test_command += f" -m {self.marker}" From b50c329a7b5fb5a351adb8f264cd30c6284423bd Mon Sep 17 00:00:00 2001 From: Joao Gante Date: Thu, 22 Aug 2024 11:48:19 +0000 Subject: [PATCH 3/3] rm comma --- .circleci/create_circleci_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/create_circleci_config.py b/.circleci/create_circleci_config.py index 6dbf7288030e..a7dd366389dc 100644 --- a/.circleci/create_circleci_config.py +++ b/.circleci/create_circleci_config.py @@ -328,7 +328,7 @@ def job_name(self): cache_name="tensorflow_examples", docker_image=[{"image":"huggingface/transformers-examples-tf"}], install_steps=["uv venv && uv pip install . && uv pip install -r examples/tensorflow/_tests_requirements.txt"], - parallelism=8, + parallelism=8 )