-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Tex selective cleanup #4084
Tex selective cleanup #4084
Conversation
In the old version also files nonrelated to the current latex job were deleted, if one now adds an (optional) jobname argument to delete_non_svg_files, only files related to that jobname (and not appearing in the whitelist) are deleted.
for more information, see https://pre-commit.ci
I'm not sure I fully understand the motivation for this - if you want to write a file with the tikz coordinates, just give it a The current approach with only deleting files with a specific stem, I believe, would also fail because-depending on the latex distribution-there may be other extra files created during the latex compilation (other than the dvi file). |
The approach you suggest would work, but is bad software engineering practice. I'll try to explain what I mean by that. A different, but as good approach would be to compile the tex file in a temporary directory, copying the tex and any other file extension one wants to preserve (on the whitelist) to the cache and removing the directory. That would get rid of all unnecessary files and not interfere between different classes using tex_file_writing. If you think this is a better approach, I'm willing to implement that. |
Okay so, if we are talking about software engineering, I will be blunt:
These functions could have some rewriting and move those global config references etc. to inside of caller classes. Better solution is to move those deletion codes to caller classes. |
Dear Sir, |
File caching as a whole is, unfortunately, just as so many other things, implemented in a rather messy and fragmented way. In an ideal world, there would be some sort of asset manager that control the life cycle of all assets generated and cached by the library, but we don't have that at the moment, nor is it worth to delay future developments for it. The feature you describe does sound interesting; better interaction for TikZ drawings, in particular the ability to have better coordinate-wise control over them, does sound interesting, and I encourage you to open an issue with more details on the interface you imagine to get feedback from the community. This would also strengthen the case for merging this change here; seen in isolation it is hard to see the benefit of the somewhat semantic nature of the improvement of the cleanup behavior vs. the drawback of the improved complexity in the implementation. Alternatively, it might make sense to spend the additional epsilon of effort and think about replacing the current |
I'd still be interested in hearing more about your plans @digmanwaves, but it appears this PR is stale and I'll close it for now. |
Overview: What does this pull request change?
In the current version, the call to delete_nonsvg_files (after a TeX run) deletes also files that are not related to the current TeX job. In the new version, an argument 'jobname' was added to delete_nonsvg_files that - when specified - restricts the deletion to files with a stem equal to jobname.
Motivation and Explanation: Why and how do your changes improve the library?
This change avoids removing unrelated files. In a future contribution to Manim I would like to add a class that converts TeX (containing TikZ) to SVG and also writes a file that contains specific coordinates defined in the TikZ part to a file,such that you can use these coordinates in Manim. In that case the file extension of the coordinate file is added to the whitelist, such that the TeX run does not the coordinate file. The change of this pull request avoids that the coordinate file is deleted by a subsequent unrelated TeX run.
From this perspective, this fix is a necessary fix to allow for the future extension. It does not impede the current working of Manim.
Links to added or changed documentation pages
I did not change any documentation except for the docstrings inside the code.
Further Information and Comments
None.
Reviewer Checklist