Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experiment_rev into payload for share experiment to Studio #3499

Merged
merged 1 commit into from
Mar 18, 2023
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
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