Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lib): correctly caching and simplified structure #233

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 7 additions & 27 deletions manim_slides/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
MutableMapping,
Optional,
Sequence,
Set,
Tuple,
ValuesView,
)
Expand Down Expand Up @@ -478,23 +477,12 @@
"""
self.__add_last_slide()

self.__output_folder.mkdir(parents=True, exist_ok=True)

files_folder = self.__output_folder / "files"
files_folder.mkdir(exist_ok=True)

scene_name = str(self)
scene_files_folder = files_folder / scene_name

old_animation_files: Set[Path] = set()

if not scene_files_folder.exists():
scene_files_folder.mkdir()
elif not use_cache:
shutil.rmtree(scene_files_folder)
scene_files_folder.mkdir()
else:
old_animation_files.update(scene_files_folder.iterdir())
scene_files_folder.mkdir(parents=True, exist_ok=True)

Check warning on line 485 in manim_slides/slide.py

View check run for this annotation

Codecov / codecov/patch

manim_slides/slide.py#L485

Added line #L485 was not covered by tests

files = []
for src_file in tqdm(
Expand All @@ -510,24 +498,16 @@
# but animations before a will have a None src_file
continue

filename = src_file.name
rev_filename = (
src_file.parent / f"{src_file.stem}_reversed{src_file.suffix}"
)
dst_file = scene_files_folder / filename
dst_file = scene_files_folder / src_file.name
rev_file = scene_files_folder / f"{src_file.stem}_reversed{src_file.suffix}"

Check warning on line 502 in manim_slides/slide.py

View check run for this annotation

Codecov / codecov/patch

manim_slides/slide.py#L501-L502

Added lines #L501 - L502 were not covered by tests

# We only copy animation if it was not present
if filename in old_animation_files:
old_animation_files.remove(filename)
else:
if not use_cache or not dst_file.exists():

Check warning on line 505 in manim_slides/slide.py

View check run for this annotation

Codecov / codecov/patch

manim_slides/slide.py#L505

Added line #L505 was not covered by tests
shutil.copyfile(src_file, dst_file)

# We only reverse video if it was not present
if rev_filename in old_animation_files:
old_animation_files.remove(rev_filename)
else:
rev_file = scene_files_folder / rev_filename
if not rev_file.exists():
reverse_video_file(src_file, rev_file)
if not use_cache or not rev_file.exists():
reverse_video_file(src_file, rev_file)

Check warning on line 510 in manim_slides/slide.py

View check run for this annotation

Codecov / codecov/patch

manim_slides/slide.py#L509-L510

Added lines #L509 - L510 were not covered by tests

files.append(dst_file)

Expand Down
Loading