Skip to content

Commit ab79e67

Browse files
authored
Fix Lint job (#333)
1 parent 6028420 commit ab79e67

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

.github/workflows/lint.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ jobs:
3636
run: |
3737
python -m pip install pre-commit
3838
- name: Run pre-commit checks
39-
# Continue on error to display the formatting diff in case lint fails.
40-
continue-on-error: true
4139
run: |
4240
pre-commit run --all-files
4341
- name: Check to see what files pre-commit modified

benchmarks/decoders/benchmark_decoders.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
plot_data,
1515
run_benchmarks,
1616
TorchAudioDecoder,
17-
TorchCodecCoreCompiled,
18-
TorchCodecCoreBatch,
1917
TorchCodecCore,
18+
TorchCodecCoreBatch,
19+
TorchCodecCoreCompiled,
2020
TorchCodecPublic,
2121
TorchVision,
2222
)
@@ -120,8 +120,8 @@ def main() -> None:
120120
continue
121121
k, v = item.split("=")
122122
kwargs_dict[k] = v
123-
decoder_dict["TorchCodecCoreBatch" + options] = (
124-
TorchCodecCoreBatch(**kwargs_dict)
123+
decoder_dict["TorchCodecCoreBatch" + options] = TorchCodecCoreBatch(
124+
**kwargs_dict
125125
)
126126
elif decoder.startswith("tcoptions:"):
127127
options = decoder[len("tcoptions:") :]
@@ -131,9 +131,7 @@ def main() -> None:
131131
continue
132132
k, v = item.split("=")
133133
kwargs_dict[k] = v
134-
decoder_dict["TorchCodecCore:" + options] = (
135-
TorchCodecCore(**kwargs_dict)
136-
)
134+
decoder_dict["TorchCodecCore:" + options] = TorchCodecCore(**kwargs_dict)
137135
video_paths = args.bm_video_paths.split(",")
138136
if args.bm_video_dir:
139137
video_paths = []

benchmarks/decoders/benchmark_decoders_library.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,12 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
227227
)
228228
return frames
229229

230+
230231
class TorchCodecPublic(AbstractDecoder):
231232
def __init__(self, num_ffmpeg_threads=None):
232-
self._num_ffmpeg_threads = int(num_ffmpeg_threads) if num_ffmpeg_threads else None
233+
self._num_ffmpeg_threads = (
234+
int(num_ffmpeg_threads) if num_ffmpeg_threads else None
235+
)
233236

234237
def get_frames_from_video(self, video_file, pts_list):
235238
decoder = VideoDecoder(video_file, num_ffmpeg_threads=self._num_ffmpeg_threads)
@@ -246,6 +249,7 @@ def get_consecutive_frames_from_video(self, video_file, numFramesToDecode):
246249
break
247250
return frames
248251

252+
249253
@torch.compile(fullgraph=True, backend="eager")
250254
def compiled_seek_and_next(decoder, pts):
251255
seek_to_pts(decoder, pts)
@@ -468,9 +472,11 @@ def plot_data(df_data, plot_path):
468472
plot_path,
469473
)
470474

475+
471476
def get_metadata(video_file_path: str) -> VideoStreamMetadata:
472477
return VideoDecoder(video_file_path).metadata
473478

479+
474480
def run_benchmarks(
475481
decoder_dict: dict[str, AbstractDecoder],
476482
video_files_paths: list[str],
@@ -492,9 +498,7 @@ def run_benchmarks(
492498
metadata_label = f"{metadata.codec} {metadata.width}x{metadata.height}, {metadata.duration_seconds}s {metadata.average_fps}fps"
493499

494500
duration = metadata.duration_seconds
495-
uniform_pts_list = [
496-
i * duration / num_samples for i in range(num_samples)
497-
]
501+
uniform_pts_list = [i * duration / num_samples for i in range(num_samples)]
498502

499503
# Note that we are using the same random pts values for all decoders for the same
500504
# video. However, because we use the duration as part of this calculation, we
@@ -504,7 +508,10 @@ def run_benchmarks(
504508
for decoder_name, decoder in decoder_dict.items():
505509
print(f"video={video_file_path}, decoder={decoder_name}")
506510

507-
for kind, pts_list in [("uniform", uniform_pts_list), ("random", random_pts_list)]:
511+
for kind, pts_list in [
512+
("uniform", uniform_pts_list),
513+
("random", random_pts_list),
514+
]:
508515
if verbose:
509516
print(
510517
f"video={video_file_path}, decoder={decoder_name}, pts_list={pts_list}"

benchmarks/decoders/benchmark_readme_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@
150150
"python_version": "3.11.10",
151151
"system": "Linux"
152152
}
153-
]
153+
]

benchmarks/decoders/generate_readme_data.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,8 @@ def main() -> None:
4747

4848
decoder_dict = {}
4949
decoder_dict["TorchCodec"] = TorchCodecPublic()
50-
decoder_dict["TorchCodec[num_threads=1]"] = TorchCodecPublic(
51-
num_ffmpeg_threads=1
52-
)
53-
decoder_dict["TorchVision[backend=video_reader]"] = TorchVision(
54-
"video_reader"
55-
)
50+
decoder_dict["TorchCodec[num_threads=1]"] = TorchCodecPublic(num_ffmpeg_threads=1)
51+
decoder_dict["TorchVision[backend=video_reader]"] = TorchVision("video_reader")
5652
decoder_dict["TorchAudio"] = TorchAudioDecoder()
5753

5854
# These are the number of uniform seeks we do in the seek+decode benchmark.

0 commit comments

Comments
 (0)