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

Fix tests recurrent #32651

Merged
merged 11 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
8 changes: 8 additions & 0 deletions examples/tensorflow/summarization/run_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@
"Offline mode: run this script without TRANSFORMERS_OFFLINE first to download nltk data files"
)
with FileLock(".lock") as lock:
try:
tokenizers_path = nltk.data.find("tokenizers").path
except (LookupError, OSError):
tokenizers_path = os.path.join(nltk.data.path[0], "tokenizers")
os.makedirs(tokenizers_path, exist_ok=True)
punkt_path = os.path.join(tokenizers_path, "punkt")
if os.path.exists(punkt_path):
os.remove(punkt_path)
molbap marked this conversation as resolved.
Show resolved Hide resolved
nltk.download("punkt", quiet=True)
# endregion

Expand Down
4 changes: 2 additions & 2 deletions tests/test_modeling_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2829,8 +2829,8 @@ def test_inputs_embeds_matches_input_ids_with_generate(self):
model.eval()

model_forward_args = inspect.signature(model.forward).parameters
if "inputs_embeds" not in model_forward_args:
self.skipTest(reason="This model doesn't use `inputs_embeds`")
if any(argument not in model_forward_args for argument in ["inputs_embeds", "position_ids"]):
self.skipTest(reason="This model doesn't use `inputs_embeds` or `position_ids`.")
has_inputs_embeds_forwarding = "inputs_embeds" in set(
inspect.signature(model.prepare_inputs_for_generation).parameters.keys()
)
Expand Down
Loading