Output git commit when running.
@@ -12,12 +12,34 @@ import pickle
import json
import sys as _sys
import datetime
+import parlai
+import git
+
from parlai.core.agents import get_agent_module, get_task_module
from parlai.core.build_data import modelzoo_path
from parlai.tasks.tasks import ids_to_tasks
from parlai.core.utils import Opt, load_opt_file
+def print_git_commit():
+ """Print the current git commit of ParlAI and parlai_internal."""
+ root = os.path.dirname(os.path.dirname(parlai.__file__))
+ internal_root = os.path.join(root, 'parlai_internal')
+ try:
+ git_ = git.Git(root)
+ current_commit = git_.rev_parse('HEAD')
+ print(f'[ Current ParlAI commit: {current_commit} ]')
+ except git.GitCommandNotFound:
+ raise
+
+ try:
+ git_ = git.Git(internal_root)
+ internal_commit = git_.rev_parse('HEAD')
+ print(f'[ Current internal commit: {internal_commit} ]')
+ except git.GitCommandNotFound:
+ pass
+
+
def print_announcements(opt):
"""
Output any announcements the ParlAI team wishes to make to users.
@@ -960,6 +982,7 @@ class ParlaiParser(argparse.ArgumentParser):
if print_args:
self.print_args()
+ print_git_commit()
print_announcements(self.opt)
return self.opt
