Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: fetch generation tests #34807

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion .github/conda/build.sh

This file was deleted.

56 changes: 0 additions & 56 deletions .github/conda/meta.yaml

This file was deleted.

1 change: 1 addition & 0 deletions test_preparation/tests_hub_test_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests
2 changes: 1 addition & 1 deletion tests/generation/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3138,7 +3138,7 @@ def test_logits_processor_not_inplace(self):
out = model.generate(input_ids, output_logits=True, output_scores=True, return_dict_in_generate=True)
out_with_temp = model.generate(
input_ids,
temperature=0.5,
Copy link
Member Author

Choose a reason for hiding this comment

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

(this change is to trigger the tests in this file)

temperature=0.6,
do_sample=True,
output_logits=True,
output_scores=True,
Expand Down
51 changes: 27 additions & 24 deletions utils/tests_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,39 +1132,42 @@ def parse_commit_message(commit_message: str) -> Dict[str, bool]:


JOB_TO_TEST_FILE = {
"tests_torch_and_tf": r"tests/models/.*/test_modeling_(?:tf_|(?!flax)).*",
"tests_torch_and_flax": r"tests/models/.*/test_modeling_(?:flax|(?!tf)).*",
"tests_tf": r"tests/models/.*/test_modeling_tf_.*",
"tests_torch": r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*",
"tests_generate": r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*",
"tests_tokenization": r"tests/models/.*/test_tokenization.*",
"tests_processors": r"tests/models/.*/test_(?!(?:modeling_|tokenization_)).*", # takes feature extractors, image processors, processors
"examples_torch": r"examples/pytorch/.*test_.*",
"examples_tensorflow": r"examples/tensorflow/.*test_.*",
"tests_exotic_models": r"tests/models/.*(?=layoutlmv|nat|deta|udop|nougat).*",
"tests_custom_tokenizers": r"tests/models/.*/test_tokenization_(?=bert_japanese|openai|clip).*",
# "repo_utils": r"tests/[^models].*test.*", TODO later on we might want to do
"pipelines_tf": r"tests/models/.*/test_modeling_tf_.*",
"pipelines_torch": r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*",
"tests_hub": r"tests/.*",
"tests_onnx": r"tests/models/.*/test_modeling_(?:tf_|(?!flax)).*",
"tests_non_model": r"tests/[^/]*?/test_.*\.py",
"tests_torch_and_tf": [r"tests/models/.*/test_modeling_(?:tf_|(?!flax)).*"],
"tests_torch_and_flax": [r"tests/models/.*/test_modeling_(?:flax|(?!tf)).*"],
"tests_tf": [r"tests/models/.*/test_modeling_tf_.*"],
"tests_torch": [r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*"],
"tests_generate": [r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*", r"tests/generation/.*"],
"tests_tokenization": [r"tests/models/.*/test_tokenization.*"],
# takes feature extractors, image processors, processors
"tests_processors": [r"tests/models/.*/test_(?!(?:modeling_|tokenization_)).*"],
"examples_torch": [r"examples/pytorch/.*test_.*"],
"examples_tensorflow": [r"examples/tensorflow/.*test_.*"],
"tests_exotic_models": [r"tests/models/.*(?=layoutlmv|nat|deta|udop|nougat).*"],
"tests_custom_tokenizers": [r"tests/models/.*/test_tokenization_(?=bert_japanese|openai|clip).*"],
# "repo_utils": [r"tests/[^models].*test.*"], TODO later on we might want to do
"pipelines_tf": [r"tests/models/.*/test_modeling_tf_.*"],
"pipelines_torch": [r"tests/models/.*/test_modeling_(?!(?:flax_|tf_)).*"],
"tests_hub": [r"tests/.*"],
"tests_onnx": [r"tests/models/.*/test_modeling_(?:tf_|(?!flax)).*"],
"tests_non_model": [r"tests/[^/]*?/test_.*\.py"],
}


def create_test_list_from_filter(full_test_list, out_path):
os.makedirs(out_path, exist_ok=True)
all_test_files = "\n".join(full_test_list)
for job_name, _filter in JOB_TO_TEST_FILE.items():
file_name = os.path.join(out_path, f"{job_name}_test_list.txt")
if job_name == "tests_hub":
files_to_test = ["tests"]
else:
files_to_test = list(re.findall(_filter, all_test_files))
for job_name, _filters in JOB_TO_TEST_FILE.items():
files_to_test = set() # Using sets to avoid duplicates when multiple filters match the same file
for _filter in _filters:
file_name = os.path.join(out_path, f"{job_name}_test_list.txt")
if job_name == "tests_hub":
files_to_test.add("tests")
else:
files_to_test = files_to_test.union(set(re.findall(_filter, all_test_files)))
print(job_name, file_name)
if len(files_to_test) > 0: # No tests -> no file with test list
with open(file_name, "w") as f:
f.write("\n".join(files_to_test))
f.write("\n".join(sorted(files_to_test)))


if __name__ == "__main__":
Expand Down
Loading