Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

save git status when run commands #4862

Open
tshu-w opened this issue Dec 14, 2020 · 12 comments
Open

save git status when run commands #4862

tshu-w opened this issue Dec 14, 2020 · 12 comments
Assignees
Labels
Contributions welcome Feature request Good First Issue A great place to start for first time contributors
Milestone

Comments

@tshu-w
Copy link
Contributor

tshu-w commented Dec 14, 2020

Sometimes after changing many versions of the code, I'm confused about how I got this result. It would be nice if allennlp could log the current git status to serialization_dir when running train command.

Here is an example of a transformers record(git_log.json):

{
    "repo_id": "<git.repo.base.Repo '/data/wts/transformers/.git'>",
    "repo_sha": "b01ddc9577b87f057e163d49563ee3f74f4810cf",
    "repo_branch": "master",
    "hostname": "XXX-GPUSERVER-144"
}
@epwalsh
Copy link
Member

epwalsh commented Dec 14, 2020

Something like this would be very good to have.

@epwalsh epwalsh added this to the 1.3 milestone Dec 14, 2020
@tshu-w
Copy link
Contributor Author

tshu-w commented Dec 15, 2020

here is toy code for reference

import git
import json
import os
import socket


def save_git_info(folder_path: str) -> None:
    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()),
    }

    with open(os.path.join(folder_path, "git_log.json"), "w") as f:
        json.dump(repo_infos, f, indent=4)

@epwalsh epwalsh self-assigned this Dec 18, 2020
@epwalsh
Copy link
Member

epwalsh commented Dec 21, 2020

@tshu-w would you be interested in making a PR for this? It would also be good to include the AllenNLP version in this meta-data.

@epwalsh
Copy link
Member

epwalsh commented Dec 21, 2020

Another detail: we should make sure this meta data is included in the model archive.

@tshu-w
Copy link
Contributor Author

tshu-w commented Dec 22, 2020

@epwalsh I would be glad to make a pull request. I will take a look when I have time.

@dirkgr dirkgr modified the milestones: 1.4, 2.1 Feb 12, 2021
@dirkgr dirkgr modified the milestones: 2.1, 2.2 Feb 24, 2021
@epwalsh
Copy link
Member

epwalsh commented Jun 4, 2021

Now that we're saving meta data in model archives, adding this should be pretty straightforward. We'd just need to add it to the Meta class.

@epwalsh epwalsh added the Good First Issue A great place to start for first time contributors label Jun 4, 2021
@tshu-w
Copy link
Contributor Author

tshu-w commented Jun 5, 2021

@epwalsh Awesome, I think it's a more common solution.

@tshu-w tshu-w closed this as completed Jun 5, 2021
@epwalsh epwalsh reopened this Jun 7, 2021
@epwalsh
Copy link
Member

epwalsh commented Jun 7, 2021

@tshu-w we're going to keep this open until the feature is added. Do you still want to make a PR?

@tshu-w
Copy link
Contributor Author

tshu-w commented Jun 8, 2021

@epwalsh I would love to, but I cannot promise.

@tshu-w
Copy link
Contributor Author

tshu-w commented Jan 20, 2022

@epwalsh Sorry, I probably won't think about submitting a PR. hope someone is interested

@Shreyz-max
Copy link

@epwalsh I am interested in this PR. If @tshu-w does not have any problem, I would like to look into it.

@tshu-w
Copy link
Contributor Author

tshu-w commented Aug 10, 2022

@Shreyz-max No problem of course.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contributions welcome Feature request Good First Issue A great place to start for first time contributors
Projects
None yet
Development

No branches or pull requests

5 participants