Skip to content

Commit

Permalink
feat[js]: add view URL to the experiment when running evaluate (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
agola11 authored May 14, 2024
2 parents 3931522 + fb41a51 commit 4e51847
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
15 changes: 15 additions & 0 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
if (this._tenantId !== null) {
return this._tenantId;
Expand Down
14 changes: 11 additions & 3 deletions js/src/evaluation/_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,24 @@ class _ExperimentManager {
return project;
}

_printExperimentStart(): void {
// @TODO log with experiment URL
protected async _printExperimentStart(): Promise<void> {
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();
return new _ExperimentManager({
examples,
experiment: project,
Expand Down

0 comments on commit 4e51847

Please sign in to comment.