feat(research): compare saved experiments against explicit trials
This commit is contained in:
parent
397cd0e160
commit
46a4f13acd
22 changed files with 3045 additions and 35 deletions
|
|
@ -27,6 +27,7 @@ import {
|
|||
retainedWorkbenchPreview,
|
||||
workbenchTrialRequest,
|
||||
} from './cost-sensitivity-input';
|
||||
import { compareExperiments, parseExperimentComparison } from './experiment-comparison';
|
||||
import {
|
||||
buildExperimentPreview,
|
||||
ExperimentError,
|
||||
|
|
@ -319,6 +320,30 @@ export class ExperimentsService {
|
|||
);
|
||||
return rows.rows.map(summary);
|
||||
}
|
||||
async compare(raw: unknown) {
|
||||
const input = parseExperimentComparison(raw);
|
||||
return this.database.transaction(async client => {
|
||||
await client.query('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY');
|
||||
const rows = (
|
||||
await client.query(
|
||||
'SELECT id,validation_phase FROM research_experiments WHERE id=ANY($1::uuid[])',
|
||||
[[input.leftId, input.rightId]]
|
||||
)
|
||||
).rows;
|
||||
if (rows.length !== 2) {
|
||||
throw new ExperimentError(404, 'Comparison experiment not found');
|
||||
}
|
||||
if (rows.some(row => row.validation_phase !== null)) {
|
||||
throw new ExperimentError(
|
||||
409,
|
||||
'Compare standalone experiments; chronological phases have their own workflow'
|
||||
);
|
||||
}
|
||||
const left = await this.readDetail(client, input.leftId),
|
||||
right = await this.readDetail(client, input.rightId);
|
||||
return compareExperiments(input, [left, right]);
|
||||
});
|
||||
}
|
||||
async get(id: string): Promise<WorkbenchExperimentDetail> {
|
||||
experimentId(id);
|
||||
return this.readDetail(this.database, id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue