Skip to content

Commit 7cb7b0d

Browse files
authored
Merge branch 'master' into model-no-duplicate-code-upload
2 parents d63a8f1 + 03b9849 commit 7cb7b0d

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ CHANGELOG
66
========
77
* feature: Allow Local Serving of Models in S3
88
* enhancement: Allow option for ``HyperparameterTuner`` to not include estimator metadata in job
9+
* bug-fix: Estimators: Join tensorboard thread after fitting
910
* enhancement: Let Framework models reuse code uploaded by Framework estimators
1011

11-
1212
1.4.2
1313
=====
1414

src/sagemaker/tensorflow/estimator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import subprocess
2020
import tempfile
2121
import threading
22+
import time
2223

2324
from sagemaker.estimator import Framework
2425
from sagemaker.fw_utils import create_image_uri, framework_name_from_image, framework_version_from_tag
@@ -234,7 +235,10 @@ def fit_super():
234235
tensorboard.start()
235236
fit_super()
236237
finally:
238+
# sleep 20 secs for tensorboard start up if fit() quits instantly
239+
time.sleep(20)
237240
tensorboard.event.set()
241+
tensorboard.join()
238242
else:
239243
fit_super()
240244

tests/unit/test_tf_estimator.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,20 @@ def test_run_tensorboard_locally_without_awscli_binary(time, strftime, popen, ca
286286
'following command: \n pip install awscli'
287287

288288

289+
@patch('sagemaker.tensorflow.estimator.Tensorboard._sync_directories')
289290
@patch('tempfile.mkdtemp', return_value='/my/temp/folder')
291+
@patch('shutil.rmtree')
290292
@patch('os.access', return_value=True)
291293
@patch('subprocess.call')
292294
@patch('subprocess.Popen')
293295
@patch('time.strftime', return_value=TIMESTAMP)
294296
@patch('time.time', return_value=TIME)
295-
@pytest.mark.skip(reason="this test fails sometimes and it needs further investigation")
296-
def test_run_tensorboard_locally(time, strftime, popen, call, access, sagemaker_session):
297+
def test_run_tensorboard_locally(time, strftime, popen, call, access, rmtree, mkdtemp, sync, sagemaker_session):
297298
tf = TensorFlow(entry_point=SCRIPT_PATH, role=ROLE, sagemaker_session=sagemaker_session,
298299
train_instance_count=INSTANCE_COUNT, train_instance_type=INSTANCE_TYPE)
299300

301+
popen().poll.return_value = None
302+
300303
tf.fit(inputs='s3://mybucket/train', run_tensorboard_locally=True)
301304

302305
popen.assert_called_with(['tensorboard', '--logdir', '/my/temp/folder', '--host', 'localhost', '--port', '6006'],
@@ -305,19 +308,21 @@ def test_run_tensorboard_locally(time, strftime, popen, call, access, sagemaker_
305308
)
306309

307310

311+
@patch('sagemaker.tensorflow.estimator.Tensorboard._sync_directories')
308312
@patch('tempfile.mkdtemp', return_value='/my/temp/folder')
313+
@patch('shutil.rmtree')
309314
@patch('socket.socket')
310315
@patch('os.access', return_value=True)
311316
@patch('subprocess.call')
312317
@patch('subprocess.Popen')
313318
@patch('time.strftime', return_value=TIMESTAMP)
314319
@patch('time.time', return_value=TIME)
315-
@pytest.mark.skip(reason="this test fails sometimes and it needs further investigation")
316-
def test_run_tensorboard_locally_port_in_use(time, strftime, popen, call, access, socket, sagemaker_session):
320+
def test_run_tensorboard_locally_port_in_use(time, strftime, popen, call, access, socket, rmtree, mkdtemp, sync,
321+
sagemaker_session):
317322
tf = TensorFlow(entry_point=SCRIPT_PATH, role=ROLE, sagemaker_session=sagemaker_session,
318323
train_instance_count=INSTANCE_COUNT, train_instance_type=INSTANCE_TYPE)
319324

320-
popen().poll.side_effect = [True, False]
325+
popen().poll.side_effect = [-1, None]
321326

322327
tf.fit(inputs='s3://mybucket/train', run_tensorboard_locally=True)
323328

0 commit comments

Comments
 (0)