Do not collect ancestors when GitMetadataSettings.collect is none #1279
+1
−1
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.
Problem
logger.compute_metadata attempts to collect git ancestor commit data if base_exp_id or base_experiment are not None.
This causes an error when clients are attempting to run Evals in an environment (e.g. CI/CD runs in a docker container) that does not have the Git binary installed, this only happens with git repos.
gitutil.py attempts to check if the git module is present before attempting git commands but that just checks that the GitPython module is present which doesn't guarantee the binary.
There doesn't seem to be a way to bypass this call to get_past_n_ancestors.
Steps to Reproduce:
git initin the directory from step 1.git remote add origin https://github.com/fake/repo.gitgit branch -m maingit add . && git commit -m "test"docker run --rm -it \ -v "$PWD":/app \ -w /app \ python:3.12-slim \ shpip install braintrust.BRAINTRUST_API_KEY=<your-api-key> python <your-script-name>.py.Expected Behavior
It should successfully run the Eval.
Observed Behavior
It fails with:
Solution
I used GitMetadataSettings being set to collect: none to skip this get_past_n_ancestors call. I'm not sure if an explicit flag for this exact operation would be better since GitMetadataSettings collection is a bit different than getting the past ancestor commits to add to an experiment.
Test Plan
Tested locally with the repro script in a container without git binary and it successfully created the Eval.