Skip to content

Commit c35de38

Browse files
YIWENX14facebook-github-bot
authored andcommitted
Fix lint and dependency issues in D67108845
Differential Revision: D67108845
1 parent 957259e commit c35de38

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

devtools/bundled_program/core.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from typing import Dict, List, Optional, Sequence, Type, Union
1010

1111
import executorch.devtools.bundled_program.schema as bp_schema
12-
from pyre_extensions import none_throws
13-
1412
import executorch.exir.schema as core_schema
1513

1614
import torch
@@ -44,10 +42,12 @@ class BundledProgram:
4442

4543
def __init__(
4644
self,
47-
executorch_program: Optional[Union[
48-
ExecutorchProgram,
49-
ExecutorchProgramManager,
50-
]],
45+
executorch_program: Optional[
46+
Union[
47+
ExecutorchProgram,
48+
ExecutorchProgramManager,
49+
]
50+
],
5151
method_test_suites: Sequence[MethodTestSuite],
5252
pte_file_path: Optional[str] = None,
5353
):
@@ -59,18 +59,24 @@ def __init__(
5959
pte_file_path: The path to pte file to deserialize program if executorch_program is not provided.
6060
"""
6161
if not executorch_program and not pte_file_path:
62-
raise RuntimeError("Either executorch_program or pte_file_path must be provided")
62+
raise RuntimeError(
63+
"Either executorch_program or pte_file_path must be provided"
64+
)
6365

6466
if executorch_program and pte_file_path:
65-
raise RuntimeError("Only one of executorch_program or pte_file_path can be used")
67+
raise RuntimeError(
68+
"Only one of executorch_program or pte_file_path can be used"
69+
)
6670

6771
method_test_suites = sorted(method_test_suites, key=lambda x: x.method_name)
6872
if executorch_program:
6973
self._assert_valid_bundle(executorch_program, method_test_suites)
70-
self.executorch_program: Optional[Union[
71-
ExecutorchProgram,
72-
ExecutorchProgramManager,
73-
]] = executorch_program
74+
self.executorch_program: Optional[
75+
Union[
76+
ExecutorchProgram,
77+
ExecutorchProgramManager,
78+
]
79+
] = executorch_program
7480
self._pte_file_path: Optional[str] = pte_file_path
7581

7682
self.method_test_suites = method_test_suites
@@ -88,7 +94,8 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
8894
if self.executorch_program:
8995
program = self._extract_program(self.executorch_program)
9096
else:
91-
with open(none_throws(self._pte_file_path), "rb") as f:
97+
assert self._pte_file_path is not None
98+
with open(self._pte_file_path, "rb") as f:
9299
p_bytes = f.read()
93100
program = _deserialize_pte_binary(p_bytes)
94101

devtools/bundled_program/test/test_bundle_data.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
# pyre-strict
88

9+
import tempfile
910
import unittest
1011
from typing import List
11-
import tempfile
1212
import executorch.devtools.bundled_program.schema as bp_schema
1313

1414
import torch
@@ -74,6 +74,7 @@ def test_bundled_program(self) -> None:
7474
bytes(_serialize_pte_binary(executorch_program.executorch_program)),
7575
)
7676

77+
7778
def test_bundled_program_from_pte(self) -> None:
7879
executorch_program, method_test_suites = get_common_executorch_program()
7980

@@ -82,11 +83,17 @@ def test_bundled_program_from_pte(self) -> None:
8283
with open(executorch_model_path, "wb") as f:
8384
f.write(executorch_program.buffer)
8485

85-
bundled_program = BundledProgram(executorch_program=None, method_test_suites=method_test_suites, pte_file_path=executorch_model_path)
86+
bundled_program = BundledProgram(
87+
executorch_program=None,
88+
method_test_suites=method_test_suites,
89+
pte_file_path=executorch_model_path
90+
)
8691

8792
method_test_suites = sorted(method_test_suites, key=lambda t: t.method_name)
8893

89-
for plan_id in range(len(executorch_program.executorch_program.execution_plan)):
94+
for plan_id in range(
95+
len(executorch_program.executorch_program.execution_plan)
96+
):
9097
bundled_plan_test = (
9198
bundled_program.serialize_to_schema().method_test_suites[plan_id]
9299
)

0 commit comments

Comments
 (0)