From 46be267f430178f679c6b42b5653f301661e7f33 Mon Sep 17 00:00:00 2001 From: Shreyz-max Date: Sat, 13 Aug 2022 13:00:46 +0530 Subject: [PATCH 1/5] Added for saving git info --- allennlp/common/meta.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/allennlp/common/meta.py b/allennlp/common/meta.py index 787442c2786..3d3628bc60a 100644 --- a/allennlp/common/meta.py +++ b/allennlp/common/meta.py @@ -2,6 +2,8 @@ from dataclasses import dataclass, asdict import json import logging +import git +import socket from typing import Union from allennlp.version import VERSION @@ -28,10 +30,21 @@ def new(cls) -> "Meta": def to_file(self, path: Union[PathLike, str]) -> None: with open(path, "w") as meta_file: - json.dump(asdict(self), meta_file) + json.dump(asdict(self).update(get_git_info()), meta_file) @classmethod def from_path(cls, path: Union[PathLike, str]) -> "Meta": with open(path) as meta_file: data = json.load(meta_file) return cls(**data) + + +def get_git_info(): + repo = git.Repo(search_parent_directories=True) + repo_info = { + "repo_id": str(repo), + "repo_sha": str(repo.head.object.hexsha), + "repo_branch": str(repo.active_branch), + "hostname": str(socket.gethostname()), + } + return repo_info From 0af159d1c3ce9deea6ff13b2b158a9f5d90a49c6 Mon Sep 17 00:00:00 2001 From: Shreyz-max Date: Sat, 13 Aug 2022 13:00:46 +0530 Subject: [PATCH 2/5] Added for saving git info --- allennlp/common/meta.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/allennlp/common/meta.py b/allennlp/common/meta.py index 787442c2786..3d3628bc60a 100644 --- a/allennlp/common/meta.py +++ b/allennlp/common/meta.py @@ -2,6 +2,8 @@ from dataclasses import dataclass, asdict import json import logging +import git +import socket from typing import Union from allennlp.version import VERSION @@ -28,10 +30,21 @@ def new(cls) -> "Meta": def to_file(self, path: Union[PathLike, str]) -> None: with open(path, "w") as meta_file: - json.dump(asdict(self), meta_file) + json.dump(asdict(self).update(get_git_info()), meta_file) @classmethod def from_path(cls, path: Union[PathLike, str]) -> "Meta": with open(path) as meta_file: data = json.load(meta_file) return cls(**data) + + +def get_git_info(): + repo = git.Repo(search_parent_directories=True) + repo_info = { + "repo_id": str(repo), + "repo_sha": str(repo.head.object.hexsha), + "repo_branch": str(repo.active_branch), + "hostname": str(socket.gethostname()), + } + return repo_info From 00c40f189ae27b4c8b3085bf470f553971eccebf Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 19 Aug 2022 14:05:28 +0530 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d31a4df966e..022f99dbe5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added metric `FBetaVerboseMeasure` which extends `FBetaMeasure` to ensure compatibility with logging plugins and add some options. - Added three sample weighting techniques to `ConditionalRandomField` by supplying three new subclasses: `ConditionalRandomFieldWeightEmission`, `ConditionalRandomFieldWeightTrans`, and `ConditionalRandomFieldWeightLannoy`. +- Added saving of github repo infos along with other metadata in model archives. ### Fixed From bc1eaedd5f23311d4cdbe3b8869f0a8bb48ea4de Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 19 Aug 2022 14:05:28 +0530 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d31a4df966e..022f99dbe5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added metric `FBetaVerboseMeasure` which extends `FBetaMeasure` to ensure compatibility with logging plugins and add some options. - Added three sample weighting techniques to `ConditionalRandomField` by supplying three new subclasses: `ConditionalRandomFieldWeightEmission`, `ConditionalRandomFieldWeightTrans`, and `ConditionalRandomFieldWeightLannoy`. +- Added saving of github repo infos along with other metadata in model archives. ### Fixed From 5cba2b7b95dc3f9d47b94f2855d21d0c07cc1dc0 Mon Sep 17 00:00:00 2001 From: Shreyz-max Date: Sat, 20 Aug 2022 15:30:09 +0530 Subject: [PATCH 5/5] Added for saving git info --- allennlp/common/meta.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/allennlp/common/meta.py b/allennlp/common/meta.py index 3d3628bc60a..e2d93d33883 100644 --- a/allennlp/common/meta.py +++ b/allennlp/common/meta.py @@ -2,8 +2,8 @@ from dataclasses import dataclass, asdict import json import logging -import git import socket +from git import Repo from typing import Union from allennlp.version import VERSION @@ -40,7 +40,7 @@ def from_path(cls, path: Union[PathLike, str]) -> "Meta": def get_git_info(): - repo = git.Repo(search_parent_directories=True) + repo = Repo(search_parent_directories=True) repo_info = { "repo_id": str(repo), "repo_sha": str(repo.head.object.hexsha),