Skip to content

infra: black format unit tests #2305

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 1 commit into from
Apr 27, 2021
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
4 changes: 2 additions & 2 deletions tests/unit/sagemaker/model/test_framework_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, sagemaker_session, **kwargs):
ROLE,
ENTRY_POINT,
sagemaker_session=sagemaker_session,
**kwargs
**kwargs,
)

def create_predictor(self, endpoint_name):
Expand All @@ -71,7 +71,7 @@ def __init__(self, sagemaker_session, entry_point, **kwargs):
ROLE,
entry_point=entry_point,
sagemaker_session=sagemaker_session,
**kwargs
**kwargs,
)

def create_predictor(self, endpoint_name):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/sagemaker/tensorflow/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _build_tf(
py_version=None,
instance_type=None,
base_job_name=None,
**kwargs
**kwargs,
):
return TensorFlow(
entry_point=SCRIPT_PATH,
Expand All @@ -170,7 +170,7 @@ def _build_tf(
instance_count=INSTANCE_COUNT,
instance_type=instance_type if instance_type else INSTANCE_TYPE,
base_job_name=base_job_name,
**kwargs
**kwargs,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sagemaker/tensorflow/test_estimator_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _build_tf(sagemaker_session, **kwargs):
role="dummy-role",
instance_count=1,
instance_type="ml.c4.xlarge",
**kwargs
**kwargs,
)


Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_amazon_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_init_enable_network_isolation(sagemaker_session):
num_components=55,
sagemaker_session=sagemaker_session,
enable_network_isolation=True,
**COMMON_ARGS
**COMMON_ARGS,
)
assert pca.num_components == 55
assert pca.enable_network_isolation() is True
Expand All @@ -99,7 +99,7 @@ def test_init_all_pca_hyperparameters(sagemaker_session):
subtract_mean=True,
extra_components=33,
sagemaker_session=sagemaker_session,
**COMMON_ARGS
**COMMON_ARGS,
)
assert pca.num_components == 55
assert pca.algorithm_mode == "randomized"
Expand All @@ -112,7 +112,7 @@ def test_init_estimator_args(sagemaker_session):
max_run=1234,
sagemaker_session=sagemaker_session,
data_location="s3://some-bucket/some-key/",
**COMMON_ARGS
**COMMON_ARGS,
)
assert pca.instance_type == COMMON_ARGS["instance_type"]
assert pca.instance_count == COMMON_ARGS["instance_count"]
Expand All @@ -133,7 +133,7 @@ def test_data_location_does_not_call_default_bucket(sagemaker_session):
num_components=2,
sagemaker_session=sagemaker_session,
data_location=data_location,
**COMMON_ARGS
**COMMON_ARGS,
)
assert pca.data_location == data_location
assert not sagemaker_session.default_bucket.called
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_fit_ndarray(time, sagemaker_session):
num_components=55,
sagemaker_session=sagemaker_session,
data_location="s3://{}/key-prefix/".format(BUCKET_NAME),
**kwargs
**kwargs,
)
train = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 8.0], [44.0, 55.0, 66.0]]
labels = [99, 85, 87, 2]
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_fit_pass_experiment_config(sagemaker_session):
num_components=55,
sagemaker_session=sagemaker_session,
data_location="s3://{}/key-prefix/".format(BUCKET_NAME),
**kwargs
**kwargs,
)
train = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 8.0], [44.0, 55.0, 66.0]]
labels = [99, 85, 87, 2]
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_chainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _chainer_estimator(
num_processes=None,
process_slots_per_host=None,
additional_mpi_options=None,
**kwargs
**kwargs,
):
return Chainer(
entry_point=SCRIPT_PATH,
Expand All @@ -103,7 +103,7 @@ def _chainer_estimator(
num_processes=num_processes,
process_slots_per_host=process_slots_per_host,
additional_mpi_options=additional_mpi_options,
**kwargs
**kwargs,
)


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def create_model(
vpc_config_override=vpc_utils.VPC_CONFIG_DEFAULT,
enable_network_isolation=None,
model_dir=None,
**kwargs
**kwargs,
):
if enable_network_isolation is None:
enable_network_isolation = self.enable_network_isolation()
Expand All @@ -151,7 +151,7 @@ def create_model(
entry_point=entry_point,
enable_network_isolation=enable_network_isolation,
role=role,
**kwargs
**kwargs,
)

@classmethod
Expand All @@ -171,7 +171,7 @@ def __init__(self, sagemaker_session, entry_point=None, role=ROLE, **kwargs):
role,
entry_point or ENTRY_POINT,
sagemaker_session=sagemaker_session,
**kwargs
**kwargs,
)

