Skip to content

Commit ff5031a

Browse files
fix(sdk): fix lint error with black.
Signed-off-by: Electronic-Waste <[email protected]>
1 parent 239a55f commit ff5031a

File tree

4 files changed

+41
-76
lines changed

4 files changed

+41
-76
lines changed

sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_observation_log_response(*args, **kwargs):
5050
metric_logs=[
5151
katib_api_pb2.MetricLog(
5252
time_stamp="2024-07-29T15:09:08Z",
53-
metric=katib_api_pb2.Metric(name="result",value="0.99")
53+
metric=katib_api_pb2.Metric(name="result", value="0.99"),
5454
)
5555
]
5656
)
@@ -245,36 +245,28 @@ def create_experiment(
245245
test_get_trial_metrics_data = [
246246
(
247247
"valid trial name",
248-
{
249-
"name": "example",
250-
"namespace": "valid",
251-
"timeout": constants.DEFAULT_TIMEOUT
252-
},
248+
{"name": "example", "namespace": "valid", "timeout": constants.DEFAULT_TIMEOUT},
253249
[
254250
katib_api_pb2.MetricLog(
255251
time_stamp="2024-07-29T15:09:08Z",
256-
metric=katib_api_pb2.Metric(name="result",value="0.99")
252+
metric=katib_api_pb2.Metric(name="result", value="0.99"),
257253
)
258-
]
254+
],
259255
),
260256
(
261257
"invalid trial name",
262258
{
263259
"name": "invalid",
264260
"namespace": "invalid",
265-
"timeout": constants.DEFAULT_TIMEOUT
261+
"timeout": constants.DEFAULT_TIMEOUT,
266262
},
267-
RuntimeError
263+
RuntimeError,
268264
),
269265
(
270266
"GetObservationLog timeout error",
271-
{
272-
"name": "example",
273-
"namespace": "valid",
274-
"timeout": 0
275-
},
276-
RuntimeError
277-
)
267+
{"name": "example", "namespace": "valid", "timeout": 0},
268+
RuntimeError,
269+
),
278270
]
279271

280272

@@ -287,16 +279,11 @@ def katib_client():
287279
side_effect=create_namespaced_custom_object_response
288280
)
289281
),
290-
), patch(
291-
"kubernetes.config.load_kube_config",
292-
return_value=Mock()
293-
), patch(
294-
"kubeflow.katib.katib_api_pb2_grpc.DBManagerStub",
282+
), patch("kubernetes.config.load_kube_config", return_value=Mock()), patch(
283+
"kubeflow.katib.katib_api_pb2_grpc.DBManagerStub",
295284
return_value=Mock(
296-
GetObservationLog=Mock(
297-
side_effect=get_observation_log_response
298-
)
299-
)
285+
GetObservationLog=Mock(side_effect=get_observation_log_response)
286+
),
300287
):
301288
client = KatibClient()
302289
yield client
@@ -318,7 +305,9 @@ def test_create_experiment(katib_client, test_name, kwargs, expected_output):
318305
print("test execution complete")
319306

320307

