quemb.shared.manage_scratch.WorkDir.from_environment

classmethod WorkDir.from_environment(*, user_defined_root=None, prefix=None, cleanup_at_end=True)

Create a WorkDir based on the environment.

The naming scheme is f"{user_defined_root}/{prefix}{SLURM_JOB_ID}" on systems with SLURM. If SLURM is not available, then the process ID is used instead.

Parameters:
  • user_defined_root (str | PathLike | None) – The root directory where to create temporary directories e.g. /tmp or /scratch. If None, then the SCRATCH_ROOT value from quemb.shared.config.Settings is taken.

  • prefix (str | None) – The prefix for the subdirectory.

  • cleanup_at_end (bool) – Perform cleanup when calling self.cleanup.

Return type:

WorkDir