Skip to content

Commit

Permalink
fix(js): Fix git tagging for Vitest (#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Feb 6, 2025
1 parent 6a17c93 commit ee20bc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.3.6",
"version": "0.3.7",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "[email protected]",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js";
export { overrideFetchImplementation } from "./singletons/fetch.js";

// Update using yarn bump-version
export const __version__ = "0.3.6";
export const __version__ = "0.3.7";
38 changes: 19 additions & 19 deletions js/src/utils/jestlike/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,18 @@ export function generateWrapperFromJestlikeMethods(
experimentConfig?.metadata?.LANGSMITH_ENVIRONMENT ??
getEnvironmentVariable("LANGSMITH_ENVIRONMENT");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const metadata: Record<string, any> = {
const suiteMetadata: Record<string, any> = {
...experimentConfig?.metadata,
__ls_runner: testRunnerName,
};
if (environment !== undefined) {
metadata.ENVIRONMENT = environment;
suiteMetadata.ENVIRONMENT = environment;
}
if (nodeEnv !== undefined) {
metadata.NODE_ENV = nodeEnv;
suiteMetadata.NODE_ENV = nodeEnv;
}
if (langsmithEnvironment !== undefined) {
metadata.LANGSMITH_ENVIRONMENT = langsmithEnvironment;
suiteMetadata.LANGSMITH_ENVIRONMENT = langsmithEnvironment;
}
const context = {
suiteUuid,
Expand All @@ -321,7 +321,7 @@ export function generateWrapperFromJestlikeMethods(
createdAt: new Date().toISOString(),
projectConfig: {
...experimentConfig,
metadata,
metadata: suiteMetadata,
},
enableTestTracking: experimentConfig?.enableTestTracking,
};
Expand All @@ -347,11 +347,13 @@ export function generateWrapperFromJestlikeMethods(
const endTime = new Date();
let branch;
let commit;
let dirty;
try {
branch = execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.trim();
commit = execSync("git rev-parse HEAD").toString().trim();
dirty = execSync("git status --porcelain").toString().trim() !== "";
} catch {
return;
}
Expand All @@ -376,23 +378,21 @@ export function generateWrapperFromJestlikeMethods(
finalModifiedAt = endTime.toISOString();
}
const datasetInfo = datasetSetupInfo.get(suiteUuid);
const { as_of } = await client.readDatasetVersion({
await client.updateProject(datasetInfo.project.id, {
metadata: {
...suiteMetadata,
commit,
branch,
dirty,
},
});
await client.updateDatasetTag({
datasetId: datasetInfo.dataset.id,
asOf: finalModifiedAt,
tag: `git:commit:${commit}`,
});
await Promise.all([
client.updateDatasetTag({
datasetId: datasetInfo.dataset.id,
asOf: as_of,
tag: `git:branch:${branch}`,
}),
client.updateDatasetTag({
datasetId: datasetInfo.dataset.id,
asOf: as_of,
tag: `git:commit:${commit}`,
}),
]);
} catch {
} catch (e) {
console.error(e);
return;
}
});
Expand Down

0 comments on commit ee20bc8

Please sign in to comment.