toil.lib.io¶
Attributes¶
Classes¶
A stream wrapping class that calls any functions passed to onWrite() with the number of bytes written for every write. |
Functions¶
|
Make a temporary directory like tempfile.mkdtemp, but with relaxed permissions. |
|
Robustly tries to delete paths. |
|
Return a tmp file name to use with atomic_install. This will be in the |
|
atomic install of tmp_path as final_path |
|
Context manager to create a temporary file. Entering returns path to |
|
Copy a file using posix atomic creations semantics. |
|
Copy an open file using posix atomic creations semantics. |
|
Make a publicly-accessible directory in the given directory. |
|
Try to use the given path. Return it if it exists or can be made, |
Module Contents¶
- toil.lib.io.logger¶
- toil.lib.io.mkdtemp(suffix=None, prefix=None, dir=None)[source]¶
Make a temporary directory like tempfile.mkdtemp, but with relaxed permissions.
The permissions on the directory will be 711 instead of 700, allowing the group and all other users to traverse the directory. This is necessary if the directory is on NFS and the Docker daemon would like to mount it or a file inside it into a container, because on NFS even the Docker daemon appears bound by the file permissions.
See <https://github.com/DataBiosphere/toil/issues/4644>, and <https://stackoverflow.com/a/67928880> which talks about a similar problem but in the context of user namespaces.
- toil.lib.io.robust_rmtree(path)[source]¶
Robustly tries to delete paths.
Continues silently if the path to be removed is already gone, or if it goes away while this function is executing.
May raise an error if a path changes between file and directory while the function is executing, or if a permission error is encountered.
- toil.lib.io.atomic_tmp_file(final_path)[source]¶
Return a tmp file name to use with atomic_install. This will be in the same directory as final_path. The temporary file will have the same extension as finalPath. It the final path is in /dev (/dev/null, /dev/stdout), it is returned unchanged and atomic_tmp_install will do nothing.
- toil.lib.io.atomic_install(tmp_path, final_path)[source]¶
atomic install of tmp_path as final_path
- Return type:
None
- toil.lib.io.AtomicFileCreate(final_path, keep=False)[source]¶
Context manager to create a temporary file. Entering returns path to the temporary file in the same directory as finalPath. If the code in context succeeds, the file renamed to its actually name. If an error occurs, the file is not installed and is removed unless keep is specified.
- Parameters:
- Return type:
- toil.lib.io.atomic_copy(src_path, dest_path, executable=None)[source]¶
Copy a file using posix atomic creations semantics.
- toil.lib.io.atomic_copyobj(src_fh, dest_path, length=16384, executable=False)[source]¶
Copy an open file using posix atomic creations semantics.
- Parameters:
src_fh (io.BytesIO)
dest_path (str)
length (int)
executable (bool)
- Return type:
None
- toil.lib.io.make_public_dir(in_directory, suggested_name=None)[source]¶
Make a publicly-accessible directory in the given directory.
- Parameters:
- Return type:
Try to make a random directory name with length 4 that doesn’t exist, with the given prefix. Otherwise, try length 5, length 6, etc, up to a max of 32 (len of uuid4 with dashes replaced). This function’s purpose is mostly to avoid having long file names when generating directories. If somehow this fails, which should be incredibly unlikely, default to a normal uuid4, which was our old default.
- toil.lib.io.try_path(path, min_size=100 * 1024 * 1024)[source]¶
Try to use the given path. Return it if it exists or can be made, and we can make things within it, or None otherwise.
- class toil.lib.io.WriteWatchingStream(backingStream)[source]¶
A stream wrapping class that calls any functions passed to onWrite() with the number of bytes written for every write.
Not seekable.
- Parameters:
backingStream (IO[Any])
- backingStream¶
- writeListeners = []¶