Skip to content

Commit 49c12f7

Browse files
Apply Black formatting to test/core files
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 561487d commit 49c12f7

19 files changed

Lines changed: 169 additions & 116 deletions

test/core/metaflow_test/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def origin_run_id_for_resume():
121121
return current.origin_run_id
122122

123123

124-
125124
class FlowDefinition(object):
126125
"""Base class for core integration test flow definitions.
127126

test/core/metaflow_test/cli_check.py

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ def artifact(self, step, name):
5252

5353
def assert_artifact(self, step, name, value, fields=None):
5454
for task, artifacts in self.artifact_dict(step, name).items():
55-
assert name in artifacts, (
56-
"Task '%s' expected %s=%s but the key was not found"
57-
% (task, name, truncate(value))
55+
assert (
56+
name in artifacts
57+
), "Task '%s' expected %s=%s but the key was not found" % (
58+
task,
59+
name,
60+
truncate(value),
5861
)
5962
artifact = artifacts[name]
6063
if fields:
@@ -65,18 +68,31 @@ def assert_artifact(self, step, name, value, fields=None):
6568
data = json.loads(artifact.descriptor)
6669
else:
6770
data = artifact
68-
assert isinstance(data, dict), (
69-
"Task '%s' expected %s to be a dictionary (got %s)"
70-
% (task, name, type(data))
71+
assert isinstance(
72+
data, dict
73+
), "Task '%s' expected %s to be a dictionary (got %s)" % (
74+
task,
75+
name,
76+
type(data),
7177
)
72-
assert data.get(field) == v, (
73-
"Task '%s' expected %s[%s]=%r but got %s[%s]=%s"
74-
% (task, name, field, truncate(v), name, field, truncate(data.get(field)))
78+
assert (
79+
data.get(field) == v
80+
), "Task '%s' expected %s[%s]=%r but got %s[%s]=%s" % (
81+
task,
82+
name,
83+
field,
84+
truncate(v),
85+
name,
86+
field,
87+
truncate(data.get(field)),
7588
)
7689
else:
77-
assert artifact == value, (
78-
"Task '%s' expected %s=%r but got %s=%s"
79-
% (task, name, truncate(value), name, truncate(artifact))
90+
assert artifact == value, "Task '%s' expected %s=%r but got %s=%s" % (
91+
task,
92+
name,
93+
truncate(value),
94+
name,
95+
truncate(artifact),
8096
)
8197

8298
def artifact_dict(self, step, name):
@@ -103,14 +119,22 @@ def artifact_dict_if_exists(self, step, name):
103119
def assert_log(self, step, logtype, value, exact_match=True):
104120
log = self.get_log(step, logtype)
105121
if exact_match:
106-
assert log == value, (
107-
"Task '%s/%s' expected %s log %r but got %r"
108-
% (self.run_id, step, logtype, value, log)
122+
assert log == value, "Task '%s/%s' expected %s log %r but got %r" % (
123+
self.run_id,
124+
step,
125+
logtype,
126+
value,
127+
log,
109128
)
110129
else:
111-
assert value in log, (
112-
"Task '%s/%s' expected %s log to contain %r but got %r"
113-
% (self.run_id, step, logtype, value, log)
130+
assert (
131+
value in log
132+
), "Task '%s/%s' expected %s log to contain %r but got %r" % (
133+
self.run_id,
134+
step,
135+
logtype,
136+
value,
137+
log,
114138
)
115139

116140
def assert_card(
@@ -136,14 +160,21 @@ def assert_card(
136160
else:
137161
raise e
138162
if exact_match:
139-
assert card_data == value, (
140-
"Task '%s/%s' expected %s card content %r but got %r"
141-
% (self.run_id, step, card_type, value, card_data)
163+
assert (
164+
card_data == value
165+
), "Task '%s/%s' expected %s card content %r but got %r" % (
166+
self.run_id,
167+
step,
168+
card_type,
169+
value,
170+
card_data,
142171
)
143172
else:
144-
assert value in card_data, (
145-
"Task '%s/%s' expected %s card to contain %r"
146-
% (self.run_id, step, card_type, value)
173+
assert value in card_data, "Task '%s/%s' expected %s card to contain %r" % (
174+
self.run_id,
175+
step,
176+
card_type,
177+
value,
147178
)
148179

149180
def list_cards(self, step, task, card_type=None):

test/core/metaflow_test/metadata_check.py

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ def artifact(self, step, name):
6666

6767
def assert_artifact(self, step, name, value, fields=None):
6868
for task, artifacts in self.artifact_dict(step, name).items():
69-
assert name in artifacts, (
70-
"Task '%s' expected %s=%s but the key was not found"
71-
% (task, name, truncate(value))
69+
assert (
70+
name in artifacts
71+
), "Task '%s' expected %s=%s but the key was not found" % (
72+
task,
73+
name,
74+
truncate(value),
7275
)
7376
artifact = artifacts[name]
7477
if fields:
@@ -77,18 +80,31 @@ def assert_artifact(self, step, name, value, fields=None):
7780
data = json.loads(artifact)
7881
else:
7982
data = artifact
80-
assert isinstance(data, dict), (
81-
"Task '%s' expected %s to be a dictionary (got %s)"
82-
% (task, name, type(data))
83+
assert isinstance(
84+
data, dict
85+
), "Task '%s' expected %s to be a dictionary (got %s)" % (
86+
task,
87+
name,
88+
type(data),
8389
)
84-
assert data.get(field) == v, (
85-
"Task '%s' expected %s[%s]=%r but got %s[%s]=%s"
86-
% (task, name, field, truncate(v), name, field, truncate(data.get(field)))
90+
assert (
91+
data.get(field) == v
92+
), "Task '%s' expected %s[%s]=%r but got %s[%s]=%s" % (
93+
task,
94+
name,
95+
field,
96+
truncate(v),
97+
name,
98+
field,
99+
truncate(data.get(field)),
87100
)
88101
else:
89-
assert artifact == value, (
90-
"Task '%s' expected %s=%r but got %s=%s"
91-
% (task, name, truncate(value), name, truncate(artifact))
102+
assert artifact == value, "Task '%s' expected %s=%r but got %s=%s" % (
103+
task,
104+
name,
105+
truncate(value),
106+
name,
107+
truncate(artifact),
92108
)
93109

94110
def artifact_dict(self, step, name):
@@ -102,14 +118,20 @@ def artifact_dict_if_exists(self, step, name):
102118
def assert_log(self, step, logtype, value, exact_match=True):
103119
log_value = self.get_log(step, logtype)
104120
if exact_match:
105-
assert log_value == value, (
106-
"Step '%s' expected task.%s=%r but got %r"
107-
% (step, logtype, value, log_value)
121+
assert log_value == value, "Step '%s' expected task.%s=%r but got %r" % (
122+
step,
123+
logtype,
124+
value,
125+
log_value,
108126
)
109127
else:
110-
assert value in log_value, (
111-
"Step '%s' expected task.%s to contain %r but got %r"
112-
% (step, logtype, value, log_value)
128+
assert (
129+
value in log_value
130+
), "Step '%s' expected task.%s to contain %r but got %r" % (
131+
step,
132+
logtype,
133+
value,
134+
log_value,
113135
)
114136

115137
def list_cards(self, step, task, card_type=None):
@@ -163,14 +185,21 @@ def assert_card(
163185
card_filter = [c for c in card_iter if card_hash in c.hash]
164186
card_data = None if len(card_filter) == 0 else card_filter[0].get()
165187
if exact_match:
166-
assert card_data == value, (
167-
"Task '%s/%s' expected %s card content %r but got %r"
168-
% (self.run_id, step, card_type, value, card_data)
188+
assert (
189+
card_data == value
190+
), "Task '%s/%s' expected %s card content %r but got %r" % (
191+
self.run_id,
192+
step,
193+
card_type,
194+
value,
195+
card_data,
169196
)
170197
else:
171-
assert value in card_data, (
172-
"Task '%s/%s' expected %s card to contain %r"
173-
% (self.run_id, step, card_type, value)
198+
assert value in card_data, "Task '%s/%s' expected %s card to contain %r" % (
199+
self.run_id,
200+
step,
201+
card_type,
202+
value,
174203
)
175204

176205
def get_card_data(self, step, task, card_type, card_id=None):

test/core/test_core_pytest.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,7 @@ def construct_arg_dicts_from_click_api():
291291

292292
trigger_cmd = [context["python"], "-B", "test_flow.py"]
293293
trigger_cmd.extend(context["top_options"])
294-
trigger_cmd.extend(
295-
[scheduler, "trigger", "--run-id-file", "run-id"]
296-
)
294+
trigger_cmd.extend([scheduler, "trigger", "--run-id-file", "run-id"])
297295
called_processes.append(
298296
subprocess.run(
299297
trigger_cmd,
@@ -409,9 +407,7 @@ def construct_arg_dicts_from_click_api():
409407
)
410408
return called_processes[-1].returncode, path
411409
else:
412-
_log(
413-
"flow failed", formatter, context, processes=called_processes
414-
)
410+
_log("flow failed", formatter, context, processes=called_processes)
415411
return called_processes[-1].returncode, path
416412
elif formatter.should_fail:
417413
return 1, path

test/core/tests/basic_foreach.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ def join(self, inputs):
100100
0,
101101
7,
102102
]
103-
) == (
104-
got
105-
)
103+
) == (got)
106104

107105
@steps(1, ["all"])
108106
def step_all(self):

test/core/tests/basic_tags.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,23 @@ def check_results(self, flow, checker):
6262
# should return nothing
6363
assert [] == list(flow_obj.runs("not_a_tag", tag))
6464
# all steps should be returned with tag filtering
65-
assert frozenset(step.name for step in flow) == frozenset(step.id.split("/")[-1] for step in run.steps(tag))
65+
assert frozenset(step.name for step in flow) == frozenset(
66+
step.id.split("/")[-1] for step in run.steps(tag)
67+
)
6668
# a conjunction of two existent tags should return the original list
67-
assert frozenset(step.name for step in flow) == frozenset(step.id.split("/")[-1] for step in run.steps(*tags))
69+
assert frozenset(step.name for step in flow) == frozenset(
70+
step.id.split("/")[-1] for step in run.steps(*tags)
71+
)
6872
# all tasks should be returned with tag filtering
6973
for step in run:
7074
# the run object should have the tags
7175
assert [True] * len(tags) == [t in step.tags for t in tags]
7276
# filtering by a non-existent tag should return nothing
7377
assert [] == list(step.tasks("not_a_tag"))
7478
# filtering by the tag should not exclude any tasks
75-
assert [task.id for task in step] == [task.id for task in step.tasks(tag)]
79+
assert [task.id for task in step] == [
80+
task.id for task in step.tasks(tag)
81+
]
7682
for task in step.tasks(tag):
7783
# the task object should have the tags
7884
assert [True] * len(tags) == [t in task.tags for t in tags]

test/core/tests/card_component_refresh_test.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ def create_random_string_array(size=10):
112112
_array_is_a_subset(
113113
card_data["data"]["component_1"]["abc"], component_1_arr
114114
)
115-
) == (
116-
True
117-
)
115+
) == (True)
118116
time.sleep(sleep_between_refreshes)
119117

120118
assert card_data is not None == True

test/core/tests/card_default_editable.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ def check_results(self, flow, checker):
9494
cards_info is not None
9595
and "cards" in cards_info
9696
and len(cards_info["cards"]) == 1
97-
) == (
98-
True
99-
)
97+
) == (True)
10098
card = cards_info["cards"][0]
10199
checker.assert_card(
102100
step.name,
@@ -118,9 +116,7 @@ def check_results(self, flow, checker):
118116
cards_info is not None
119117
and "cards" in cards_info
120118
and len(cards_info["cards"]) == 1
121-
) == (
122-
True
123-
)
119+
) == (True)
124120
for card in cards_info["cards"]:
125121
checker.assert_card(
126122
step.name,

test/core/tests/card_default_editable_customize.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ def check_results(self, flow, checker):
5353
cards_info is not None
5454
and "cards" in cards_info
5555
and len(cards_info["cards"]) == 2
56-
) == (
57-
True
58-
)
56+
) == (True)
5957
# Find the card without the id
6058
default_editable_cards = [
6159
c for c in cards_info["cards"] if c["id"] is None
@@ -85,9 +83,7 @@ def check_results(self, flow, checker):
8583
cards_info is not None
8684
and "cards" in cards_info
8785
and len(cards_info["cards"]) == 2
88-
) == (
89-
True
90-
)
86+
) == (True)
9187
default_editable_cards = [
9288
c for c in cards_info["cards"] if c["id"] is None
9389
]

test/core/tests/card_default_editable_with_id.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def check_results(self, flow, checker):
6565
cards_info is not None
6666
and "cards" in cards_info
6767
and len(cards_info["cards"]) == 2
68-
) == (
69-
True
70-
)
68+
) == (True)
7169
# Find the card without the id
7270
default_editable_cards = [
7371
c for c in cards_info["cards"] if c["id"] is None
@@ -99,9 +97,7 @@ def check_results(self, flow, checker):
9997
cards_info is not None
10098
and "cards" in cards_info
10199
and len(cards_info["cards"]) == 2
102-
) == (
103-
True
104-
)
100+
) == (True)
105101
default_editable_cards = [
106102
c for c in cards_info["cards"] if c["id"] is None
107103
]

0 commit comments

Comments
 (0)