Skip to content

Commit a363df7

Browse files
author
Andrei Bratu
committed
add tests for new eval run functionality
1 parent cc601f3 commit a363df7

File tree

3 files changed

+740
-4
lines changed

3 files changed

+740
-4
lines changed

jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export default {
33
preset: "ts-jest",
44
testEnvironment: "node",
55
moduleNameMapper: {
6-
"(.+)\.js$": "$1",
6+
"^(?!.*node_modules)(.+)\\.js$": "$1",
77
},
88
};

src/evals/run.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ export async function runEval<
8383
concurrency = Math.min(concurrency, 32);
8484

8585
const [hlFile, function_] = await getHLFile(client, fileConfig);
86+
if (hlFile.type === "flow" && !function_) {
87+
throw new HumanloopRuntimeError(
88+
"Flows can only be evaluated locally, please provide a callable inside `file` argument.",
89+
);
90+
}
8691
const type_ = hlFile.type as FileType;
8792

8893
let hlDataset: DatasetResponse;
@@ -629,13 +634,16 @@ async function resolveFile<I extends Record<string, unknown> & { message?: any[]
629634
);
630635
}
631636

632-
if (callable) {
637+
if (version) {
633638
// User responsibility to provide adequate file.version for upserting the file
634639
console.info(
635640
`${CYAN}Upserting a new File version based on \`file.version\`. Will use provided callable for generating Logs.${RESET}\n`,
636641
);
637642
try {
638-
return [await upsertFile(client, fileConfig), callable];
643+
return [
644+
await upsertFile(client, fileConfig),
645+
callable ? callable : undefined,
646+
];
639647
} catch (error: any) {
640648
throw new HumanloopRuntimeError(
641649
`Error upserting File. Please ensure \`file.version\` is valid: ${error.toString()}`,
@@ -645,7 +653,7 @@ async function resolveFile<I extends Record<string, unknown> & { message?: any[]
645653

646654
if (!versionId && !environment) {
647655
// Return default version of the file
648-
return [hlFile as unknown as EvaluatedFile, undefined];
656+
return [hlFile as unknown as EvaluatedFile, callable];
649657
}
650658

651659
if (!fileId && (versionId || environment)) {

0 commit comments

Comments
 (0)