Skip to content

Commit e5f40a0

Browse files
committed
More pyfmt updates
1 parent 855d9bd commit e5f40a0

15 files changed

Lines changed: 46 additions & 46 deletions

File tree

.github/scripts/run_with_env_secrets.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def main():
5858

5959
docker_path = shutil.which("docker")
6060
if not docker_path:
61-
run_cmd_or_die(f"bash { os.environ.get('RUNNER_TEMP', '') }/exec_script")
61+
run_cmd_or_die(f"bash {os.environ.get('RUNNER_TEMP', '')}/exec_script")
6262
else:
6363
container_name = (
6464
run_cmd_or_die(
@@ -68,10 +68,10 @@ def main():
6868
-e RUNNER_ARTIFACT_DIR=/artifacts \
6969
-e RUNNER_DOCS_DIR=/docs \
7070
-e RUNNER_TEST_RESULTS_DIR=/test-results \
71-
--env-file="{ os.environ.get('RUNNER_TEMP', '') }/github_env_{ os.environ.get('GITHUB_RUN_ID', '') }" \
71+
--env-file="{os.environ.get("RUNNER_TEMP", "")}/github_env_{os.environ.get("GITHUB_RUN_ID", "")}" \
7272
`# It is unknown why the container sees a different value for this.` \
7373
-e GITHUB_STEP_SUMMARY \
74-
{ ' '.join([ f'-e {v}' for v in secrets_u_names ]) } \
74+
{" ".join([f"-e {v}" for v in secrets_u_names])} \
7575
--cap-add=SYS_PTRACE \
7676
--detach \
7777
--ipc=host \
@@ -80,16 +80,16 @@ def main():
8080
--tty \
8181
--ulimit stack=10485760:83886080 \
8282
--ulimit core=0 \
83-
{ os.environ.get('GPU_FLAG', '') } \
84-
-v "{ os.environ.get('GITHUB_WORKSPACE', '') }/{ os.environ.get('REPOSITORY', '') }:/{ os.environ.get('REPOSITORY', 'work') }" \
85-
-v "{ os.environ.get('GITHUB_WORKSPACE', '') }/test-infra:/test-infra" \
86-
-v "{ os.environ.get('RUNNER_ARTIFACT_DIR', '') }:/artifacts" \
87-
-v "{ os.environ.get('RUNNER_DOCS_DIR', '') }:/docs" \
88-
-v "{ os.environ.get('RUNNER_TEST_RESULTS_DIR', '') }:/test-results" \
89-
-v "{ os.environ.get('RUNNER_TEMP', '') }/exec_script:/exec" \
90-
-v "{ os.environ.get('GITHUB_STEP_SUMMARY', '') }":"{ os.environ.get('GITHUB_STEP_SUMMARY', '') }" \
91-
-w /{ os.environ.get('REPOSITORY', 'work') } \
92-
"{ os.environ.get('DOCKER_IMAGE', '') }"
83+
{os.environ.get("GPU_FLAG", "")} \
84+
-v "{os.environ.get("GITHUB_WORKSPACE", "")}/{os.environ.get("REPOSITORY", "")}:/{os.environ.get("REPOSITORY", "work")}" \
85+
-v "{os.environ.get("GITHUB_WORKSPACE", "")}/test-infra:/test-infra" \
86+
-v "{os.environ.get("RUNNER_ARTIFACT_DIR", "")}:/artifacts" \
87+
-v "{os.environ.get("RUNNER_DOCS_DIR", "")}:/docs" \
88+
-v "{os.environ.get("RUNNER_TEST_RESULTS_DIR", "")}:/test-results" \
89+
-v "{os.environ.get("RUNNER_TEMP", "")}/exec_script:/exec" \
90+
-v "{os.environ.get("GITHUB_STEP_SUMMARY", "")}":"{os.environ.get("GITHUB_STEP_SUMMARY", "")}" \
91+
-w /{os.environ.get("REPOSITORY", "work")} \
92+
"{os.environ.get("DOCKER_IMAGE", "")}"
9393
""" # noqa: E501
9494
)
9595
.replace("\n", "")

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/hud_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def render_html_from_state(
468468
f'<span class="ev" title="{title_attr}">{icon}</span>'
469469
)
470470
html_parts.append(
471-
f"<td class=\"cell {cell_classes}\">{''.join(cell_parts)}</td>"
471+
f'<td class="cell {cell_classes}">{"".join(cell_parts)}</td>'
472472
)
473473
html_parts.append("</tr>")
474474
html_parts.append("</tbody>")

s3_management/manage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def to_simple_package_html(self, subdir: Optional[str], package_name: str) -> st
544544
attributes += ' data-requires-python="&gt;=3.10"'
545545

546546
out.append(
547-
f' <a href="/{obj.key}{maybe_fragment}"{attributes}>{path.basename(obj.key).replace("%2B","+")}</a><br/>'
547+
f' <a href="/{obj.key}{maybe_fragment}"{attributes}>{path.basename(obj.key).replace("%2B", "+")}</a><br/>'
548548
)
549549
# Adding html footer
550550
out.append(" </body>")
@@ -564,7 +564,7 @@ def to_simple_packages_html(
564564
out.append(" <body>")
565565
for pkg_name in sorted(self.get_package_names(subdir)):
566566
out.append(
567-
f' <a href="{pkg_name.lower().replace("_","-")}/">{pkg_name.replace("_","-")}</a><br/>'
567+
f' <a href="{pkg_name.lower().replace("_", "-")}/">{pkg_name.replace("_", "-")}</a><br/>'
568568
)
569569
# Adding html footer
570570
out.append(" </body>")
@@ -813,7 +813,7 @@ def main() -> None:
813813
)
814814
etime = time.time()
815815
print(
816-
f"DEBUG: Fetched {len(idx.objects)} objects for '{prefix}' in {etime-stime:.2f} seconds"
816+
f"DEBUG: Fetched {len(idx.objects)} objects for '{prefix}' in {etime - stime:.2f} seconds"
817817
)
818818
if args.compute_sha256:
819819
idx.compute_sha256()

tools/analytics/cubinsizes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def compute_cubin_sizes(file_name, section_name=".nv_fatbin", debug=False):
6565
raise RuntimeError(
6666
f"Unexpected cubin version {hex(version)} or kind {kind}"
6767
)
68-
sm_ver = f'{"ptx" if kind == 1 else "sm"}_{sm_ver}'
68+
sm_ver = f"{'ptx' if kind == 1 else 'sm'}_{sm_ver}"
6969
if debug:
7070
print(
7171
f" {idx}: elf_size={elf_size} code_ver={hex(code_ver)} sm={sm_ver}"

tools/analytics/download_count_wheels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,20 @@ def output_results(bytes_cache: dict) -> None:
107107
print("=-=-= OS =-=-=")
108108
total_os_num = sum(os_results.values())
109109
for os_type, num in os_results.items():
110-
print(f"\t* {os_type}: {num} ({(num/total_os_num)*100:.2f}%)")
110+
print(f"\t* {os_type}: {num} ({(num / total_os_num) * 100:.2f}%)")
111111

112112
print("=-=-= ARCH =-=-=")
113113
total_arch_num = sum(arch_results.values())
114114
for arch_type, num in arch_results.items():
115-
print(f"\t* {arch_type}: {num} ({(num/total_arch_num) * 100:.2f}%)")
115+
print(f"\t* {arch_type}: {num} ({(num / total_arch_num) * 100:.2f}%)")
116116

117117
print("=-=-= By Package =-=-=")
118118
for package_name, upper_val in package_results.items():
119119
print(f"=-=-= {package_name} =-=-=")
120120
total_package_num = sum(upper_val.values())
121121
for package_version, num in upper_val.items():
122122
print(
123-
f"\t* {package_version}: {num} ({(num/total_package_num) * 100:.2f}%)"
123+
f"\t* {package_version}: {num} ({(num / total_package_num) * 100:.2f}%)"
124124
)
125125

126126

tools/analytics/duplicates_analyze.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def humansize(size):
5656
if size < 1024:
5757
return f"{size} bytes"
5858
if size < 1024**2:
59-
return f"{int(size/1024)} Kb"
59+
return f"{int(size / 1024)} Kb"
6060
if size < 1024**3:
61-
return f"{size/(1024.0**2):.2f} Mb"
62-
return f"{size/(1024.0**3):.2f} Gb"
61+
return f"{size / (1024.0**2):.2f} Mb"
62+
return f"{size / (1024.0**3):.2f} Gb"
6363

6464

6565
def print_sizes(libname, depth: int = 2) -> None:
@@ -104,7 +104,7 @@ def print_symbols_overlap(libname1: str, libname2: str) -> None:
104104
)
105105
return
106106
print(
107-
f"{libname1} symbols size {humansize(sym1_size)} overlap {humansize(overlap_size)} ({100.0 * overlap_size/sym1_size :.2f}%)"
107+
f"{libname1} symbols size {humansize(sym1_size)} overlap {humansize(overlap_size)} ({100.0 * overlap_size / sym1_size:.2f}%)"
108108
)
109109
for sym in sym_overlap:
110110
print(sym)

tools/analytics/github_analyze.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def get_commits_dict(x, y):
479479
# if Issue is mentioned is release branch, than it was picked already
480480
if mentioned_in_release:
481481
continue
482-
print(f'{issue_url} ;{issue["title"]};{state}')
482+
print(f"{issue_url} ;{issue['title']};{state}")
483483

484484

485485
def commits_missing_in_release(
@@ -539,7 +539,7 @@ def analyze_stacks(repo: GitRepo) -> None:
539539
print(f"{author} has 1 stack of depth {slen[0]}")
540540
continue
541541
print(
542-
f"{author} has {len(slen)} stacks max depth is {max(slen)} avg depth is {sum(slen)/len(slen):.2f} mean is {slen[len(slen)//2]}"
542+
f"{author} has {len(slen)} stacks max depth is {max(slen)} avg depth is {sum(slen) / len(slen):.2f} mean is {slen[len(slen) // 2]}"
543543
)
544544

545545

@@ -735,7 +735,7 @@ def main():
735735
print(f"Parsing git history with remote {remote}...", end="", flush=True)
736736
start_time = time.time()
737737
x = repo._run_git_log(f"{remote}/main")
738-
print(f"done in {time.time()-start_time:.1f} sec")
738+
print(f"done in {time.time() - start_time:.1f} sec")
739739
if args.analyze_reverts:
740740
analyze_reverts(x)
741741
elif args.contributor_stats:

tools/analytics/validate_binaries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def main() -> None:
7070
)
7171

7272
assert len(expected_builds) > 0, "expected builds set should not be empty."
73-
assert (
74-
expected_builds == actual_builds
75-
), f"Missing following builds in conda: {expected_builds.difference(actual_builds)} for platform {platform}"
73+
assert expected_builds == actual_builds, (
74+
f"Missing following builds in conda: {expected_builds.difference(actual_builds)} for platform {platform}"
75+
)
7676

7777
print(
7878
f"\nSuccessfully verified following binaries are available in Conda for {platform}..."

tools/analytics/validate_pypi_staging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def get_size(path):
3939
if size < 1024:
4040
return f"{size} bytes"
4141
elif size < pow(1024, 2):
42-
return f"{round(size/1024, 2)} KB"
42+
return f"{round(size / 1024, 2)} KB"
4343
elif size < pow(1024, 3):
44-
return f"{round(size/(pow(1024,2)), 2)} MB"
44+
return f"{round(size / (pow(1024, 2)), 2)} MB"
4545
elif size < pow(1024, 4):
46-
return f"{round(size/(pow(1024,3)), 2)} GB"
46+
return f"{round(size / (pow(1024, 3)), 2)} GB"
4747

4848

4949
def generate_expected_builds(platform: str, package: str, release: str) -> list:

tools/scripts/consolidate_scale_config_yaml.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def check_being_used(org, repo, name, user, token):
105105
found[ocurrence["path"]] = 1
106106
if len(found) > 0:
107107
return True
108-
print(f'No usage found for {name} in {org}/{repo} = {query["q"]}', file=sys.stderr)
108+
print(f"No usage found for {name} in {org}/{repo} = {query['q']}", file=sys.stderr)
109109
return False
110110

111111

@@ -173,7 +173,7 @@ def main():
173173
os, is_ephemeral, ref_repo = type_warning[v["instance_type"]][k]
174174
if os != v["os"] or is_ephemeral != v["is_ephemeral"]:
175175
print(
176-
f'WARNING! Found runner_types with same name && instance_type [{v["instance_type"]}, {k}] but different OS or is_ephemeral tag, this will fail [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v["os"]}, {v["is_ephemeral"]})]',
176+
f"WARNING! Found runner_types with same name && instance_type [{v['instance_type']}, {k}] but different OS or is_ephemeral tag, this will fail [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v['os']}, {v['is_ephemeral']})]",
177177
file=sys.stderr,
178178
)
179179
else:
@@ -184,11 +184,11 @@ def main():
184184
os, is_ephemeral, ref_repo = runn_cfg
185185
if os != v["os"] or is_ephemeral != v["is_ephemeral"]:
186186
print(
187-
f'INFO! Found runner_types with same instance_type [{v["instance_type"]}, {k}] and different OS or is_ephemeral tag, this is not encouraged, but it is OK [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v["os"], v["is_ephemeral"]})]'
187+
f"INFO! Found runner_types with same instance_type [{v['instance_type']}, {k}] and different OS or is_ephemeral tag, this is not encouraged, but it is OK [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v['os'], v['is_ephemeral']})]"
188188
)
189189
else:
190190
print(
191-
f'WARNING! Found runner_types with same instance_type [{v["instance_type"]}, {k}] and same OS or is_ephemeral tags, but they have different names, this is bad [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v["os"], v["is_ephemeral"]})]',
191+
f"WARNING! Found runner_types with same instance_type [{v['instance_type']}, {k}] and same OS or is_ephemeral tags, but they have different names, this is bad [({ref_repo}, {os}, {is_ephemeral}), ({repo}, {v['os'], v['is_ephemeral']})]",
192192
file=sys.stderr,
193193
)
194194
else:

0 commit comments

Comments
 (0)