Optionally store git metadata in RE md - #266
Merged
Merged
Conversation
Contributor
|
I like the idea, but could we use naming that isn't tied to |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds support for recording git provenance for a startup/profile collection repository into the RunEngine’s metadata (RE.md) during nslsii.configure_base() setup, to improve traceability of optimization/profile collection runs.
Changes:
- Add
git_info()helper innslsii/utils.pyto retrieve commit SHA, branch, and dirty status for a local git working tree. - Extend
configure_base()to optionally store that git metadata intoRE.mdwhen a directory is provided.
File summaries
| File | Description |
|---|---|
| nslsii/utils.py | Adds git_info() helper that shells out to git to collect ref/branch/dirty state. |
| nslsii/init.py | Adds an optional configure_base() argument and writes git metadata into RE.md. |
Review details
Suppressed comments (3)
nslsii/init.py:126
- The docstring parameter name should match the function signature. If the intent is to point at the startup/profile collection repository, document it under the same name (
profile_collection_dir) and clarify it should be a git working tree.
startup_dir : Path, optional
None by default, path to the repository being used
nslsii/utils.py:135
subprocess.check_output(..., cwd=...)can raise otherOSErrorsubclasses (e.g.NotADirectoryError) if the provided directory is invalid. CatchingOSErrorhere would makegit_inforeliably return(None, None, None)for any filesystem/path issue, consistent with the current fallback behavior.
except (subprocess.CalledProcessError, FileNotFoundError):
return None, None, None
nslsii/init.py:321
- Using
if startup_dir:will skip storing metadata when the caller passes a valid but falsy path-like value (e.g. empty string meaning current directory). Prefer an explicitis not Nonecheck, and update the variable name to match the public parameter name. Also use the prevailing double-quote style in this module for consistency.
# store startup code git repository metadata in RE
if startup_dir:
ref, branch, dirty = git_info(startup_dir)
RE.md['startup_git_metadata'] = {'ref': ref, 'branch': branch, 'dirty': dirty}
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
49
to
53
| redis_ssl=False, | ||
| redis_prefix="", | ||
| redis_db: int = 0, | ||
| startup_dir=None, | ||
| ): |
Comment on lines
+318
to
+321
| # store startup code git repository metadata in RE | ||
| if startup_dir: | ||
| ref, branch, dirty = git_info(startup_dir) | ||
| RE.md['startup_git_metadata'] = {'ref': ref, 'branch': branch, 'dirty': dirty} |
| return conn | ||
|
|
||
|
|
||
| def git_info(git_dir: Path) -> tuple[str, str, bool] | tuple[None, None, None]: |
Jakub Wlodek (jwlodek)
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of an effort to have more provenance for blop agents, having the ability to link profile collection code back to an optimization run is important.
This PR adds an optional argument
profile_collection_dirtoconfigure_base()which when provided, stores the current ref, branch name, and dirty status toRE.md