Skip to content

Record the git branch and package version in job metadata - #2225

Open
lbluque wants to merge 1 commit into
mainfrom
record-branch-and-version-in-job-metadata
Open

lbluque wants to merge 1 commit into
mainfrom
record-branch-and-version-in-job-metadata

Conversation

@lbluque

@lbluque lbluque commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

job.metadata.commit already identifies the code a run was trained with, but only as a hash, and only when fairchem.core sits in a git repo — a released install has no repo, so get_commit_hash() reports core:None.

This adds two more read-only fields next to it, both populated in JobConfig.__post_init__:

  • metadata.branch — from git branch --show-current in the fairchem.core checkout. None for a released install and for a detached HEAD, neither of which has a branch to report.
  • metadata.version — the installed fairchem-core version. 2.21.1 for a release, 2.21.1.dev50+gdfbfb7044 for a dev checkout, so it pins a released install that has no commit.
Trained from commit branch version
A dev checkout core:db9b17fc6,experimental:NA main 2.21.1.dev50+gdfbfb7044
A released install core:None,experimental:NA None 2.21.1

Both fields are Optional[str] = None, so existing configs and anything reading Metadata are unaffected.

One caveat worth knowing: for an editable install the version is resolved when the package is installed, so its embedded hash can lag behind metadata.commit. commit remains the accurate one.

Motivation

Makes a checkpoint's provenance self-describing: given a trained model you can tell exactly which fairchem code produced it, including for models trained from a PyPI install where no commit is recoverable today. Downstream checkpoint tooling can then surface it rather than asking the person who trained the model.

Test plan

New tests in tests/core/common/test_utils_.py cover get_branch_for_repo on a branch, on a detached HEAD, and outside a git repo, plus get_package_version.

job.metadata.commit already identifies the code a run was trained with, but
only as a hash, and only when fairchem.core sits in a git repo: a released
install has no repo, so get_commit_hash() reports "core:None".

Record two more read-only fields alongside it:

- metadata.branch, from `git branch --show-current` in the fairchem.core
  checkout. None for a released install and for a detached HEAD, both of
  which have no branch to report.
- metadata.version, the installed fairchem-core version. "2.21.1" for a
  release, "2.21.1.dev50+gdfbfb7044" for a dev checkout, so it pins a
  released install that has no commit.

Note that for an editable install the version is resolved when the package
is installed, so its embedded hash can lag behind metadata.commit.
@meta-cla meta-cla Bot added the cla signed label Oct 6, 2026
@lbluque
lbluque requested a review from rayg1234 October 7, 2026 00:10
@lbluque lbluque added enhancement New feature or request minor Minor version release labels Oct 7, 2026
@lbluque
lbluque requested a review from mshuaibii October 7, 2026 00:13
@lbluque
lbluque added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@mshuaibii
mshuaibii added this pull request to the merge queue Oct 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed enhancement New feature or request minor Minor version release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants