未验证 提交 95f66c26 编写于 作者: F freeliuzc 提交者: GitHub

Use tempfile to place all the temporary files. Modify some code structure. (#43376)

上级 59f89236
...@@ -17,14 +17,22 @@ from __future__ import print_function ...@@ -17,14 +17,22 @@ from __future__ import print_function
import os import os
import sys import sys
import time import time
import tempfile
import subprocess import subprocess
import unittest import unittest
import numpy as np import numpy as np
import paddle import paddle
class TestDirectory(unittest.TestCase): class TestDirectory(unittest.TestCase):
def setUp(self):
self.temp_dir = tempfile.TemporaryDirectory()
def tearDown(self):
self.temp_dir.cleanup()
def get_import_command(self, module): def get_import_command(self, module):
paths = module.split('.') paths = module.split('.')
if len(paths) == 1: if len(paths) == 1:
...@@ -77,7 +85,7 @@ class TestDirectory(unittest.TestCase): ...@@ -77,7 +85,7 @@ class TestDirectory(unittest.TestCase):
'paddle.static.nn.spectral_norm', 'paddle.static.nn.embedding' 'paddle.static.nn.spectral_norm', 'paddle.static.nn.embedding'
] ]
import_file = 'run_import_modules.py' import_file = os.path.join(self.temp_dir.name, 'run_import_modules.py')
with open(import_file, "w") as wb: with open(import_file, "w") as wb:
for module in new_directory: for module in new_directory:
...@@ -137,7 +145,8 @@ class TestDirectory(unittest.TestCase): ...@@ -137,7 +145,8 @@ class TestDirectory(unittest.TestCase):
'paddle.declarative.spectral_norm', 'paddle.declarative.embedding' 'paddle.declarative.spectral_norm', 'paddle.declarative.embedding'
] ]
import_file = 'run_old_import_modules.py' import_file = os.path.join(self.temp_dir.name,
'run_old_import_modules.py')
with open(import_file, "w") as wb: with open(import_file, "w") as wb:
cmd_context_count = """ cmd_context_count = """
......
...@@ -26,13 +26,6 @@ from paddle.fluid.dygraph.base import to_variable ...@@ -26,13 +26,6 @@ from paddle.fluid.dygraph.base import to_variable
from paddle.fluid.dygraph import Linear from paddle.fluid.dygraph import Linear
from paddle.fluid.framework import _test_eager_guard from paddle.fluid.framework import _test_eager_guard
# Can use Amusic dataset as the DeepCF describes.
DATA_PATH = os.environ.get('DATA_PATH', '')
BATCH_SIZE = int(os.environ.get('BATCH_SIZE', 128))
NUM_BATCHES = int(os.environ.get('NUM_BATCHES', 5))
NUM_EPOCHES = int(os.environ.get('NUM_EPOCHES', 1))
class DMF(fluid.Layer): class DMF(fluid.Layer):
...@@ -129,84 +122,90 @@ class DeepCF(fluid.Layer): ...@@ -129,84 +122,90 @@ class DeepCF(fluid.Layer):
return prediction return prediction
def get_data(): class TestDygraphDeepCF(unittest.TestCase):
user_ids = []
item_ids = []
labels = []
NUM_USERS = 100
NUM_ITEMS = 1000
matrix = np.zeros([NUM_USERS, NUM_ITEMS], dtype=np.float32)
for uid in range(NUM_USERS): def setUp(self):
for iid in range(NUM_ITEMS): # Can use Amusic dataset as the DeepCF describes.
label = float(random.randint(1, 6) == 1) self.data_path = os.environ.get('DATA_PATH', '')
self.batch_size = int(os.environ.get('BATCH_SIZE', 128))
self.num_batches = int(os.environ.get('NUM_BATCHES', 5))
self.num_epoches = int(os.environ.get('NUM_EPOCHES', 1))
def get_data(self):
user_ids = []
item_ids = []
labels = []
NUM_USERS = 100
NUM_ITEMS = 1000
matrix = np.zeros([NUM_USERS, NUM_ITEMS], dtype=np.float32)
for uid in range(NUM_USERS):
for iid in range(NUM_ITEMS):
label = float(random.randint(1, 6) == 1)
user_ids.append(uid)
item_ids.append(iid)
labels.append(label)
matrix[uid, iid] = label
indices = np.arange(len(user_ids))
np.random.shuffle(indices)
users_np = np.array(user_ids, dtype=np.int32)[indices]
items_np = np.array(item_ids, dtype=np.int32)[indices]
labels_np = np.array(labels, dtype=np.float32)[indices]
return np.expand_dims(users_np, -1), \
np.expand_dims(items_np, -1), \
np.expand_dims(labels_np, -1), NUM_USERS, NUM_ITEMS, matrix
def load_data(self):
sys.stderr.write('loading from %s\n' % self.data_path)
likes = dict()
num_users = -1
num_items = -1
with open(self.data_path, 'r') as f:
for l in f.readlines():
uid, iid, rating = [int(v) for v in l.split('\t')]
num_users = max(num_users, uid + 1)
num_items = max(num_items, iid + 1)
if float(rating) > 0.0:
likes[(uid, iid)] = 1.0
user_ids = []
item_ids = []
labels = []
matrix = np.zeros([num_users, num_items], dtype=np.float32)
for uid, iid in likes.keys():
user_ids.append(uid) user_ids.append(uid)
item_ids.append(iid) item_ids.append(iid)
labels.append(label) labels.append(1.0)
matrix[uid, iid] = label matrix[uid, iid] = 1.0
indices = np.arange(len(user_ids))
np.random.shuffle(indices) negative = 0
users_np = np.array(user_ids, dtype=np.int32)[indices] while negative < 3:
items_np = np.array(item_ids, dtype=np.int32)[indices] nuid = random.randint(0, num_users - 1)
labels_np = np.array(labels, dtype=np.float32)[indices] niid = random.randint(0, num_items - 1)
return np.expand_dims(users_np, -1), \ if (nuid, niid) not in likes:
np.expand_dims(items_np, -1), \ negative += 1
np.expand_dims(labels_np, -1), NUM_USERS, NUM_ITEMS, matrix user_ids.append(nuid)
item_ids.append(niid)
labels.append(0.0)
def load_data(DATA_PATH):
sys.stderr.write('loading from %s\n' % DATA_PATH) indices = np.arange(len(user_ids))
likes = dict() np.random.shuffle(indices)
num_users = -1 users_np = np.array(user_ids, dtype=np.int32)[indices]
num_items = -1 items_np = np.array(item_ids, dtype=np.int32)[indices]
with open(DATA_PATH, 'r') as f: labels_np = np.array(labels, dtype=np.float32)[indices]
for l in f.readlines(): return np.expand_dims(users_np, -1), \
uid, iid, rating = [int(v) for v in l.split('\t')] np.expand_dims(items_np, -1), \
num_users = max(num_users, uid + 1) np.expand_dims(labels_np, -1), num_users, num_items, matrix
num_items = max(num_items, iid + 1)
if float(rating) > 0.0:
likes[(uid, iid)] = 1.0
user_ids = []
item_ids = []
labels = []
matrix = np.zeros([num_users, num_items], dtype=np.float32)
for uid, iid in likes.keys():
user_ids.append(uid)
item_ids.append(iid)
labels.append(1.0)
matrix[uid, iid] = 1.0
negative = 0
while negative < 3:
nuid = random.randint(0, num_users - 1)
niid = random.randint(0, num_items - 1)
if (nuid, niid) not in likes:
negative += 1
user_ids.append(nuid)
item_ids.append(niid)
labels.append(0.0)
indices = np.arange(len(user_ids))
np.random.shuffle(indices)
users_np = np.array(user_ids, dtype=np.int32)[indices]
items_np = np.array(item_ids, dtype=np.int32)[indices]
labels_np = np.array(labels, dtype=np.float32)[indices]
return np.expand_dims(users_np, -1), \
np.expand_dims(items_np, -1), \
np.expand_dims(labels_np, -1), num_users, num_items, matrix
class TestDygraphDeepCF(unittest.TestCase):
def test_deefcf(self): def test_deefcf(self):
seed = 90 seed = 90
if DATA_PATH: if self.data_path:
(users_np, items_np, labels_np, num_users, num_items, (users_np, items_np, labels_np, num_users, num_items,
matrix) = load_data(DATA_PATH) matrix) = self.load_data()
else: else:
(users_np, items_np, labels_np, num_users, num_items, (users_np, items_np, labels_np, num_users, num_items,
matrix) = get_data() matrix) = self.get_data()
paddle.seed(seed) paddle.seed(seed)
paddle.framework.random._manual_program_seed(seed) paddle.framework.random._manual_program_seed(seed)
startup = fluid.Program() startup = fluid.Program()
...@@ -228,17 +227,19 @@ class TestDygraphDeepCF(unittest.TestCase): ...@@ -228,17 +227,19 @@ class TestDygraphDeepCF(unittest.TestCase):
exe = fluid.Executor(fluid.CPUPlace( exe = fluid.Executor(fluid.CPUPlace(
) if not core.is_compiled_with_cuda() else fluid.CUDAPlace(0)) ) if not core.is_compiled_with_cuda() else fluid.CUDAPlace(0))
exe.run(startup) exe.run(startup)
for e in range(NUM_EPOCHES): for e in range(self.num_epoches):
sys.stderr.write('epoch %d\n' % e) sys.stderr.write('epoch %d\n' % e)
for slice in range(0, BATCH_SIZE * NUM_BATCHES, BATCH_SIZE): for slice in range(0, self.batch_size * self.num_batches,
if slice + BATCH_SIZE >= users_np.shape[0]: self.batch_size):
if slice + self.batch_size >= users_np.shape[0]:
break break
static_loss = exe.run( static_loss = exe.run(
main, main,
feed={ feed={
users.name: users_np[slice:slice + BATCH_SIZE], users.name: users_np[slice:slice + self.batch_size],
items.name: items_np[slice:slice + BATCH_SIZE], items.name: items_np[slice:slice + self.batch_size],
labels.name: labels_np[slice:slice + BATCH_SIZE] labels.name:
labels_np[slice:slice + self.batch_size]
}, },
fetch_list=[loss])[0] fetch_list=[loss])[0]
sys.stderr.write('static loss %s\n' % static_loss) sys.stderr.write('static loss %s\n' % static_loss)
...@@ -250,18 +251,20 @@ class TestDygraphDeepCF(unittest.TestCase): ...@@ -250,18 +251,20 @@ class TestDygraphDeepCF(unittest.TestCase):
deepcf = DeepCF(num_users, num_items, matrix) deepcf = DeepCF(num_users, num_items, matrix)
adam = fluid.optimizer.AdamOptimizer( adam = fluid.optimizer.AdamOptimizer(
0.01, parameter_list=deepcf.parameters()) 0.01, parameter_list=deepcf.parameters())
for e in range(NUM_EPOCHES): for e in range(self.num_epoches):
sys.stderr.write('epoch %d\n' % e) sys.stderr.write('epoch %d\n' % e)
for slice in range(0, BATCH_SIZE * NUM_BATCHES, BATCH_SIZE): for slice in range(0, self.batch_size * self.num_batches,
if slice + BATCH_SIZE >= users_np.shape[0]: self.batch_size):
if slice + self.batch_size >= users_np.shape[0]:
break break
prediction = deepcf( prediction = deepcf(
to_variable(users_np[slice:slice + BATCH_SIZE]), to_variable(users_np[slice:slice + self.batch_size]),
to_variable(items_np[slice:slice + BATCH_SIZE])) to_variable(items_np[slice:slice + self.batch_size]))
loss = fluid.layers.reduce_sum( loss = fluid.layers.reduce_sum(
fluid.layers.log_loss( fluid.layers.log_loss(
prediction, prediction,
to_variable(labels_np[slice:slice + BATCH_SIZE]))) to_variable(labels_np[slice:slice +
self.batch_size])))
loss.backward() loss.backward()
adam.minimize(loss) adam.minimize(loss)
deepcf.clear_gradients() deepcf.clear_gradients()
...@@ -276,18 +279,20 @@ class TestDygraphDeepCF(unittest.TestCase): ...@@ -276,18 +279,20 @@ class TestDygraphDeepCF(unittest.TestCase):
adam2 = fluid.optimizer.AdamOptimizer( adam2 = fluid.optimizer.AdamOptimizer(
0.01, parameter_list=deepcf2.parameters()) 0.01, parameter_list=deepcf2.parameters())
fluid.set_flags({'FLAGS_sort_sum_gradient': True}) fluid.set_flags({'FLAGS_sort_sum_gradient': True})
for e in range(NUM_EPOCHES): for e in range(self.num_epoches):
sys.stderr.write('epoch %d\n' % e) sys.stderr.write('epoch %d\n' % e)
for slice in range(0, BATCH_SIZE * NUM_BATCHES, BATCH_SIZE): for slice in range(0, self.batch_size * self.num_batches,
if slice + BATCH_SIZE >= users_np.shape[0]: self.batch_size):
if slice + self.batch_size >= users_np.shape[0]:
break break
prediction2 = deepcf2( prediction2 = deepcf2(
to_variable(users_np[slice:slice + BATCH_SIZE]), to_variable(users_np[slice:slice + self.batch_size]),
to_variable(items_np[slice:slice + BATCH_SIZE])) to_variable(items_np[slice:slice + self.batch_size]))
loss2 = fluid.layers.reduce_sum( loss2 = fluid.layers.reduce_sum(
fluid.layers.log_loss( fluid.layers.log_loss(
prediction2, prediction2,
to_variable(labels_np[slice:slice + BATCH_SIZE]))) to_variable(labels_np[slice:slice +
self.batch_size])))
loss2.backward() loss2.backward()
adam2.minimize(loss2) adam2.minimize(loss2)
deepcf2.clear_gradients() deepcf2.clear_gradients()
...@@ -306,19 +311,22 @@ class TestDygraphDeepCF(unittest.TestCase): ...@@ -306,19 +311,22 @@ class TestDygraphDeepCF(unittest.TestCase):
adam = fluid.optimizer.AdamOptimizer( adam = fluid.optimizer.AdamOptimizer(
0.01, parameter_list=deepcf.parameters()) 0.01, parameter_list=deepcf.parameters())
for e in range(NUM_EPOCHES): for e in range(self.num_epoches):
sys.stderr.write('epoch %d\n' % e) sys.stderr.write('epoch %d\n' % e)
for slice in range(0, BATCH_SIZE * NUM_BATCHES, BATCH_SIZE): for slice in range(0, self.batch_size * self.num_batches,
if slice + BATCH_SIZE >= users_np.shape[0]: self.batch_size):
if slice + self.batch_size >= users_np.shape[0]:
break break
prediction = deepcf( prediction = deepcf(
to_variable(users_np[slice:slice + BATCH_SIZE]), to_variable(users_np[slice:slice +
to_variable(items_np[slice:slice + BATCH_SIZE])) self.batch_size]),
to_variable(items_np[slice:slice +
self.batch_size]))
loss = fluid.layers.reduce_sum( loss = fluid.layers.reduce_sum(
fluid.layers.log_loss( fluid.layers.log_loss(
prediction, prediction,
to_variable(labels_np[slice:slice + to_variable(labels_np[slice:slice +
BATCH_SIZE]))) self.batch_size])))
loss.backward() loss.backward()
adam.minimize(loss) adam.minimize(loss)
deepcf.clear_gradients() deepcf.clear_gradients()
......
...@@ -177,4 +177,5 @@ class TestDygraphGNN(unittest.TestCase): ...@@ -177,4 +177,5 @@ class TestDygraphGNN(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
paddle.enable_static()
unittest.main() unittest.main()
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import os
import unittest import unittest
import tempfile
import numpy as np import numpy as np
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.static import InputSpec from paddle.static import InputSpec
...@@ -160,6 +163,10 @@ class TestNetWithNonTensorSpec(unittest.TestCase): ...@@ -160,6 +163,10 @@ class TestNetWithNonTensorSpec(unittest.TestCase):
self.out_num = 16 self.out_num = 16
self.x_spec = paddle.static.InputSpec([-1, 16], name='x') self.x_spec = paddle.static.InputSpec([-1, 16], name='x')
self.x = paddle.randn([4, 16]) self.x = paddle.randn([4, 16])
self.temp_dir = tempfile.TemporaryDirectory()
def tearDown(self):
self.temp_dir.cleanup()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
...@@ -182,7 +189,7 @@ class TestNetWithNonTensorSpec(unittest.TestCase): ...@@ -182,7 +189,7 @@ class TestNetWithNonTensorSpec(unittest.TestCase):
self.check_result(specs, 'list') self.check_result(specs, 'list')
def check_result(self, specs, path): def check_result(self, specs, path):
path = './net_non_tensor_' + path path = os.path.join(self.temp_dir.name, './net_non_tensor_', path)
net = NetWithNonTensorSpec(self.in_num, self.out_num) net = NetWithNonTensorSpec(self.in_num, self.out_num)
net.eval() net.eval()
...@@ -218,7 +225,7 @@ class TestNetWithNonTensorSpec(unittest.TestCase): ...@@ -218,7 +225,7 @@ class TestNetWithNonTensorSpec(unittest.TestCase):
net = paddle.jit.to_static(net, input_spec=specs) net = paddle.jit.to_static(net, input_spec=specs)
net.eval() net.eval()
path = './net_twice' path = os.path.join(self.temp_dir.name, './net_twice')
# NOTE: check input_specs_compatible # NOTE: check input_specs_compatible
new_specs = [self.x_spec, True, "bn", 10] new_specs = [self.x_spec, True, "bn", 10]
...@@ -264,6 +271,7 @@ class TestNetWithNonTensorSpecWithPrune(unittest.TestCase): ...@@ -264,6 +271,7 @@ class TestNetWithNonTensorSpecWithPrune(unittest.TestCase):
self.y_spec = paddle.static.InputSpec([16], name='y') self.y_spec = paddle.static.InputSpec([16], name='y')
self.x = paddle.randn([4, 16]) self.x = paddle.randn([4, 16])
self.y = paddle.randn([16]) self.y = paddle.randn([16])
self.temp_dir = tempfile.TemporaryDirectory()
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
...@@ -271,7 +279,7 @@ class TestNetWithNonTensorSpecWithPrune(unittest.TestCase): ...@@ -271,7 +279,7 @@ class TestNetWithNonTensorSpecWithPrune(unittest.TestCase):
def test_non_tensor_with_prune(self): def test_non_tensor_with_prune(self):
specs = [self.x_spec, self.y_spec, True] specs = [self.x_spec, self.y_spec, True]
path = './net_non_tensor_prune_' path = os.path.join(self.temp_dir.name, './net_non_tensor_prune_')
net = NetWithNonTensorSpecPrune(self.in_num, self.out_num) net = NetWithNonTensorSpecPrune(self.in_num, self.out_num)
net.eval() net.eval()
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import paddle import os
import json
import tempfile
import unittest import unittest
import warnings
import numpy import numpy
import paddle
import paddle.nn.functional as F import paddle.nn.functional as F
import tempfile
import warnings
import json
import os
from paddle.fluid.framework import _enable_legacy_dygraph from paddle.fluid.framework import _enable_legacy_dygraph
_enable_legacy_dygraph() _enable_legacy_dygraph()
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
from __future__ import print_function from __future__ import print_function
import os
import tempfile
import unittest import unittest
import paddle.fluid as fluid import paddle.fluid as fluid
...@@ -29,8 +31,6 @@ import paddle ...@@ -29,8 +31,6 @@ import paddle
from paddle.io import Dataset from paddle.io import Dataset
import numpy import numpy
paddle.enable_static()
class TestOptimizer(unittest.TestCase): class TestOptimizer(unittest.TestCase):
...@@ -1279,6 +1279,12 @@ class TestMasterWeightSaveForFP16(unittest.TestCase): ...@@ -1279,6 +1279,12 @@ class TestMasterWeightSaveForFP16(unittest.TestCase):
Master weights will be saved by optimizer::state_dict. Master weights will be saved by optimizer::state_dict.
''' '''
def setUp(self):
self.temp_dir = tempfile.TemporaryDirectory()
def tearDown(self):
self.temp_dir.cleanup()
def check_with_opt_state_dict(self, use_save_load=True): def check_with_opt_state_dict(self, use_save_load=True):
paddle.seed(100) paddle.seed(100)
numpy.random.seed(100) numpy.random.seed(100)
...@@ -1340,10 +1346,12 @@ class TestMasterWeightSaveForFP16(unittest.TestCase): ...@@ -1340,10 +1346,12 @@ class TestMasterWeightSaveForFP16(unittest.TestCase):
optimizer.clear_grad(set_to_zero=False) optimizer.clear_grad(set_to_zero=False)
if use_save_load and i == 5: if use_save_load and i == 5:
paddle.save(model.state_dict(), "model.pdparams") model_path = os.path.join(self.temp_dir.name, "model.pdparams")
paddle.save(optimizer.state_dict(), "opt.pdopt") optimizer_path = os.path.join(self.temp_dir.name, "opt.pdopt")
model.set_state_dict(paddle.load("model.pdparams")) paddle.save(model.state_dict(), model_path)
optimizer.set_state_dict(paddle.load("opt.pdopt")) paddle.save(optimizer.state_dict(), optimizer_path)
model.set_state_dict(paddle.load(model_path))
optimizer.set_state_dict(paddle.load(optimizer_path))
return loss.numpy() return loss.numpy()
...@@ -1359,4 +1367,5 @@ class TestMasterWeightSaveForFP16(unittest.TestCase): ...@@ -1359,4 +1367,5 @@ class TestMasterWeightSaveForFP16(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
paddle.enable_static()
unittest.main() unittest.main()
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import os
import numpy as np import numpy as np
import tempfile
import unittest
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import unittest
import paddle.nn as nn import paddle.nn as nn
import os
class SimpleFCLayer(nn.Layer): class SimpleFCLayer(nn.Layer):
...@@ -54,6 +56,10 @@ class TestTracedLayerErrMsg(unittest.TestCase): ...@@ -54,6 +56,10 @@ class TestTracedLayerErrMsg(unittest.TestCase):
self.fc_size = 2 self.fc_size = 2
self.layer = self._train_simple_net() self.layer = self._train_simple_net()
self.type_str = 'class' self.type_str = 'class'
self.temp_dir = tempfile.TemporaryDirectory()
def tearDown(self):
self.temp_dir.cleanup()
def test_trace_err(self): def test_trace_err(self):
if fluid.framework.in_dygraph_mode(): if fluid.framework.in_dygraph_mode():
...@@ -122,7 +128,7 @@ class TestTracedLayerErrMsg(unittest.TestCase): ...@@ -122,7 +128,7 @@ class TestTracedLayerErrMsg(unittest.TestCase):
dygraph_out, traced_layer = fluid.dygraph.TracedLayer.trace( dygraph_out, traced_layer = fluid.dygraph.TracedLayer.trace(
self.layer, [in_x]) self.layer, [in_x])
path = './traced_layer_err_msg' path = os.path.join(self.temp_dir.name, './traced_layer_err_msg')
with self.assertRaises(TypeError) as e: with self.assertRaises(TypeError) as e:
traced_layer.save_inference_model([0]) traced_layer.save_inference_model([0])
self.assertEqual( self.assertEqual(
...@@ -193,11 +199,15 @@ class TestTracedLayerSaveInferenceModel(unittest.TestCase): ...@@ -193,11 +199,15 @@ class TestTracedLayerSaveInferenceModel(unittest.TestCase):
"""test save_inference_model will automaticlly create non-exist dir""" """test save_inference_model will automaticlly create non-exist dir"""
def setUp(self): def setUp(self):
self.save_path = "./nonexist_dir/fc" self.temp_dir = tempfile.TemporaryDirectory()
self.save_path = os.path.join(self.temp_dir.name, "./nonexist_dir/fc")
import shutil import shutil
if os.path.exists(os.path.dirname(self.save_path)): if os.path.exists(os.path.dirname(self.save_path)):
shutil.rmtree(os.path.dirname(self.save_path)) shutil.rmtree(os.path.dirname(self.save_path))
def tearDown(self):
self.temp_dir.cleanup()
def test_mkdir_when_input_path_non_exist(self): def test_mkdir_when_input_path_non_exist(self):
if fluid.framework.in_dygraph_mode(): if fluid.framework.in_dygraph_mode():
return return
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册