From 6a2252b02eeb0a7599a675e5acfd1cf257a8c3d5 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Tue, 14 May 2024 16:39:00 +0200 Subject: [PATCH 1/2] feat[js]: add view URL to the experiment when running evaluate --- js/src/client.ts | 15 +++++++++++++++ js/src/evaluation/_runner.ts | 14 +++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/js/src/client.ts b/js/src/client.ts index bcad8eaca..cfbd869da 100644 --- a/js/src/client.ts +++ b/js/src/client.ts @@ -1597,6 +1597,21 @@ export class Client { return `${this.getHostUrl()}/o/${tenantId}/projects/p/${project.id}`; } + public async getDatasetUrl({ + datasetId, + datasetName, + }: { + datasetId?: string; + datasetName?: string; + }) { + if (datasetId === undefined && datasetName === undefined) { + throw new Error("Must provide either datasetName or datasetId"); + } + const dataset = await this.readDataset({ datasetId, datasetName }); + const tenantId = await this._getTenantId(); + return `${this.getHostUrl()}/o/${tenantId}/datasets/${dataset.id}`; + } + private async _getTenantId(): Promise { if (this._tenantId !== null) { return this._tenantId; diff --git a/js/src/evaluation/_runner.ts b/js/src/evaluation/_runner.ts index c2cc7408d..087582278 100644 --- a/js/src/evaluation/_runner.ts +++ b/js/src/evaluation/_runner.ts @@ -319,16 +319,24 @@ class _ExperimentManager { return project; } - _printExperimentStart(): void { - // @TODO log with experiment URL + protected async _printExperimentStart(): Promise { console.log(`Starting evaluation of experiment: ${this.experimentName}`); + + const firstExample = this._examples?.[0]; + const datasetId = firstExample?.dataset_id; + if (!datasetId || !this._experiment) return; + + const datasetUrl = await this.client.getDatasetUrl({ datasetId }); + const compareUrl = `${datasetUrl}/compare?selectedSessions=${this._experiment.id}`; + + console.log(`View results at ${compareUrl}`); } async start(): Promise<_ExperimentManager> { const examples = await this.getExamples(); const firstExample = examples[0]; const project = await this._getProject(firstExample); - this._printExperimentStart(); + await this._printExperimentStart(project); return new _ExperimentManager({ examples, experiment: project, From fb41a5106a48c3a86636f0ffde042af051f91f45 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Tue, 14 May 2024 17:10:32 +0200 Subject: [PATCH 2/2] fix tsc --- js/src/evaluation/_runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/evaluation/_runner.ts b/js/src/evaluation/_runner.ts index 087582278..3c5a12799 100644 --- a/js/src/evaluation/_runner.ts +++ b/js/src/evaluation/_runner.ts @@ -336,7 +336,7 @@ class _ExperimentManager { const examples = await this.getExamples(); const firstExample = examples[0]; const project = await this._getProject(firstExample); - await this._printExperimentStart(project); + await this._printExperimentStart(); return new _ExperimentManager({ examples, experiment: project,