def create_predictor(self, endpoint_name):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_fm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_all_hyperparameters(sagemaker_session):
factors_init_scale=1.101,
factors_init_sigma=1.202,
factors_init_value=1.303,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert fm.hyperparameters() == dict(
num_factors=str(ALL_REQ_ARGS["num_factors"]),
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,10 @@ def test_ecr_login_needed(check_output):
token_response = "AWS:%s" % token
b64_token = base64.b64encode(token_response.encode("utf-8"))
response = {
u"authorizationData": [
"authorizationData": [
{
u"authorizationToken": b64_token,
u"proxyEndpoint": u"https://520713654638.dkr.ecr.us-east-1.amazonaws.com",
"authorizationToken": b64_token,
"proxyEndpoint": "https://520713654638.dkr.ecr.us-east-1.amazonaws.com",
}
],
"ResponseMetadata": {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_ipinsights.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_all_hyperparameters(sagemaker_session):
random_negative_sampling_rate=5,
shuffled_negative_sampling_rate=5,
weight_decay=5.0,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert ipinsights.hyperparameters() == dict(
num_entity_vectors=str(ALL_REQ_ARGS["num_entity_vectors"]),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, sagemaker_session, **kwargs):
ROLE,
SCRIPT_NAME,
sagemaker_session=sagemaker_session,
**kwargs
**kwargs,
)

def prepare_container_def(self, instance_type, accelerator_type=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_all_hyperparameters(sagemaker_session):
epochs=10,
center_factor=2,
eval_metrics=["msd", "ssd"],
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert kmeans.hyperparameters() == dict(
k=str(ALL_REQ_ARGS["k"]),
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
ALL_REQ_ARGS = dict(
{"k": K, "sample_size": SAMPLE_SIZE, "predictor_type": PREDICTOR_TYPE_REGRESSOR},
**COMMON_TRAIN_ARGS
**COMMON_TRAIN_ARGS,
)

REGION = "us-west-2"
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_all_hyperparameters_regressor(sagemaker_session):
index_metric="COSINE",
faiss_index_ivf_nlists="auto",
faiss_index_pq_m=1,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert knn.hyperparameters() == dict(
k=str(ALL_REQ_ARGS["k"]),
Expand All @@ -130,7 +130,7 @@ def test_all_hyperparameters_classifier(sagemaker_session):
index_type="faiss.IVFFlat",
index_metric="L2",
faiss_index_ivf_nlists="20",
**test_params
**test_params,
)
assert knn.hyperparameters() == dict(
k=str(ALL_REQ_ARGS["k"]),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_all_hyperparameters(sagemaker_session):
max_restarts=3,
max_iterations=10,
tol=3.3,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert lda.hyperparameters() == dict(
num_topics=str(ALL_REQ_ARGS["num_topics"]),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_linear_learner.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_all_hyperparameters(sagemaker_session):
accuracy_top_k=3,
f_beta=1.0,
balance_multiclass_weights=False,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)

assert lr.hyperparameters() == dict(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_ntm.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_all_hyperparameters(sagemaker_session):
clip_gradient=0.5,
weight_decay=0.5,
learning_rate=0.5,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert ntm.hyperparameters() == dict(
num_topics=str(ALL_REQ_ARGS["num_topics"]),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_object2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
ALL_REQ_ARGS = dict(
{"epochs": EPOCHS, "enc0_max_seq_len": ENC0_MAX_SEQ_LEN, "enc0_vocab_size": ENC0_VOCAB_SIZE},
**COMMON_TRAIN_ARGS
**COMMON_TRAIN_ARGS,
)

REGION = "us-west-2"
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_all_hyperparameters(sagemaker_session):
enc1_layers=3,
enc0_freeze_pretrained_embedding=True,
enc1_freeze_pretrained_embedding=False,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)

hp = object2vec.hyperparameters()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_all_hyperparameters(sagemaker_session):
algorithm_mode="regular",
subtract_mean="True",
extra_components=1,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert pca.hyperparameters() == dict(
num_components=str(ALL_REQ_ARGS["num_components"]),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_pipeline_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, sagemaker_session, **kwargs):
ROLE,
ENTRY_POINT,
sagemaker_session=sagemaker_session,
**kwargs
**kwargs,
)

def create_predictor(self, endpoint_name):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_randomcutforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_all_hyperparameters(sagemaker_session):
num_trees=NUM_TREES,
num_samples_per_tree=NUM_SAMPLES_PER_TREE,
eval_metrics=EVAL_METRICS,
**ALL_REQ_ARGS
**ALL_REQ_ARGS,
)
assert randomcutforest.hyperparameters() == dict(
num_samples_per_tree=str(NUM_SAMPLES_PER_TREE),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _sklearn_estimator(
instance_type=instance_type if instance_type else INSTANCE_TYPE,
base_job_name=base_job_name,
py_version=PYTHON_VERSION,
**kwargs
**kwargs,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def test_deploy_optional_params(_get_best_training_job, best_estimator, tuner):
wait=False,
model_name=model_name,
kms_key=kms_key,
**kwargs
**kwargs,
)

best_estimator.assert_called_with(training_job)
Expand All @@ -905,7 +905,7 @@ def test_deploy_optional_params(_get_best_training_job, best_estimator, tuner):
model_name=model_name,
kms_key=kms_key,
data_capture_config=None,
**kwargs
**kwargs,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _xgboost_estimator(
instance_type=None,
instance_count=1,
base_job_name=None,
**kwargs
**kwargs,
):

return XGBoost(
Expand All @@ -105,7 +105,7 @@ def _xgboost_estimator(
instance_count=instance_count,
base_job_name=base_job_name,
py_version=PYTHON_VERSION,
**kwargs
**kwargs,
)


Expand Down