Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"build-runner": "tsc",
"release-build": "tsx release-build.ts",
"web-codegen-scorer": "tsx ./runner/bin/cli.ts",
"wcs": "pnpm -s web-codegen-scorer",
"eval": "pnpm web-codegen-scorer eval",
"init": "pnpm web-codegen-scorer init",
"report": "cd report-app && CODEGEN_REPORTS_DIR=../.web-codegen-scorer/reports pnpm start",
Expand Down
7 changes: 6 additions & 1 deletion runner/eval-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ function builder(argv: Argv): Argv<Options> {
})
.option('logging', {
type: 'string',
default: 'dynamic' as const,
default:
process.env['CI'] === '1'
? ('text-only' as const)
: ('dynamic' as const),
defaultDescription: '`dynamic` (or `text-only` when `CI=1`)',
requiresArg: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you currently use wcs eval <..> --logging without a value, it will not show help. I think requiring an argument is better here. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, that makes sense.

choices: ['text-only', 'dynamic'] as const,
description: 'Type of logging to use during the evaluation process',
})
Expand Down
4 changes: 2 additions & 2 deletions runner/orchestration/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ export async function generateCodeAndAssess(options: {
stack: e instanceof Error ? e.stack : undefined,
});

let details = ` Error: ${e}`;
let details = `Error: ${e}`;
if (e instanceof Error && e.stack) {
details += e.stack;
details += `\nStack: ${e.stack}`;
}

progress.log(
Expand Down
26 changes: 25 additions & 1 deletion runner/progress/dynamic-progress-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ProgressType,
progressTypeToIcon,
} from './progress-logger.js';
import { redX } from '../reporting/format.js';

const PREFIX_WIDTH = 20;

Expand All @@ -17,6 +18,11 @@ export class DynamicProgressLogger implements ProgressLogger {
private spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
private currentSpinnerFrame = 0;
private spinnerInterval: ReturnType<typeof setInterval> | undefined;
private errors: {
prompt: RootPromptDefinition;
message: string;
details?: string;
}[] = [];

initialize(total: number): void {
this.finalize();
Expand Down Expand Up @@ -72,9 +78,22 @@ export class DynamicProgressLogger implements ProgressLogger {
this.wrapper?.stop();
this.pendingBars.clear();
this.wrapper = this.totalBar = this.spinnerInterval = undefined;

for (const error of this.errors) {
let message = `${redX()} [${error.prompt.name}] ${error.message}`;
if (error.details) {
message += `\n ${error.details}`;
}
console.error(message);
}
}

log(prompt: RootPromptDefinition, type: ProgressType, message: string): void {
log(
prompt: RootPromptDefinition,
type: ProgressType,
message: string,
details?: string
): void {
if (!this.wrapper || !this.totalBar) {
return;
}
Expand All @@ -92,6 +111,11 @@ export class DynamicProgressLogger implements ProgressLogger {
return;
}

// Capture errors for static printing once the dynamic progress is hidden.
if (type === 'error') {
this.errors.push({ prompt, message, details });
}

// Pad/trim the name so they're all the same length.
const name = this.trimString(
prompt.name.padEnd(PREFIX_WIDTH, ' '),
Expand Down