diff --git a/sisyphus/job.py b/sisyphus/job.py index bfb4b6a..807dcda 100644 --- a/sisyphus/job.py +++ b/sisyphus/job.py @@ -574,7 +574,7 @@ def _sis_import_from_dirs(self, import_dirs, mode, use_alias=False): :param import_dirs: :return: """ - assert mode in ("copy", "symlink", "dryrun"), "Unsupported mode given: %s" % mode + assert mode in ("copy", "symlink", "hardlink", "dryrun"), "Unsupported mode given: %s" % mode local_path = self._sis_path() if use_alias and not self._sis_aliases: @@ -628,6 +628,14 @@ def _sis_import_from_dirs(self, import_dirs, mode, use_alias=False): elif mode == "symlink": logging.info("Symlink import %s from %s" % (self._sis_id(), import_path)) os.symlink(src=os.path.abspath(import_path), dst=local_path, target_is_directory=True) + elif mode == "hardlink": + logging.info("Hardlink import %s from %s" % (self._sis_id(), import_path)) + shutil.copytree( + src=os.path.abspath(import_path), + dst=local_path, + symlinks=True, + copy_function=os.link, + ) else: logging.info("Possible import %s from %s" % (self._sis_id(), import_path)) return True diff --git a/sisyphus/toolkit.py b/sisyphus/toolkit.py index 03b4005..7bd08a8 100644 --- a/sisyphus/toolkit.py +++ b/sisyphus/toolkit.py @@ -453,7 +453,7 @@ def import_work_directory(directories: Union[str, List[str]], mode="dryrun", use Link or copy finished jobs from other work directories. :param str directories: Path to other work directories - :param str mode: How to import job directories. Options: (copy, symlink, dryrun) + :param str mode: How to import job directories. Options: (copy, symlink, hardlink, dryrun) """ if isinstance(directories, str):