Skip to content

Set parameter process waiting to False #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sagemaker_tensorflow_container/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def _env_vars_with_tf_config(env, ps_task):

def _run_ps(env):
env_vars = _env_vars_with_tf_config(env, ps_task=True)
framework.entry_point.run(env.module_dir, env.user_entry_point, env.to_cmd_args(), env_vars)
framework.entry_point.run(env.module_dir, env.user_entry_point,
env.to_cmd_args(), env_vars, wait=False)


def _run_worker(env):
Expand Down
38 changes: 25 additions & 13 deletions test/unit/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def test_train_distributed_master(run, distributed_training_env):

run.assert_any_call('s3://my/bucket', 'script_name',
distributed_training_env.to_cmd_args(),
{'TF_CONFIG': ps_tf_config})
{'TF_CONFIG': ps_tf_config},
wait=False)

master_tf_config = '{"cluster": {' \
'"master": ["host1:2222"], ' \
Expand All @@ -107,8 +108,7 @@ def test_train_distributed_master(run, distributed_training_env):

run.assert_called_with('s3://my/bucket', 'script_name',
distributed_training_env.to_cmd_args(),
{
'TF_CONFIG': master_tf_config})
{'TF_CONFIG': master_tf_config})


@patch('subprocess.check_call')
Expand All @@ -131,7 +131,7 @@ def test_train_distributed_worker(run,

run.assert_any_call('s3://my/bucket', 'script_name',
distributed_training_env.to_cmd_args(),
{'TF_CONFIG': ps_tf_config})
{'TF_CONFIG': ps_tf_config}, wait=False)

master_tf_config = '{"cluster": {' \
'"master": ["host1:2222"], ' \
Expand Down Expand Up @@ -176,18 +176,30 @@ def test_run_ps(env_vars_with_tf_config, run, distributed_training_env):

run.assert_called_once_with(distributed_training_env.module_dir,
distributed_training_env.user_entry_point,
distributed_training_env.to_cmd_args(), env_vars_with_tf_config())
distributed_training_env.to_cmd_args(), env_vars_with_tf_config(),
wait=False)


def test_build_tf_config():
assert training._build_tf_config(HOST_LIST, HOST1) == \
{'cluster': CLUSTER_WITH_PS, 'environment': 'cloud', 'task': MASTER_TASK}
assert training._build_tf_config(HOST_LIST, HOST1, ps_task=True) == \
{'cluster': CLUSTER_WITH_PS, 'environment': 'cloud', 'task': PS_TASK_1}
assert training._build_tf_config(HOST_LIST, HOST2) == \
{'cluster': CLUSTER_WITH_PS, 'environment': 'cloud', 'task': WORKER_TASK}
assert training._build_tf_config(HOST_LIST, HOST2, ps_task=True) == \
{'cluster': CLUSTER_WITH_PS, 'environment': 'cloud', 'task': PS_TASK_2}
assert training._build_tf_config(HOST_LIST, HOST1) == {
'cluster': CLUSTER_WITH_PS,
'environment': 'cloud',
'task': MASTER_TASK
}
assert training._build_tf_config(HOST_LIST, HOST1, ps_task=True) == {
'cluster': CLUSTER_WITH_PS,
'environment': 'cloud',
'task': PS_TASK_1
}
assert training._build_tf_config(HOST_LIST, HOST2) == {
'cluster': CLUSTER_WITH_PS,
'environment': 'cloud',
'task': WORKER_TASK
}
assert training._build_tf_config(HOST_LIST, HOST2, ps_task=True) == {
'cluster': CLUSTER_WITH_PS,
'environment': 'cloud',
'task': PS_TASK_2}


def test_build_tf_config_error():
Expand Down