321-
@pytest.mark.parametrize("test_name,kwargs,expected_output", test_get_trial_metrics_data)
308+
@pytest.mark.parametrize(
309+
"test_name,kwargs,expected_output", test_get_trial_metrics_data
310+
)
322311
def test_get_trial_metrics(katib_client, test_name, kwargs, expected_output):
323312
"""
324313
test get_trial_metrics function of katib client

sdk/python/v1beta1/kubeflow/katib/api/report_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def report_metrics(
6868
metric_logs=[
6969
katib_api_pb2.MetricLog(
7070
time_stamp=timestamp,
71-
metric=katib_api_pb2.Metric(name=name,value=str(value))
71+
metric=katib_api_pb2.Metric(name=name, value=str(value)),
7272
)
7373
for name, value in metrics.items()
7474
]
75-
)
75+
),
7676
),
7777
timeout=timeout,
7878
)

sdk/python/v1beta1/kubeflow/katib/api/report_metrics_test.py

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,71 +17,40 @@ def report_observation_log_response(*args, **kwargs):
1717
test_report_metrics_data = [
1818
(
1919
"valid metrics with float type",
20-
{
21-
"metrics": {
22-
"result": 0.99
23-
},
24-
"timeout": constants.DEFAULT_TIMEOUT
25-
26-
},
20+
{"metrics": {"result": 0.99}, "timeout": constants.DEFAULT_TIMEOUT},
2721
TEST_RESULT_SUCCESS,
28-
ENV_VARIABLE_NOT_EMPTY
22+
ENV_VARIABLE_NOT_EMPTY,
2923
),
3024
(
3125
"valid metrics with string type",
32-
{
33-
"metrics": {
34-
"result": "0.99"
35-
},
36-
"timeout": constants.DEFAULT_TIMEOUT
37-
},
26+
{"metrics": {"result": "0.99"}, "timeout": constants.DEFAULT_TIMEOUT},
3827
TEST_RESULT_SUCCESS,
39-
ENV_VARIABLE_NOT_EMPTY
28+
ENV_VARIABLE_NOT_EMPTY,
4029
),
4130
(
4231
"valid metrics with int type",
43-
{
44-
"metrics": {
45-
"result": 1
46-
},
47-
"timeout": constants.DEFAULT_TIMEOUT
48-
},
32+
{"metrics": {"result": 1}, "timeout": constants.DEFAULT_TIMEOUT},
4933
TEST_RESULT_SUCCESS,
50-
ENV_VARIABLE_NOT_EMPTY
34+
ENV_VARIABLE_NOT_EMPTY,
5135
),
5236
(
5337
"ReportObservationLog timeout error",
54-
{
55-
"metrics": {
56-
"result": 0.99
57-
},
58-
"timeout": 0
59-
},
38+
{"metrics": {"result": 0.99}, "timeout": 0},
6039
RuntimeError,
61-
ENV_VARIABLE_NOT_EMPTY
40+
ENV_VARIABLE_NOT_EMPTY,
6241
),
6342
(
6443
"invalid metrics with type string",
65-
{
66-
"metrics": {
67-
"result": "abc"
68-
},
69-
"timeout": constants.DEFAULT_TIMEOUT
70-
},
44+
{"metrics": {"result": "abc"}, "timeout": constants.DEFAULT_TIMEOUT},
7145
ValueError,
72-
ENV_VARIABLE_NOT_EMPTY
46+
ENV_VARIABLE_NOT_EMPTY,
7347
),
7448
(
7549
"Trial name is not passed to env variables",
76-
{
77-
"metrics": {
78-
"result": 0.99
79-
},
80-
"timeout": constants.DEFAULT_TIMEOUT
81-
},
50+
{"metrics": {"result": 0.99}, "timeout": constants.DEFAULT_TIMEOUT},
8251
ValueError,
83-
ENV_VARIABLE_EMPTY
84-
)
52+
ENV_VARIABLE_EMPTY,
53+
),
8554
]
8655

8756

@@ -113,9 +82,16 @@ def mock_report_observation_log():
11382
@pytest.mark.parametrize(
11483
"test_name,kwargs,expected_output,mock_getenv",
11584
test_report_metrics_data,
116-
indirect=["mock_getenv"]
85+
indirect=["mock_getenv"],
11786
)
118-
def test_report_metrics(test_name, kwargs, expected_output, mock_getenv, mock_get_current_k8s_namespace, mock_report_observation_log):
87+
def test_report_metrics(
88+
test_name,
89+
kwargs,
90+
expected_output,
91+
mock_getenv,
92+
mock_get_current_k8s_namespace,
93+
mock_report_observation_log,
94+
):
11995
"""
12096
test report_metrics function
12197
"""

sdk/python/v1beta1/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"kubeflow/katib/katib_api_pb2_grpc.py",
4747
)
4848

49-
with open("kubeflow/katib/katib_api_pb2_grpc.py", 'r+') as file:
49+
with open("kubeflow/katib/katib_api_pb2_grpc.py", "r+") as file:
5050
content = file.read()
5151
new_content = content.replace("api_pb2", "kubeflow.katib.katib_api_pb2")
5252
file.seek(0)

0 commit comments

Comments
 (0)