Skip to content

Commit a69c805

Browse files
MoFHekarhdong
authored andcommitted
[fix] get_temp_dir function may return different directory.
And filesystem may be slower than files asserting check.
1 parent 52ef375 commit a69c805

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tensorflow_recommenders_addons/dynamic_embedding/python/kernel_tests/horovod_sync_train_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import numpy as np
2424
import shutil
25+
from time import sleep
2526

2627
import tensorflow as tf
2728

@@ -409,6 +410,7 @@ def call(self, x):
409410
def check_TFRADynamicEmbedding_directory(save_dir,
410411
save_it=None,
411412
should_be_exist=True):
413+
sleep(4) # Wait for filesystem operation
412414
hvd_size = hvd.size()
413415
if hvd_size <= 1:
414416
hvd_size = 1
@@ -441,6 +443,10 @@ def check_TFRADynamicEmbedding_directory(save_dir,
441443
new_de_opt_compared = {}
442444

443445
save_dir = self.get_temp_dir()
446+
# Need to use same directory when horovod save
447+
save_dir = hvd.broadcast_object(save_dir,
448+
root_rank=0,
449+
name=f'{__file__}_broadcast_save_dir')
444450

445451
model = NoCompileModel('ones')
446452
base_opt = Adam(1.0)

0 commit comments

Comments
 (0)