Skip to content

infra: use generated TensorFlow version fixtures #1713

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
Jul 15, 2020
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
46 changes: 16 additions & 30 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,18 @@ def xgboost_version(request):
return request.param


@pytest.fixture(scope="module")
def tf_version(tensorflow_training_version):
# TODO: remove this fixture and update tests
if tensorflow_training_version in ("1.13.1", "2.2", "2.2.0"):
pytest.skip("version isn't compatible with both training and inference.")
return tensorflow_training_version
@pytest.fixture(scope="module", params=["py2", "py3"])
def tensorflow_training_py_version(tensorflow_training_version, request):
return _tf_py_version(tensorflow_training_version, request)


@pytest.fixture(scope="module", params=["py2", "py3"])
def tf_py_version(tensorflow_training_version, request):
version = Version(tensorflow_training_version)
def tensorflow_inference_py_version(tensorflow_inference_version, request):
return _tf_py_version(tensorflow_inference_version, request)


def _tf_py_version(tf_version, request):
version = Version(tf_version)
if version < Version("1.11"):
return "py2"
if version < Version("2.2"):
Expand Down Expand Up @@ -253,28 +254,18 @@ def sklearn_full_py_version():


@pytest.fixture(scope="module")
def tf_training_latest_version():
return "2.2.0"


@pytest.fixture(scope="module")
def tf_training_latest_py_version():
return "py37"


@pytest.fixture(scope="module")
def tf_serving_latest_version():
return "2.1.0"


@pytest.fixture(scope="module")
def tf_full_version(tf_training_latest_version, tf_serving_latest_version):
def tf_full_version(tensorflow_training_latest_version, tensorflow_inference_latest_version):
"""Fixture for TF tests that test both training and inference.

Fixture exists as such, since TF training and TFS have different latest versions.
Otherwise, this would simply be a single latest version.
"""
return str(min(Version(tf_training_latest_version), Version(tf_serving_latest_version)))
return str(
min(
Version(tensorflow_training_latest_version),
Version(tensorflow_inference_latest_version),
)
)


@pytest.fixture(scope="module")
Expand All @@ -292,11 +283,6 @@ def tf_full_py_version(tf_full_version):
return "py37"


@pytest.fixture(scope="module")
def ei_tf_full_version():
return "2.0.0"


