From 6f3cbd396592859685aa211135cf1c8459dc4bb3 Mon Sep 17 00:00:00 2001 From: kalyanr Date: Sat, 6 Jan 2024 13:32:38 +0530 Subject: [PATCH] fix lint Signed-off-by: kalyanr --- tests/ml_commons/test_ml_commons_client.py | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/ml_commons/test_ml_commons_client.py b/tests/ml_commons/test_ml_commons_client.py index 296336f7..2122d2d4 100644 --- a/tests/ml_commons/test_ml_commons_client.py +++ b/tests/ml_commons/test_ml_commons_client.py @@ -165,14 +165,15 @@ def test_train(iris_index): def test_execute(): - raised = False try: input_json = {"operation": "max", "input_data": [1.0, 2.0, 3.0]} result = ml_client.execute( algorithm_name="local_sample_calculator", input_json=input_json ) except Exception as ex: - pytest.fail(f"Raised Exception during execute API testing with dictionary. Exception info: {ex}") + pytest.fail( + f"Raised Exception during execute API testing with dictionary. Exception info: {ex}" + ) else: assert result["output"]["result"] == 3 @@ -182,12 +183,14 @@ def test_execute(): algorithm_name="local_sample_calculator", input_json=input_json ) except Exception as ex: - pytest.fail(f"Raised Exception during execute API testing with JSON string. Exception info: {ex}") + pytest.fail( + f"Raised Exception during execute API testing with JSON string. Exception info: {ex}" + ) else: assert result["output"]["result"] == 3 + def test_DEPRECATED_integration_pretrained_model_upload_unload_delete(): - raised = False try: model_id = ml_client.upload_pretrained_model( model_name=PRETRAINED_MODEL_NAME, @@ -198,33 +201,39 @@ def test_DEPRECATED_integration_pretrained_model_upload_unload_delete(): ) ml_model_status = ml_client.get_model_info(model_id) except Exception as ex: - pytest.fail(f"Raised Exception during pretrained model registration and deployment. Exception info:{ex}") + pytest.fail( + f"Raised Exception during pretrained model registration and deployment. Exception info:{ex}" + ) else: assert ml_model_status.get("model_state") != "DEPLOY_FAILED" - if model_id: - raised = False try: ml_model_status = ml_client.get_model_info(model_id) except Exception as ex: - pytest.fail("Raised Exception in getting pretrained model info. Exception info: {ex}") + pytest.fail( + f"Raised Exception in getting pretrained model info. Exception info: {ex}" + ) else: assert ml_model_status.get("model_format") == "TORCH_SCRIPT" assert ml_model_status.get("algorithm") == "TEXT_EMBEDDING" - + try: ml_client.unload_model(model_id) ml_model_status = ml_client.get_model_info(model_id) - except: # noqa: E722 - pytest.fail("Raised Exception in pretrained model undeployment. Exception info: {ex}") + except Exception as ex: + pytest.fail( + f"Raised Exception in pretrained model undeployment. Exception info: {ex}" + ) else: assert ml_model_status.get("model_state") != "UNDEPLOY_FAILED" - + try: delete_model_obj = ml_client.delete_model(model_id) except Exception as ex: - pytest.fail("Raised Exception in deleting pretrained model. Exception info: {ex}") + pytest.fail( + f"Raised Exception in deleting pretrained model. Exception info: {ex}" + ) else: assert delete_model_obj.get("result") == "deleted"