utilities
General-purpose utility functions for mdfactory.
funcworking_directory(path, create=False, cleanup=False, exists_ok=True)Change working directory and return to previous on exit.
parampathstr or PathTarget directory to change into.
paramcreatebool= FalseCreate the directory if it does not exist. Default is False.
paramcleanupbool= FalseRemove the directory before creating it. Implies create=True.
Default is False.
paramexists_okbool= TrueIf False, raise FileExistsError when the directory already exists.
Default is True.
Returns
Nonefunctemporary_working_directory(prefix='temp_')Create a temporary directory and change into it.
paramprefixstr= 'temp_'Prefix for the temporary directory name. Default is "temp_".
Returns
Nonefuncload_yaml_file(yaml_file_path) → Dict[str, Any]Load data from a YAML file.
paramyaml_file_pathstrThe path to the YAML file.
Returns
typing.DictThe loaded data from the YAML file.
funclock_local_folder(folder, retries=120, wait=2.0, message='')Acquire a file-based lock on a folder, blocking until available.
Create a \<folder>.lock sentinel file and yield. If the lock file
already exists, retry up to retries times with wait seconds between
attempts. The lock file is removed on exit.
paramfolderstr or PathPath to the folder to lock.
paramretriesint= 120Maximum number of acquisition attempts. Default is 120.
paramwaitfloat= 2.0Seconds to sleep between retries. Default is 2.0.
parammessagestr= ''Informational message (currently unused, reserved for logging).
Returns
None