Skip to content

Commit 5af6eed

Browse files
LowinLianton-l
andauthored
debug an exception (#638)
* debug an exception if dst_path is not a file, it will raise Exception in the function src_path.samefile: FileNotFoundError: [Errno 2] No such file or directory: '/home/lilongwei/notebook/onnx_diffusion/vae_decoder/model.onnx' * Update src/diffusers/onnx_utils.py Co-authored-by: Anton Lozhkov <[email protected]>
1 parent f3983d1 commit 5af6eed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/diffusers/onnx_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def _save_pretrained(self, save_directory: Union[str, Path], file_name: Optional
7979

8080
src_path = self.model_save_dir.joinpath(self.latest_model_name)
8181
dst_path = Path(save_directory).joinpath(model_file_name)
82-
if not src_path.samefile(dst_path):
82+
try:
8383
shutil.copyfile(src_path, dst_path)
84+
except shutil.SameFileError:
85+
pass
8486

8587
def save_pretrained(
8688
self,

0 commit comments

Comments
 (0)