From 99b71768a038adbbe82cb2a16c90e29e63951669 Mon Sep 17 00:00:00 2001 From: hiyouga Date: Tue, 11 Mar 2025 15:13:59 +0800 Subject: [PATCH] support commit info Former-commit-id: af752b1c271739e6614773e6898566240d0c7043 --- src/llamafactory/extras/env.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/llamafactory/extras/env.py b/src/llamafactory/extras/env.py index 504917c0..d7a75d3f 100644 --- a/src/llamafactory/extras/env.py +++ b/src/llamafactory/extras/env.py @@ -74,4 +74,13 @@ def print_env() -> None: except Exception: pass + try: + import subprocess + + commit_info = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True) + commit_hash = commit_info.stdout.strip() + info["Git commit"] = commit_hash + except Exception: + pass + print("\n" + "\n".join([f"- {key}: {value}" for key, value in info.items()]) + "\n")