Files & directories¶
This submodule provides function for file and directory managment.
- biom3d.utils.os.abs_listdir(path: str) list[str][source]¶
List all files in a directory and return their absolute paths (sorted).
- Parameters:
path (str) – Path to the directory to list.
- Returns:
list_abs_paths – Sorted list of absolute paths for each file in the directory.
- Return type:
list of str
- biom3d.utils.os.abs_path(root: str, listdir_: list[str]) list[str][source]¶
Convert a list of filenames into absolute paths using the given root.
- Parameters:
root (str) – Root directory to prepend to each filename.
listdir (list of str) – List of filenames or relative paths.
- Returns:
list_abs_paths – List of absolute paths constructed by joining root and each element of listdir_.
- Return type:
list of str
Notes
Is not recursive.
- biom3d.utils.os.create_save_dirs(log_dir: str, desc: str, dir_names: list[str] = ['model', 'logs', 'images'], return_base_dir: bool = False) list[str][source]¶
Create a directory structure for saving models, logs, images, etc.
- Parameters:
log_dir (str) – Root directory in which to create the new structure.
desc (str) – Name of the model that will be appended to the timestamp.
dir_names (list of str, default=['model', 'logs', 'images']) – Names of the subdirectories to create inside the base directory.
return_base_dir (bool, default=False) – If True, the base directory path is included in the returned list.
- Returns:
list_dirs – List of full paths to the created subdirectories. Contains root if return_base_dir is True
- Return type:
list of str