diff --git a/.changeset/soft-eagles-protect.md b/.changeset/soft-eagles-protect.md new file mode 100644 index 000000000..1f72dad5a --- /dev/null +++ b/.changeset/soft-eagles-protect.md @@ -0,0 +1,5 @@ +--- +"braintrust": patch +--- + +Do not collect git metadata when org-level metadata settings are absent. diff --git a/js/src/framework.ts b/js/src/framework.ts index eb22fbb8b..c9a834ebd 100644 --- a/js/src/framework.ts +++ b/js/src/framework.ts @@ -344,7 +344,7 @@ export interface Evaluator< baseExperimentId?: string; /** - * Optional settings for collecting git metadata. By default, will collect all git metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings. If org settings are absent, git metadata is not collected. */ gitMetadataSettings?: GitMetadataSettings; diff --git a/js/src/gitutil.ts b/js/src/gitutil.ts index ef7a26bcb..43a6d8005 100644 --- a/js/src/gitutil.ts +++ b/js/src/gitutil.ts @@ -149,12 +149,12 @@ function truncateToByteLimit(s: string, byteLimit: number = 65536): string { } export async function getRepoInfo(settings?: GitMetadataSettings) { - if (settings && settings.collect === "none") { + if (!settings || settings.collect === "none") { return undefined; } const repo = await repoInfo(); - if (!repo || !settings || settings.collect === "all") { + if (!repo || settings.collect === "all") { return repo; } diff --git a/js/src/logger.ts b/js/src/logger.ts index 6623aa322..2fe305dec 100644 --- a/js/src/logger.ts +++ b/js/src/logger.ts @@ -3545,7 +3545,7 @@ type InitializedExperiment = * @param options.apiKey The API key to use. If the parameter is not specified, will try to use the `BRAINTRUST_API_KEY` environment variable. If no API key is specified, will prompt the user to login. * @param options.orgName (Optional) The name of a specific organization to connect to. This is useful if you belong to multiple. * @param options.metadata (Optional) A dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys must be strings. - * @param options.gitMetadataSettings (Optional) Settings for collecting git metadata. By default, will collect all git metadata fields allowed in org-level settings. + * @param options.gitMetadataSettings (Optional) Settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings. If org settings are absent, git metadata is not collected. * @param setCurrent If true (the default), set the global current-experiment to the newly-created one. * @param options.open If the experiment already exists, open it in read-only mode. Throws an error if the experiment does not already exist. * @param options.projectId The id of the project to create the experiment in. This takes precedence over `project` if specified. @@ -3699,9 +3699,7 @@ export function init( return repoInfo; } let mergedGitMetadataSettings = { - ...(state.gitMetadataSettings || { - collect: "all", - }), + ...(state.gitMetadataSettings || { collect: "none" as const }), }; if (gitMetadataSettings) { mergedGitMetadataSettings = mergeGitMetadataSettings( @@ -5709,7 +5707,7 @@ function _saveOrgInfo( state.orgName = org.name; state.apiUrl = iso.getEnv("BRAINTRUST_API_URL") ?? org.api_url; state.proxyUrl = iso.getEnv("BRAINTRUST_PROXY_URL") ?? org.proxy_url; - state.gitMetadataSettings = org.git_metadata || undefined; + state.gitMetadataSettings = org.git_metadata || { collect: "none" }; break; } }