Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions scripts/submit_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def get_all_commands(args) -> Dict[str, Tuple[List[str], str]]:


def isolate_code(project_root: str, save_dir: str) -> str:
"""Snapshot the code tree into save_dir/code (or code_vN if taken).
"""Snapshot the code tree into save_dir/code (or code_vN if taken); for an
in-repo save_dir the snapshot goes to a <repo>_code_snapshots/ sibling of
the repo instead, mirroring save_dir's relative layout.

Top-level entries are symlinked (instant, avoids deep-copying data/),
except ancestors of the snapshot itself.
Expand All @@ -244,7 +246,16 @@ def isolate_code(project_root: str, save_dir: str) -> str:
import shutil
from pathlib import Path

isolated_root = os.path.join(save_dir, "code")
# setuptools file discovery walks the whole source tree following
# symlinks, so snapshots must live outside it.
project_root_resolved = Path(project_root).resolve()
save_dir_resolved = Path(save_dir).resolve()
if save_dir_resolved.is_relative_to(project_root_resolved):
snapshots_root = project_root_resolved.parent / f"{project_root_resolved.name}_code_snapshots"
save_dir_rel = save_dir_resolved.relative_to(project_root_resolved)
isolated_root = str(snapshots_root / save_dir_rel / "code")
else:
isolated_root = os.path.join(save_dir, "code")
if os.path.exists(isolated_root):
version = 1
while os.path.exists(f"{isolated_root}_v{version}"):
Expand Down
Loading