From 64ab546979bc9daab95a3f83ba0b2cb8cd0d4488 Mon Sep 17 00:00:00 2001 From: Chien-Chin Huang Date: Wed, 19 Nov 2025 12:48:16 -0800 Subject: [PATCH 1/3] Update (base update) [ghstack-poisoned] From b1ec7910508ed7e3cf3927c605436aad5af341b4 Mon Sep 17 00:00:00 2001 From: Chien-Chin Huang Date: Wed, 19 Nov 2025 12:48:16 -0800 Subject: [PATCH 2/3] Update [ghstack-poisoned] --- scripts/loss_compare.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/loss_compare.py b/scripts/loss_compare.py index 31573c3bce..48a211c8f2 100644 --- a/scripts/loss_compare.py +++ b/scripts/loss_compare.py @@ -301,6 +301,33 @@ def print_configuration( # ============================================================================= +def check_git_clean_state() -> None: + """Check if git working directory is clean before switching commits. + + Raises SystemExit if there are uncommitted changes or untracked files. + """ + result = subprocess.run( + ["git", "status", "--porcelain"], + capture_output=True, + text=True, + check=True, + ) + + if result.stdout.strip(): + log_print("Error: Git working directory is not clean") + log_print(" Cannot switch commits with uncommitted changes") + log_print("") + log_print("Modified/untracked files:") + for line in result.stdout.strip().split("\n"): + log_print(f" {line}") + log_print("") + log_print("Please commit, stash, or discard your changes before running this script") + log_print(" - To commit: git add -A && git commit -m 'message'") + log_print(" - To stash: git stash") + log_print(" - To discard: git checkout -- . && git clean -fd") + sys.exit(1) + + def checkout_commit(commit: str, commit_name: str) -> None: """Checkout git commit.""" if commit != ".": @@ -840,6 +867,12 @@ def main() -> None: args.job_dump_folder, ) + # Check if git working directory is clean before switching commits + # Skip check if both commits are "." (comparing configs on same commit) + needs_git_checkout = args.baseline_commit != "." or args.test_commit != "." + if needs_git_checkout: + check_git_clean_state() + create_seed_checkpoint( enable_seed_checkpoint, args.baseline_config, From f8584851715b312b3d241b1880d2090b3dc44782 Mon Sep 17 00:00:00 2001 From: Chien-Chin Huang Date: Wed, 19 Nov 2025 16:03:22 -0800 Subject: [PATCH 3/3] Update [ghstack-poisoned] --- scripts/loss_compare.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/loss_compare.py b/scripts/loss_compare.py index 48a211c8f2..42ad3a81be 100644 --- a/scripts/loss_compare.py +++ b/scripts/loss_compare.py @@ -321,7 +321,9 @@ def check_git_clean_state() -> None: for line in result.stdout.strip().split("\n"): log_print(f" {line}") log_print("") - log_print("Please commit, stash, or discard your changes before running this script") + log_print( + "Please commit, stash, or discard your changes before running this script" + ) log_print(" - To commit: git add -A && git commit -m 'message'") log_print(" - To stash: git stash") log_print(" - To discard: git checkout -- . && git clean -fd")