Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed model saving when git repo not found #729

Merged
merged 3 commits into from
Nov 11, 2023
Merged
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
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 @@
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"

Check warning on line 165 in GANDLF/utils/modelio.py

View check run for this annotation

Codecov / codecov/patch

GANDLF/utils/modelio.py#L164-L165

Added lines #L164 - L165 were not covered by tests

torch.save(model_dict, path)

Expand Down
Loading