File tree Expand file tree Collapse file tree 3 files changed +4
-5
lines changed Expand file tree Collapse file tree 3 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 2
2
import struct
3
3
4
4
import torch
5
- import tempfile
6
5
from typing import List , Dict , Tuple
7
6
from itertools import chain
8
7
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ def test_save_file_and_load_file_consistency():
105
105
tensor_dict = create_gpt2_numpy_dict (1 )
106
106
filename = ""
107
107
loaded_dict = {}
108
- with tempfile .NamedTemporaryFile () as tmp :
108
+ with tempfile .NamedTemporaryFile (delete = False ) as tmp :
109
109
filename = tmp .name
110
110
try :
111
111
save_file (tensor_dict , filename )
@@ -117,7 +117,7 @@ def test_save_file_and_load_file_consistency():
117
117
118
118
def test_safe_open_access_and_metadata ():
119
119
tensor_dict = create_gpt2_numpy_dict (1 )
120
- with tempfile .NamedTemporaryFile () as tmp :
120
+ with tempfile .NamedTemporaryFile (delete = False ) as tmp :
121
121
filename = tmp .name
122
122
# save file into tempfile
123
123
save_file (tensor_dict , filename )
@@ -131,7 +131,7 @@ def test_safe_open_access_and_metadata():
131
131
132
132
def test_safe_open_access_with_metadata ():
133
133
tensor_dict = create_gpt2_numpy_dict (1 )
134
- with tempfile .NamedTemporaryFile () as tmp :
134
+ with tempfile .NamedTemporaryFile (delete = False ) as tmp :
135
135
filename = tmp .name
136
136
137
137
save_file (tensor_dict , filename , metadata = {"hello" : "world" })
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ def test_pt_save_file_and_load_file_consistency():
117
117
118
118
def test_pt_safe_open_access_and_metadata ():
119
119
tensor_dict = create_gpt2_tensors_dict (1 )
120
- with tempfile .NamedTemporaryFile () as tmp :
120
+ with tempfile .NamedTemporaryFile (delete = False ) as tmp :
121
121
filename = tmp .name
122
122
save_file (tensor_dict , filename )
123
123
with safe_open (filename , "pt" ) as model :
You can’t perform that action at this time.
0 commit comments