Skip to content

Commit

Permalink
Merge pull request #729 from scap3yvt/723_fix_for_no_git_repo
Browse files Browse the repository at this point in the history
Fixed model saving when git repo not found
  • Loading branch information
sarthakpati authored Nov 11, 2023
2 parents d099b7b + b97fb05 commit 13abd55
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions GANDLF/utils/modelio.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ def save_model(
model_dict["parameters"] = params

try:
# this will try to encode the git hash of the current GaNDLF codebase, and reverts to "None" if not found
model_dict["git_hash"] = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=os.getcwd())
.decode("ascii")
.strip()
)
except subprocess.CalledProcessError:
model_dict["git_hash"] = None
except (subprocess.CalledProcessError, FileNotFoundError):
model_dict["git_hash"] = "None"

torch.save(model_dict, path)

Expand Down

0 comments on commit 13abd55

Please sign in to comment.