Skip to content

Commit

Permalink
increase timeout (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Feb 9, 2024
1 parent f7657d9 commit c6dfe31
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 400 deletions.
174 changes: 93 additions & 81 deletions js/src/tests/batch_client.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,50 +52,16 @@ async function waitUntilRunFound(
);
}

test("Test persist update run", async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
});
const projectName = "__test_persist_update_run_batch";
await deleteProject(langchainClient, projectName);

const runId = uuidv4();
const dottedOrder = convertToDottedOrderFormat(
new Date().getTime() / 1000,
runId
);
await langchainClient.createRun({
id: runId,
project_name: projectName,
name: "test_run",
run_type: "llm",
inputs: { text: "hello world" },
trace_id: runId,
dotted_order: dottedOrder,
});

await langchainClient.updateRun(runId, {
outputs: { output: ["Hi"] },
dotted_order: dottedOrder,
trace_id: runId,
});
await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
expect(storedRun.id).toEqual(runId);
await langchainClient.deleteProject({ projectName });
});

test("Test persist update runs above the batch size limit", async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
pendingAutoBatchedRunLimit: 2,
});
const projectName = "__test_persist_update_run_batch";
await deleteProject(langchainClient, projectName);
test.concurrent(
"Test persist update run",
async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
});
const projectName = "__test_persist_update_run_batch_1";
await deleteProject(langchainClient, projectName);

const createRun = async () => {
const runId = uuidv4();
const dottedOrder = convertToDottedOrderFormat(
new Date().getTime() / 1000,
Expand All @@ -115,50 +81,96 @@ test("Test persist update runs above the batch size limit", async () => {
outputs: { output: ["Hi"] },
dotted_order: dottedOrder,
trace_id: runId,
end_time: Math.floor(new Date().getTime() / 1000),
});
await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
expect(storedRun.id).toEqual(runId);
};
await langchainClient.deleteProject({ projectName });
},
180_000
);

await Promise.all([createRun(), createRun(), createRun()]);
test.concurrent(
"Test persist update runs above the batch size limit",
async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
pendingAutoBatchedRunLimit: 2,
});
const projectName = "__test_persist_update_run_batch_above_bs_limit";
await deleteProject(langchainClient, projectName);

await langchainClient.deleteProject({ projectName });
});
const createRun = async () => {
const runId = uuidv4();
const dottedOrder = convertToDottedOrderFormat(
new Date().getTime() / 1000,
runId
);
await langchainClient.createRun({
id: runId,
project_name: projectName,
name: "test_run",
run_type: "llm",
inputs: { text: "hello world" },
trace_id: runId,
dotted_order: dottedOrder,
});

test("Test persist update run with delay", async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
});
const projectName = "__test_persist_update_run_batch";
await deleteProject(langchainClient, projectName);
await langchainClient.updateRun(runId, {
outputs: { output: ["Hi"] },
dotted_order: dottedOrder,
trace_id: runId,
end_time: Math.floor(new Date().getTime() / 1000),
});
await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
expect(storedRun.id).toEqual(runId);
};

const runId = uuidv4();
const dottedOrder = convertToDottedOrderFormat(
new Date().getTime() / 1000,
runId
);
await langchainClient.createRun({
id: runId,
project_name: projectName,
name: "test_run",
run_type: "llm",
inputs: { text: "hello world" },
trace_id: runId,
dotted_order: dottedOrder,
});
await Promise.all([createRun(), createRun(), createRun()]);

await langchainClient.deleteProject({ projectName });
},
180_000
);

test.concurrent(
"Test persist update run with delay",
async () => {
const langchainClient = new Client({
autoBatchTracing: true,
callerOptions: { maxRetries: 0 },
});
const projectName = "__test_persist_update_run_batch_with_delay";
await deleteProject(langchainClient, projectName);

const runId = uuidv4();
const dottedOrder = convertToDottedOrderFormat(
new Date().getTime() / 1000,
runId
);
await langchainClient.createRun({
id: runId,
project_name: projectName,
name: "test_run",
run_type: "llm",
inputs: { text: "hello world" },
trace_id: runId,
dotted_order: dottedOrder,
});

await new Promise((resolve) => setTimeout(resolve, 1000));
await langchainClient.updateRun(runId, {
outputs: { output: ["Hi"] },
dotted_order: dottedOrder,
trace_id: runId,
end_time: Math.floor(new Date().getTime() / 1000),
});
await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
expect(storedRun.id).toEqual(runId);
await langchainClient.deleteProject({ projectName });
});
await new Promise((resolve) => setTimeout(resolve, 1000));
await langchainClient.updateRun(runId, {
outputs: { output: ["Hi"] },
dotted_order: dottedOrder,
trace_id: runId,
end_time: Math.floor(new Date().getTime() / 1000),
});
await waitUntilRunFound(langchainClient, runId, true);
const storedRun = await langchainClient.readRun(runId);
expect(storedRun.id).toEqual(runId);
await langchainClient.deleteProject({ projectName });
},
180_000
);
Loading

0 comments on commit c6dfe31

Please sign in to comment.