Skip to content

Commit

Permalink
import_work_directory, hardlink mode (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz authored Nov 21, 2023
1 parent adadf2c commit 89ea492
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion sisyphus/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sisyphus/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 89ea492

Please sign in to comment.