From 2255c2c7a00fa6e3dae46913f536e9e27572f088 Mon Sep 17 00:00:00 2001 From: Stas Bekman Date: Thu, 15 Oct 2020 21:22:43 -0700 Subject: [PATCH] [seq2seq] get_git_info fails gracefully (#7843) Co-authored-by: Sam Shleifer --- examples/seq2seq/utils.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/seq2seq/utils.py b/examples/seq2seq/utils.py index d19cf63549..9740e75ae0 100644 --- a/examples/seq2seq/utils.py +++ b/examples/seq2seq/utils.py @@ -457,14 +457,22 @@ def load_json(path): def get_git_info(): - repo = git.Repo(search_parent_directories=True) - repo_infos = { - "repo_id": str(repo), - "repo_sha": str(repo.head.object.hexsha), - "repo_branch": str(repo.active_branch), - "hostname": str(socket.gethostname()), - } - return repo_infos + try: + repo = git.Repo(search_parent_directories=True) + repo_infos = { + "repo_id": str(repo), + "repo_sha": str(repo.head.object.hexsha), + "repo_branch": str(repo.active_branch), + "hostname": str(socket.gethostname()), + } + return repo_infos + except TypeError: + return { + "repo_id": None, + "repo_sha": None, + "repo_branch": None, + "hostname": None, + } ROUGE_KEYS = ["rouge1", "rouge2", "rougeL", "rougeLsum"]