Back to Black

This commit is contained in:
Matěj Cepl 2020-10-06 08:46:05 +02:00
commit 5697ff87a8
112 changed files with 1803 additions and 977 deletions

View file

@ -88,11 +88,15 @@ def test_delete_endpoint_config():
resp = sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
with pytest.raises(ClientError) as e:
sagemaker.describe_endpoint_config(EndpointConfigName=endpoint_config_name)
assert e.value.response["Error"]["Message"].startswith("Could not find endpoint configuration")
assert e.value.response["Error"]["Message"].startswith(
"Could not find endpoint configuration"
)
with pytest.raises(ClientError) as e:
sagemaker.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
assert e.value.response["Error"]["Message"].startswith( "Could not find endpoint configuration")
assert e.value.response["Error"]["Message"].startswith(
"Could not find endpoint configuration"
)
@mock_sagemaker
@ -134,7 +138,9 @@ def test_create_endpoint():
sagemaker.create_endpoint(
EndpointName=endpoint_name, EndpointConfigName="NonexistentEndpointConfig"
)
assert e.value.response["Error"]["Message"].startswith("Could not find endpoint configuration")
assert e.value.response["Error"]["Message"].startswith(
"Could not find endpoint configuration"
)
model_name = "MyModel"
_create_model(sagemaker, model_name)

View file

@ -49,8 +49,9 @@ def test_create_notebook_instance_minimal_params():
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
assert resp["NotebookInstanceName"] == NAME_PARAM
assert resp["NotebookInstanceStatus"] == "InService"
assert resp["Url"] == \
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
assert resp["Url"] == "{}.notebook.{}.sagemaker.aws".format(
NAME_PARAM, TEST_REGION_NAME
)
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
assert resp["RoleArn"] == FAKE_ROLE_ARN
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
@ -99,8 +100,9 @@ def test_create_notebook_instance_params():
assert resp["NotebookInstanceArn"].endswith(args["NotebookInstanceName"])
assert resp["NotebookInstanceName"] == NAME_PARAM
assert resp["NotebookInstanceStatus"] == "InService"
assert resp["Url"] == \
"{}.notebook.{}.sagemaker.aws".format(NAME_PARAM, TEST_REGION_NAME)
assert resp["Url"] == "{}.notebook.{}.sagemaker.aws".format(
NAME_PARAM, TEST_REGION_NAME
)
assert resp["InstanceType"] == INSTANCE_TYPE_PARAM
assert resp["RoleArn"] == FAKE_ROLE_ARN
assert isinstance(resp["LastModifiedTime"], datetime.datetime)
@ -111,8 +113,7 @@ def test_create_notebook_instance_params():
assert resp["SubnetId"] == FAKE_SUBNET_ID
assert resp["SecurityGroups"] == FAKE_SECURITY_GROUP_IDS
assert resp["KmsKeyId"] == FAKE_KMS_KEY_ID
assert resp["NotebookInstanceLifecycleConfigName"] == \
FAKE_LIFECYCLE_CONFIG_NAME
assert resp["NotebookInstanceLifecycleConfigName"] == FAKE_LIFECYCLE_CONFIG_NAME
assert resp["AcceleratorTypes"] == ACCELERATOR_TYPES_PARAM
assert resp["DefaultCodeRepository"] == FAKE_DEFAULT_CODE_REPO
assert resp["AdditionalCodeRepositories"] == FAKE_ADDL_CODE_REPOS
@ -135,9 +136,11 @@ def test_create_notebook_instance_bad_volume_size():
}
with pytest.raises(ParamValidationError) as ex:
sagemaker.create_notebook_instance(**args)
assert \
ex.value.args[0] == \
"Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(vol_size)
assert ex.value.args[
0
] == "Parameter validation failed:\nInvalid range for parameter VolumeSizeInGB, value: {}, valid range: 5-inf".format(
vol_size
)
@mock_sagemaker
@ -238,17 +241,15 @@ def test_notebook_instance_lifecycle_config():
OnCreate=on_create,
OnStart=on_start,
)
assert \
e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config already exists.)"
)
assert e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config already exists.)"
)
resp = sagemaker.describe_notebook_instance_lifecycle_config(
NotebookInstanceLifecycleConfigName=name,
)
assert resp["NotebookInstanceLifecycleConfigName"] == name
assert \
resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
assert resp["NotebookInstanceLifecycleConfigArn"].startswith("arn:aws:sagemaker")
assert resp["NotebookInstanceLifecycleConfigArn"].endswith(name)
assert resp["OnStart"] == on_start
assert resp["OnCreate"] == on_create
@ -263,16 +264,14 @@ def test_notebook_instance_lifecycle_config():
sagemaker.describe_notebook_instance_lifecycle_config(
NotebookInstanceLifecycleConfigName=name,
)
assert \
e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config does not exist.)"
)
assert e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config does not exist.)"
)
with pytest.raises(ClientError) as e:
sagemaker.delete_notebook_instance_lifecycle_config(
NotebookInstanceLifecycleConfigName=name,
)
assert \
e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config does not exist.)"
)
assert e.value.response["Error"]["Message"].endswith(
"Notebook Instance Lifecycle Config does not exist.)"
)

View file

@ -82,20 +82,21 @@ def test_create_training_job():
r"^arn:aws:sagemaker:.*:.*:training-job/{}$".format(training_job_name)
)
assert resp["ModelArtifacts"]["S3ModelArtifacts"].startswith(
params["OutputDataConfig"]["S3OutputPath"]
)
params["OutputDataConfig"]["S3OutputPath"]
)
assert training_job_name in (resp["ModelArtifacts"]["S3ModelArtifacts"])
assert \
resp["ModelArtifacts"]["S3ModelArtifacts"].endswith("output/model.tar.gz")
assert resp["ModelArtifacts"]["S3ModelArtifacts"].endswith("output/model.tar.gz")
assert resp["TrainingJobStatus"] == "Completed"
assert resp["SecondaryStatus"] == "Completed"
assert resp["HyperParameters"] == params["HyperParameters"]
assert \
resp["AlgorithmSpecification"]["TrainingImage"] == \
params["AlgorithmSpecification"]["TrainingImage"]
assert \
resp["AlgorithmSpecification"]["TrainingInputMode"] == \
params["AlgorithmSpecification"]["TrainingInputMode"]
assert (
resp["AlgorithmSpecification"]["TrainingImage"]
== params["AlgorithmSpecification"]["TrainingImage"]
)
assert (
resp["AlgorithmSpecification"]["TrainingInputMode"]
== params["AlgorithmSpecification"]["TrainingInputMode"]
)
assert "MetricDefinitions" in resp["AlgorithmSpecification"]
assert "Name" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]
assert "Regex" in resp["AlgorithmSpecification"]["MetricDefinitions"][0]