From f26eaaa6345f3b8938ef4bc53609ec335419afad Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Tue, 17 Dec 2024 21:07:26 +0000 Subject: [PATCH] Run the data function as soon as evalite is called for maximum concurrency. --- .changeset/funny-pants-relax.md | 5 +++++ packages/evalite/src/index.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/funny-pants-relax.md diff --git a/.changeset/funny-pants-relax.md b/.changeset/funny-pants-relax.md new file mode 100644 index 0000000..fd3dbb4 --- /dev/null +++ b/.changeset/funny-pants-relax.md @@ -0,0 +1,5 @@ +--- +"evalite": patch +--- + +Run the data function as soon as evalite is called for maximum concurrency. diff --git a/packages/evalite/src/index.ts b/packages/evalite/src/index.ts index c79a90c..0c55109 100644 --- a/packages/evalite/src/index.ts +++ b/packages/evalite/src/index.ts @@ -86,9 +86,11 @@ export const evalite = ( evalName: string, opts: Evalite.RunnerOpts ) => { - return describe.concurrent(evalName, async () => { - const dataset = await opts.data(); - + // Eagerly run the promise before the dataset for + // maximum concurrency + const datasetPromise = opts.data(); + return describe(evalName, async () => { + const dataset = await datasetPromise; it.concurrent.for(dataset.map((d, index) => ({ ...d, index })))( evalName, async (data, { task }) => {