Skip to content

Commit 629c0cf

Browse files
Thomas Polasekfacebook-github-bot
authored andcommitted
Convert directory fbcode/aibench to use the Ruff Formatter
Summary: Converts the directory specified to use the Ruff formatter in pyfmt ruff_dog If this diff causes merge conflicts when rebasing, please run `hg status -n -0 --change . -I '**/*.{py,pyi}' | xargs -0 arc pyfmt` on your diff, and amend any changes before rebasing onto latest. That should help reduce or eliminate any merge conflicts. allow-large-files Reviewed By: amyreese Differential Revision: D66250245 fbshipit-source-id: 91d6f48b32e47a33841aaefe1e2b43b7705c1267
1 parent 6f00632 commit 629c0cf

File tree

18 files changed

+66
-80
lines changed

18 files changed

+66
-80
lines changed

ailab/benchmark/db_controller.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ def get_payload(req):
138138
"status": (
139139
"OCCUPIED"
140140
if d[2] == "0"
141-
else "AVAILABLE" if d[2] == "1" else "OFFLINE"
141+
else "AVAILABLE"
142+
if d[2] == "1"
143+
else "OFFLINE"
142144
),
143145
"claimer": claimer,
144146
"job_queue": job_queue,

ailab/file_storage/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
@csrf_exempt
1111
def upload(request):
12-
1312
# Handle file upload
1413
if request.method == "POST" and "file" in request.FILES:
1514
file = request.FILES["file"]

benchmarking/benchmarks/benchmarks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
class BenchmarkCollector:
3232
def __init__(self, framework, model_cache, **kwargs):
33-
3433
self.args = kwargs.get("args", None)
3534
if not os.path.isdir(model_cache):
3635
os.makedirs(model_cache)
@@ -104,7 +103,6 @@ def _collectOneBenchmark(self, source, meta, benchmarks, info, user_identifier):
104103
# Update all files in the benchmark to absolute path
105104
# download the files if needed
106105
def _updateFiles(self, one_benchmark, filename, user_identifier):
107-
108106
model = one_benchmark["model"]
109107
model_dir = os.path.join(self.model_cache, model["format"], model["name"])
110108
if not os.path.isdir(model_dir):

