Skip to content

Commit

Permalink
Add experiment_rev into payload for share experiment to Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
mattseddon committed Mar 18, 2023
1 parent baf3ea7 commit 248cfb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 12 additions & 8 deletions extension/src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const STUDIO_ENDPOINT = 'https://studio.iterative.ai/api/live'

type ExperimentDetails = {
baselineSha: string
sha: string
metrics: ValueTreeRoot | undefined
name: string
params: ValueTreeRoot
Expand All @@ -29,6 +30,7 @@ type RequestBody = {
repo_url: string
name: string
baseline_sha: string
experiment_rev: string
metrics: ValueTreeRoot
params: ValueTreeRoot
type: 'done'
Expand All @@ -50,22 +52,23 @@ const collectExperiment = (data: ExperimentFields) => {

const findExperimentByName = (
name: string,
sha: string,
baselineSha: string,
experimentsObject: ExperimentsCommitOutput
) => {
for (const experiment of Object.values(experimentsObject)) {
if (experiment.data?.name !== name) {
for (const [sha, { data }] of Object.entries(experimentsObject)) {
if (data?.name !== name) {
continue
}

if (experiment?.data) {
const { metrics, params } = collectExperiment(experiment.data)
if (data) {
const { metrics, params } = collectExperiment(data)

return {
baselineSha: sha,
baselineSha,
metrics,
name,
params
params,
sha
}
}
}
Expand Down Expand Up @@ -114,7 +117,7 @@ const shareWithProgress = (
studioAccessToken: string
): Thenable<unknown> =>
Toast.showProgress('Sharing Experiment', async progress => {
const { metrics, params, baselineSha, name } = experimentDetails
const { metrics, params, baselineSha, sha, name } = experimentDetails

progress.report({
increment: 0,
Expand All @@ -125,6 +128,7 @@ const shareWithProgress = (
const response = await sendPostRequest(studioAccessToken, {
baseline_sha: baselineSha,
client: 'vscode',
experiment_rev: sha,
metrics: metrics || {},
name,
params: params || {},
Expand Down
2 changes: 2 additions & 0 deletions extension/src/test/suite/patch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ suite('Patch Test Suite', () => {
body: JSON.stringify({
baseline_sha: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77',
client: 'vscode',
experiment_rev: '4fb124aebddb2adf1545030907687fa9a4c80e70',
metrics,
name,
params: {
Expand Down Expand Up @@ -133,6 +134,7 @@ suite('Patch Test Suite', () => {
body: JSON.stringify({
baseline_sha: '53c3851f46955fa3e2b8f6e1c52999acc8c9ea77',
client: 'vscode',
experiment_rev: '4fb124aebddb2adf1545030907687fa9a4c80e70',
metrics,
name,
params: {
Expand Down

0 comments on commit 248cfb5

Please sign in to comment.