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

CI Fix Windows permission error on merge test #1952

Merged
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
11 changes: 10 additions & 1 deletion tests/testing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import pickle
import re
import shutil
import tempfile
from collections import OrderedDict
from dataclasses import replace
Expand Down Expand Up @@ -621,9 +622,17 @@ def _test_merge_layers(self, model_id, config_cls, config_kwargs):
# test that the logits are identical after a save-load-roundtrip
if hasattr(model, "save_pretrained"):
# model is a transformers model
with tempfile.TemporaryDirectory() as tmp_dirname:
tmp_dirname = tempfile.mkdtemp()
# note: not using the context manager here because it fails on Windows CI for some reason
try:
model.save_pretrained(tmp_dirname)
model_from_pretrained = self.transformers_class.from_pretrained(tmp_dirname).to(self.torch_device)
finally:
try:
shutil.rmtree(tmp_dirname)
except PermissionError:
# windows error
pass
else:
# model is not a transformers model
model_from_pretrained = pickle.loads(pickle.dumps(model))
Expand Down
Loading