@pytest.fixture(scope="module")
def xgboost_full_version():
return "1.0-1"
Expand Down
9 changes: 6 additions & 3 deletions tests/integ/test_airflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ def test_sklearn_airflow_config_uploads_data_source_to_s3(

@pytest.mark.canary_quick
def test_tf_airflow_config_uploads_data_source_to_s3(
sagemaker_session, cpu_instance_type, tf_training_latest_version, tf_training_latest_py_version
sagemaker_session,
cpu_instance_type,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
with timeout(seconds=AIRFLOW_CONFIG_TIMEOUT_IN_SECONDS):
tf = TensorFlow(
Expand All @@ -524,8 +527,8 @@ def test_tf_airflow_config_uploads_data_source_to_s3(
instance_count=SINGLE_INSTANCE_COUNT,
instance_type=cpu_instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
metric_definitions=[
{"Name": "train:global_steps", "Regex": r"global_step\/sec:\s(.*)"}
],
Expand Down
12 changes: 6 additions & 6 deletions tests/integ/test_data_capture_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


def test_enabling_data_capture_on_endpoint_shows_correct_data_capture_status(
sagemaker_session, tf_serving_latest_version
sagemaker_session, tensorflow_inference_latest_version
):
endpoint_name = unique_name_from_base("sagemaker-tensorflow-serving")
model_data = sagemaker_session.upload_data(
Expand All @@ -52,7 +52,7 @@ def test_enabling_data_capture_on_endpoint_shows_correct_data_capture_status(
model = TensorFlowModel(
model_data=model_data,
role=ROLE,
framework_version=tf_serving_latest_version,
framework_version=tensorflow_inference_latest_version,
sagemaker_session=sagemaker_session,
)
predictor = model.deploy(
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_enabling_data_capture_on_endpoint_shows_correct_data_capture_status(


def test_disabling_data_capture_on_endpoint_shows_correct_data_capture_status(
sagemaker_session, tf_serving_latest_version
sagemaker_session, tensorflow_inference_latest_version
):
endpoint_name = unique_name_from_base("sagemaker-tensorflow-serving")
model_data = sagemaker_session.upload_data(
Expand All @@ -109,7 +109,7 @@ def test_disabling_data_capture_on_endpoint_shows_correct_data_capture_status(
model = TensorFlowModel(
model_data=model_data,
role=ROLE,
framework_version=tf_serving_latest_version,
framework_version=tensorflow_inference_latest_version,
sagemaker_session=sagemaker_session,
)
destination_s3_uri = os.path.join(
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_disabling_data_capture_on_endpoint_shows_correct_data_capture_status(


def test_updating_data_capture_on_endpoint_shows_correct_data_capture_status(
sagemaker_session, tf_serving_latest_version
sagemaker_session, tensorflow_inference_latest_version
):
endpoint_name = sagemaker.utils.unique_name_from_base("sagemaker-tensorflow-serving")
model_data = sagemaker_session.upload_data(
Expand All @@ -195,7 +195,7 @@ def test_updating_data_capture_on_endpoint_shows_correct_data_capture_status(
model = TensorFlowModel(
model_data=model_data,
role=ROLE,
framework_version=tf_serving_latest_version,
framework_version=tensorflow_inference_latest_version,
sagemaker_session=sagemaker_session,
)
destination_s3_uri = os.path.join(
Expand Down
25 changes: 14 additions & 11 deletions tests/integ/test_horovod.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
@pytest.mark.canary_quick
def test_hvd_cpu(
sagemaker_session,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
cpu_instance_type,
tmpdir,
):
_create_and_fit_estimator(
sagemaker_session,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
cpu_instance_type,
tmpdir,
)
Expand All @@ -50,12 +50,15 @@ def test_hvd_cpu(
integ.test_region() in integ.TRAINING_NO_P2_REGIONS, reason="no ml.p2 instances in this region"
)
def test_hvd_gpu(
sagemaker_session, tf_training_latest_version, tf_training_latest_py_version, tmpdir
sagemaker_session,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
tmpdir,
):
_create_and_fit_estimator(
sagemaker_session,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
"ml.p2.xlarge",
tmpdir,
)
Expand All @@ -65,8 +68,8 @@ def test_hvd_gpu(
@pytest.mark.parametrize("instances, processes", [[1, 2], (2, 1), (2, 2)])
def test_horovod_local_mode(
sagemaker_local_session,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
instances,
processes,
tmpdir,
Expand All @@ -80,8 +83,8 @@ def test_horovod_local_mode(
instance_type="local",
sagemaker_session=sagemaker_local_session,
output_path=output_path,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
distribution={"mpi": {"enabled": True, "processes_per_host": processes}},
)

Expand Down
4 changes: 2 additions & 2 deletions tests/integ/test_model_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@


@pytest.fixture(scope="module")
def predictor(sagemaker_session, tf_serving_latest_version):
def predictor(sagemaker_session, tensorflow_inference_latest_version):
endpoint_name = unique_name_from_base("sagemaker-tensorflow-serving")
model_data = sagemaker_session.upload_data(
path=os.path.join(tests.integ.DATA_DIR, "tensorflow-serving-test-model.tar.gz"),
Expand All @@ -100,7 +100,7 @@ def predictor(sagemaker_session, tf_serving_latest_version):
model = TensorFlowModel(
model_data=model_data,
role=ROLE,
framework_version=tf_serving_latest_version,
framework_version=tensorflow_inference_latest_version,
sagemaker_session=sagemaker_session,
)
predictor = model.deploy(
Expand Down
18 changes: 12 additions & 6 deletions tests/integ/test_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@


def test_mnist_with_checkpoint_config(
sagemaker_session, instance_type, tf_training_latest_version, tf_training_latest_py_version
sagemaker_session,
instance_type,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
checkpoint_s3_uri = "s3://{}/checkpoints/tf-{}".format(
sagemaker_session.default_bucket(), sagemaker_timestamp()
Expand All @@ -51,8 +54,8 @@ def test_mnist_with_checkpoint_config(
instance_count=1,
instance_type=instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
metric_definitions=[{"Name": "train:global_steps", "Regex": r"global_step\/sec:\s(.*)"}],
checkpoint_s3_uri=checkpoint_s3_uri,
checkpoint_local_path=checkpoint_local_path,
Expand Down Expand Up @@ -124,16 +127,19 @@ def test_server_side_encryption(sagemaker_session, tf_full_version, tf_full_py_v

@pytest.mark.canary_quick
def test_mnist_distributed(
sagemaker_session, instance_type, tf_training_latest_version, tf_training_latest_py_version
sagemaker_session,
instance_type,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
estimator = TensorFlow(
entry_point=SCRIPT,
role=ROLE,
instance_count=2,
instance_type=instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
distribution=PARAMETER_SERVER_DISTRIBUTION,
)
inputs = estimator.sagemaker_session.upload_data(
Expand Down
32 changes: 16 additions & 16 deletions tests/integ/test_tf_efs_fsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_mnist_efs(
efs_fsx_setup,
sagemaker_session,
cpu_instance_type,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
role = efs_fsx_setup["role_name"]
subnets = [efs_fsx_setup["subnet_id"]]
Expand All @@ -71,8 +71,8 @@ def test_mnist_efs(
instance_count=1,
instance_type=cpu_instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
subnets=subnets,
security_group_ids=security_group_ids,
)
Expand Down Expand Up @@ -103,8 +103,8 @@ def test_mnist_lustre(
efs_fsx_setup,
sagemaker_session,
cpu_instance_type,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
role = efs_fsx_setup["role_name"]
subnets = [efs_fsx_setup["subnet_id"]]
Expand All @@ -116,8 +116,8 @@ def test_mnist_lustre(
instance_count=1,
instance_type=cpu_instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
subnets=subnets,
security_group_ids=security_group_ids,
)
Expand All @@ -144,8 +144,8 @@ def test_tuning_tf_efs(
efs_fsx_setup,
sagemaker_session,
cpu_instance_type,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
role = efs_fsx_setup["role_name"]
subnets = [efs_fsx_setup["subnet_id"]]
Expand All @@ -157,8 +157,8 @@ def test_tuning_tf_efs(
instance_count=1,
instance_type=cpu_instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
subnets=subnets,
security_group_ids=security_group_ids,
)
Expand Down Expand Up @@ -197,8 +197,8 @@ def test_tuning_tf_lustre(
efs_fsx_setup,
sagemaker_session,
cpu_instance_type,
tf_training_latest_version,
tf_training_latest_py_version,
tensorflow_training_latest_version,
tensorflow_training_latest_py_version,
):
role = efs_fsx_setup["role_name"]
subnets = [efs_fsx_setup["subnet_id"]]
Expand All @@ -210,8 +210,8 @@ def test_tuning_tf_lustre(
instance_count=1,
instance_type=cpu_instance_type,
sagemaker_session=sagemaker_session,
framework_version=tf_training_latest_version,
py_version=tf_training_latest_py_version,
framework_version=tensorflow_training_latest_version,
py_version=tensorflow_training_latest_py_version,
subnets=subnets,
security_group_ids=security_group_ids,
)
Expand Down
Loading