Skip to content

Commit dfb28be

Browse files
committed
Make python 2 compatible
1 parent f3e4c8b commit dfb28be

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

mx.graalpython/mx_graalpython_bisect.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def run_bisect_benchmark(suite, bad, good, callback, threshold=None):
4444
git_dir = suite.vc_dir
4545
commits = suite.vc.git_command(
4646
git_dir,
47-
['log', '--first-parent', '--format=format:%H', f'{good}^..{bad}'],
47+
['log', '--first-parent', '--format=format:%H', '{}^..{}'.format(good, bad)],
4848
abortOnError=True,
4949
).splitlines()
5050
if not commits:
@@ -62,7 +62,7 @@ def run_bisect_benchmark(suite, bad, good, callback, threshold=None):
6262
if values[good_index] * 1.03 > values[bad_index]:
6363
sys.exit(
6464
"Didn't detect a regression - less that 3% difference between good value "
65-
f"{values[good_index]} and bad value {values[bad_index]}"
65+
"{} and bad value {}".format(values[good_index], values[bad_index])
6666
)
6767
else:
6868
bad_index = -1
@@ -118,10 +118,10 @@ def bad_commit(self):
118118

119119
def visualize(self, level=1):
120120
level_marker = '=' * level
121-
print(f"{level_marker} {self.repo_name}")
121+
print(level_marker, self.repo_name)
122122
for index, (commit, value) in enumerate(zip(self.commits, self.values)):
123123
if value is not None:
124-
print(f"{level_marker} {commit} {value:6.6} {get_message(self.suite, commit)}")
124+
print("{} {} {:6.6} {}".format(level_marker, commit, value, get_message(self.suite, commit)))
125125
if self.subresults and index in self.subresults:
126126
self.subresults[index].visualize(level + 1)
127127

@@ -130,7 +130,8 @@ def summarize(self):
130130
for subresult in self.subresults.values():
131131
if subresult.summarize():
132132
return True
133-
print(f"Detected bad commit in {self.repo_name} repository:\n{self.bad_commit} {get_message(self.suite, self.bad_commit)}")
133+
print("Detected bad commit in {} repository:\n{} {}"
134+
.format(self.repo_name, self.bad_commit, get_message(self.suite, self.bad_commit)))
134135
return True
135136
return False
136137

@@ -160,36 +161,35 @@ def bisect_benchmark(argv):
160161

161162
primary_suite = mx.primary_suite()
162163

163-
fetched_enterprise = False
164+
fetched_enterprise = [False]
164165

165166
def benchmark_callback(suite, commit):
166-
nonlocal fetched_enterprise
167167
suite.vc.update_to_branch(suite.vc_dir, commit)
168168
mx.run_mx(['sforceimports'], suite=suite)
169169
if args.enterprise and suite.name != 'vm-enterprise':
170170
checkout_args = ['--dynamicimports', '/vm-enterprise', 'checkout-downstream', 'vm', 'vm-enterprise']
171-
if fetched_enterprise:
171+
if fetched_enterprise[0]:
172172
checkout_args.append('--no-fetch')
173173
mx.run_mx(checkout_args, out=mx.OutputCapture())
174174
mx.run_mx(['--env', 'ee', 'sforceimports'], suite=get_suite('/vm-enterprise'))
175-
fetched_enterprise = True
175+
fetched_enterprise[0] = True
176176
elif suite.name != 'vm':
177177
mx.run_mx(['--env', 'ce', 'sforceimports'], suite=get_suite('/vm'))
178178
suite.vc.update_to_branch(suite.vc_dir, commit)
179179
mx.run_mx(['sforceimports'], suite=suite)
180180
env = os.environ.copy()
181181
if 'CI' not in os.environ:
182-
env['MX_ALT_OUTPUT_ROOT'] = f'mxbuild-{commit}'
182+
env['MX_ALT_OUTPUT_ROOT'] = 'mxbuild-{}'.format(commit)
183183
retcode = mx.run(shlex.split(args.build_command), env=env, nonZeroIsFatal=False)
184184
if retcode:
185-
sys.exit(f"Failed to execute the build command for {commit}")
185+
sys.exit("Failed to execute the build command for {}".format(commit))
186186
output = mx.OutputCapture()
187187
retcode = mx.run(shlex.split(args.benchmark_command), env=env, out=mx.TeeOutputCapture(output), nonZeroIsFatal=False)
188188
if retcode:
189-
sys.exit(f"Failed to execute benchmark for {commit}")
190-
match = re.search(rf'{re.escape(args.benchmark_criterion)}.*duration: ([\d.]+)', output.data)
189+
sys.exit("Failed to execute benchmark for {}".format(commit))
190+
match = re.search(r'{}.*duration: ([\d.]+)'.format(re.escape(args.benchmark_criterion)), output.data)
191191
if not match:
192-
sys.exit(f"Failed to get result from the benchmark")
192+
sys.exit("Failed to get result from the benchmark")
193193
return float(match.group(1))
194194

195195
bad = get_commit(primary_suite, args.bad)
@@ -202,4 +202,4 @@ def benchmark_callback(suite, commit):
202202
print()
203203

204204
if 'CI' not in os.environ:
205-
print(f"You can rerun a benchmark for a particular commit using:\nMX_ALT_OUTPUT_ROOT=mxbuild-$commit {args.benchmark_command}")
205+
print("You can rerun a benchmark for a particular commit using:\nMX_ALT_OUTPUT_ROOT=mxbuild-$commit {}".format(args.benchmark_command))

0 commit comments

Comments
 (0)