kernelfoundry.eval_pipeline.utils.tmp_dir¶
Custom TemporaryDirectory with container-aware cleanup.
When container processes run as root they can leave root-owned files behind,
making normal shutil.rmtree cleanup fail with PermissionError. This module
provides a drop-in replacement for tempfile.TemporaryDirectory that
falls back to sudo rm -rf in that case.
Classes
|
A |
- class kernelfoundry.eval_pipeline.utils.tmp_dir.TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False)[source]¶
A
tempfile.TemporaryDirectorythat can clean up root-owned files.After containerized runs (Docker / Podman), files inside the temporary directory may be owned by root. Normal cleanup raises
PermissionErrorin that situation. This subclass detects that and retries the deletion viasudo rm -rf, which must be available and permitted for the running user.All constructor arguments are forwarded to
tempfile.TemporaryDirectoryunchanged.- cleanup() None[source]¶
Clean up the temporary directory.
Tries the standard cleanup first. If that raises a
PermissionError(e.g. root-owned files left by a container), falls back tosudo rm -rf.