benchmarking/data_converters/json_converter/json_converter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def convert(self, data):
7979
new_string = d["info_string"]
8080
if old_string != new_string:
8181
getLogger().warning(
82-
"info_string values "
83-
"for {} ".format(key)
82+
"info_string values " "for {} ".format(key)
8483
+ "do not match.\n"
8584
+ "Current info_string: "
8685
+ "{}\n ".format(old_string)

benchmarking/download_benchmarks/download_benchmarks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ def _processOneBenchmark(self, benchmark):
5252
if "files" in one_benchmark["model"]:
5353
for field in one_benchmark["model"]["files"]:
5454
value = one_benchmark["model"]["files"][field]
55-
assert (
56-
"location" in value
57-
), "location field is missing in benchmark " "{}".format(filename)
55+
assert "location" in value, (
56+
"location field is missing in benchmark " "{}".format(filename)
57+
)
5858
location = value["location"]
5959
md5 = value.get("md5")
6060
path = self.downloadFile(location, md5)
6161
locations.append(path)
6262
if "libraries" in one_benchmark["model"]:
6363
for value in one_benchmark["model"]["libraries"]:
64-
assert (
65-
"location" in value
66-
), "location field is missing in benchmark " "{}".format(filename)
64+
assert "location" in value, (
65+
"location field is missing in benchmark " "{}".format(filename)
66+
)
6767
location = value["location"]
6868
md5 = value.get("md5")
6969
path = self.downloadFile(location, md5)

benchmarking/frameworks/caffe2/caffe2.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,20 @@ def verifyBenchmarkFile(self, benchmark, filename, is_post):
5555

5656
for f in model["files"]:
5757
field = model["files"][f]
58-
assert (
59-
"filename" in field
60-
), "Filename is missing in file" + " {} of benchmark {}".format(
61-
f, filename
58+
assert "filename" in field, (
59+
"Filename is missing in file"
60+
+ " {} of benchmark {}".format(f, filename)
6261
)
63-
assert (
64-
"location" in field
65-
), "Location is missing in file" + " {} of benchmark {}".format(
66-
f, filename
62+
assert "location" in field, (
63+
"Location is missing in file"
64+
+ " {} of benchmark {}".format(f, filename)
6765
)
6866
if "md5" not in field:
6967
assert not field["location"].startswith("//") or field[
7068
"location"
71-
].startswith(
72-
"//fbpkg"
73-
), "MD5 is missing in file" + " {} of benchmark {}".format(
74-
f, filename
69+
].startswith("//fbpkg"), (
70+
"MD5 is missing in file"
71+
+ " {} of benchmark {}".format(f, filename)
7572
)
7673

7774
# tests is mandatory
@@ -90,9 +87,9 @@ def verifyBenchmarkFile(self, benchmark, filename, is_post):
9087
is_generic_test = tests[0]["metric"] == "generic"
9188

9289
for test in tests:
93-
assert (
94-
"metric" in test
95-
), "Metric field is missing in " + "benchmark {}".format(filename)
90+
assert "metric" in test, (
91+
"Metric field is missing in " + "benchmark {}".format(filename)
92+
)
9693

9794
# no check is needed if the metric is generic
9895
if is_generic_test:
@@ -104,16 +101,16 @@ def verifyBenchmarkFile(self, benchmark, filename, is_post):
104101
if "warmup" not in test:
105102
test["warmup"] = -1
106103

107-
assert (
108-
"identifier" in test
109-
), "Identifier field is missing in " + "benchmark {}".format(filename)
104+
assert "identifier" in test, (
105+
"Identifier field is missing in " + "benchmark {}".format(filename)
106+
)
110107

111108
if "commands" in test or "command" in test or "arguments" in test:
112109
continue
113110
# for backward compatibility purpose
114-
assert (
115-
"inputs" in test
116-
), "Inputs field is missing in " + "benchmark {}".format(filename)
111+
assert "inputs" in test, (
112+
"Inputs field is missing in " + "benchmark {}".format(filename)
113+
)
117114

118115
num = -1
119116
for ip_name in test["inputs"]:

benchmarking/frameworks/framework_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,9 @@ def _runCommands(
577577
else (
578578
"simpleperf"
579579
if ["cpu"] == types
580-
else "perfetto" if PerfettoAnySupported(types) else "<unspecified>"
580+
else "perfetto"
581+
if PerfettoAnySupported(types)
582+
else "<unspecified>"
581583
)
582584
)
583585
profiler = profiling_args.setdefault("profiler", default_profiler)

benchmarking/harness.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,12 @@ def runBenchmark(self, info, platform, benchmarks):
253253
# check the framework matches
254254
if "model" in benchmark and "framework" in benchmark["model"]:
255255
assert benchmark["model"]["framework"] == self.args.framework, (
256-
"Framework specified in the json file "
257-
"{} ".format(benchmark["model"]["framework"])
258-
+ "does not match the command line argument "
259-
"{}".format(self.args.framework)
256+
"Framework specified in the json file " "{} ".format(
257+
benchmark["model"]["framework"]
258+
)
259+
+ "does not match the command line argument " "{}".format(
260+
self.args.framework
261+
)
260262
)
261263
if self.args.debug:
262264
for test in benchmark["tests"]:

benchmarking/platforms/device_manager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def run(self):
423423
getLogger().info(
424424
f"\nBattery status: {battery_state['status']}"
425425
+ f"\nBattery charge level: {battery_state['charge_level']}%"
426-
+ f"\nBattery temperature: {battery_state['temperature']}\xB0C"
426+
+ f"\nBattery temperature: {battery_state['temperature']}\xb0C"
427427
)
428428
if battery_state["disconnected"]:
429429
getLogger().warning(
@@ -456,9 +456,10 @@ def run(self):
456456
battery_state = getBatteryState(
457457
self.device["hash"], self.args.platform, self.args.android_dir
458458
)
459-
if (battery_state["supported"]) and battery_state[
460-
"charge_level"
461-
] < charge_threshold:
459+
if (
460+
(battery_state["supported"])
461+
and battery_state["charge_level"] < charge_threshold
462+
):
462463
getLogger().info(
463464
f"Battery charge of {battery_state['charge_level']}% is below threshold of {charge_threshold}%; Sleep another {self.cooldown} seconds."
464465
)

benchmarking/profilers/perfetto/perfetto.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class BatteryState(Enum):
6262

6363

6464
class Perfetto(ProfilerBase):
65-
6665
CONFIG_FILE = "perfetto.conf"
6766
DEVICE_DIRECTORY = "/data/local/tmp/perf"
6867
DEVICE_TRACE_DIRECTORY = "/data/misc/perfetto-traces"

0 commit comments

Comments
 (0)