Skip to content

feat: model experiments wait handler#7800

Open
paul-sffrth wants to merge 5 commits into
stackitcloud:mainfrom
paul-sffrth:feature/mexp-wait-handler
Open

feat: model experiments wait handler#7800
paul-sffrth wants to merge 5 commits into
stackitcloud:mainfrom
paul-sffrth:feature/mexp-wait-handler

Conversation

@paul-sffrth

@paul-sffrth paul-sffrth commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

Wait handlers for model experiments

Checklist

  • Issue was linked above
  • No generated code was adjusted manually (check comments in file header)
  • Changelogs
    • Changelog in the root directory was adjusted (see here)
    • Changelog(s) of the service(s) were adjusted (see e.g. here)
  • VERSION file(s) of the service(s) were adjusted
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Unit tests got implemented or updated
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@paul-sffrth paul-sffrth requested a review from a team as a code owner June 10, 2026 11:21
)

// CreateMExpInstanceWaitHandler will wait for creation of Model Experiments instance
func CreateMExpInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func CreateMExpInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {
func CreateModelExperimentsInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the comment above

ActiveState: []modelexperiments.InstanceState{modelexperiments.INSTANCESTATE_ACTIVE},
ErrorState: []modelexperiments.InstanceState{modelexperiments.INSTANCESTATE_IMPAIRED},
}
handler := wait.New(waitConfig.Wait())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handler := wait.New(waitConfig.Wait())
handler := wait.New(waitConfig.Wait())
handler.SetTimeout(10 * time.Minute)
return handler

}

// DeleteMExpInstanceWaitHandler will wait for deletion of Model Experiments instance
func DeleteMExpInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func DeleteMExpInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {
func DeleteModelExperimentsInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {

},
DeleteHttpErrorStatusCodes: []int{http.StatusNotFound},
}
handler := wait.New(waitConfig.Wait())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like mentioned in create function, please group handler and following lines together.

}

// CreateMExpTokenWait Handler will wait for creation of Model Experiments instance token
func CreateMExpInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func CreateMExpInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {
func CreateModelExperimentsInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {

ActiveState: []modelexperiments.TokenState{modelexperiments.TOKENSTATE_ACTIVE},
ErrorState: []modelexperiments.TokenState{},
}
handler := wait.New(waitConfig.Wait())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

}

// DeleteMExpInstanceTokenWaitHandler will wait for deletion of Model Experiments instance token
func DeleteMExpInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func DeleteMExpInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {
func DeleteModelExperimentsInstanceTokenWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId, tokenId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceTokenResponse] {

},
DeleteHttpErrorStatusCodes: []int{http.StatusNotFound},
}
handler := wait.New(waitConfig.Wait())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}
}

func TestCreateMExpInstanceWaitHandler(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adapt test names also


modelexperimentsClient, err := modelexperiments.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
fmt.Fprintf(os.Stderr, "[Model Experiments] Creating API client: %v\n", err)

os.Exit(1)
}

// Create a instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create a instance
// Create an instance

Comment thread examples/modelexperiments/modelexperiments.go
createTokenPayload := modelexperiments.CreateInstanceTokenPayload{
Name: "token-name",
}
createTokenResp, err := modelexperimentsClient.DefaultAPI.CreateInstanceToken(context.Background(), projectId, region, createInstanceResp.Instance.Id).CreateInstanceTokenPayload(createTokenPayload).Execute()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait handler is missing also in here.

Comment thread examples/modelexperiments/modelexperiments.go
@GokceGK

GokceGK commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution.

Notice.txt is not part of this PR, but I just recognized a point in there.

Can you please change the first line to

STACKIT Model Experiments SDK for Go

Comment thread examples/modelexperiments/modelexperiments.go
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `GetInstance`: %v\n", err)
} else {
fmt.Printf("Retrieved instance: %+v\n", getInstanceResp.Instance)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe instead of printing whole instance, you can print 1-2 fields like name and description to increase output readability. As some printed fields are just nil or addresses.

os.Exit(1)
}

// Create an Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create an Model Experiments Instance
// Create a Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick :)

if err != nil {
fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `CreateInstance`: %v\n", err)
} else {
fmt.Printf("[Model Experiments] Created Model Experiments Instance with ID: \"%s\".\n", createInstanceResp.Instance.Id)

@GokceGK GokceGK Jun 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("[Model Experiments] Created Model Experiments Instance with ID: \"%s\".\n", createInstanceResp.Instance.Id)
fmt.Printf("[Model Experiments] Triggered creation of Model Experiments Instance with ID: \"%s\".\n", createInstanceResp.Instance.Id)

}
createInstanceResp, err := modelexperimentsClient.DefaultAPI.CreateInstance(ctx, projectId, region).CreateInstancePayload(createInstancePayload).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `CreateInstance`: %v\n", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should either use log.Fatalf instead of fmt.Fprintf or use os.Exit(1) wherever you get an error.

This comment is valid also for the rest of the file.

fmt.Printf("[Model Experiments] Retrieved %d instances\n", len(listInstaceResp.Instances))
}

// Update an Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Update an Model Experiments Instance
// Update a Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick

}

// List Model Experiments Instances
listInstaceResp, err := modelexperimentsClient.DefaultAPI.ListInstances(ctx, projectId, region).Execute()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
listInstaceResp, err := modelexperimentsClient.DefaultAPI.ListInstances(ctx, projectId, region).Execute()
listInstanceResp, err := modelexperimentsClient.DefaultAPI.ListInstances(ctx, projectId, region).Execute()

fmt.Printf("[Model Experiments] Retrieved Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", getInstanceResp.Instance.Id, getInstanceResp.Instance.Name)
}

// List Model Experiments Instances

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Printf("[Model Experiments] Listing Model Experiments instances.\n")

fmt.Printf("[Model Experiments] Retrieved %d instances\n", len(listInstaceResp.Instances))
}

// Update an Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Printf("[Model Experiments] Updating Model Experiments Instance.\n")

fmt.Printf("[Model Experiments] Updated Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", partialUpdateInstanceResp.Instance.Id, partialUpdateInstanceResp.Instance.Name)
}

// Delete an Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Delete an Model Experiments Instance
// Delete a Model Experiments Instance

if err != nil {
fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `DeleteInstance`: %v\n", err)
} else {
fmt.Printf("[Model Experiments] Deleted Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", deleteInstanceResp.Instance.Id, deleteInstanceResp.Instance.Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("[Model Experiments] Deleted Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", deleteInstanceResp.Instance.Id, deleteInstanceResp.Instance.Name)
fmt.Printf("[Model Experiments] Triggered deletion of Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", deleteInstanceResp.Instance.Id, deleteInstanceResp.Instance.Name)

fmt.Printf("[Model Experiments] Updated Model Experiments Instance with ID: \"%s\" and display name: \"%s\"\n", partialUpdateInstanceResp.Instance.Id, partialUpdateInstanceResp.Instance.Name)
}

// Delete an Model Experiments Instance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should delete the instance at the end of the script, after you delete the token.
Otherwise, this will cause error.

[Model Experiments] Error when calling `CreateToken`: 404 Not Found, status code 404, Body: {"code":404,"message":"mlflow service not available: instance not found","status":"Not Found"}

panic: runtime error: invalid memory address or nil pointer dereference

if err != nil {
fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `CreateToken`: %v\n", err)
} else {
fmt.Printf("[Model Experiments] Created Model Experiments Instance Token: %+v\n", createTokenResp.Token)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("[Model Experiments] Created Model Experiments Instance Token: %+v\n", createTokenResp.Token)
fmt.Printf("[Model Experiments] Triggered creation of Model Experiments Instance Token: %+v\n", createTokenResp.Token)

}
fmt.Printf("[Model Experiments] Model Experiments Instance \"%s\" has been successfully deleted.\n", deleteInstanceResp.Instance.Id)

// Create an Model Experiments Instance Token

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create an Model Experiments Instance Token
// Create a Model Experiments Instance Token

fmt.Printf("[Model Experiments] Retrieved %d instance tokens\n", len(listTokenResp.Tokens))
}

// Update an Model Experiments Instance Token

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Update an Model Experiments Instance Token
// Update a Model Experiments Instance Token

fmt.Printf("[Model Experiments] Updated Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", partialUpdateTokenResp.Token.Id, partialUpdateTokenResp.Token.Name)
}

// Delete an Model Experiments Instance Token

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Delete an Model Experiments Instance Token
// Delete a Model Experiments Instance Token

if err != nil {
fmt.Fprintf(os.Stderr, "[Model Experiments] Error when calling `DeleteInstanceToken`: %v\n", err)
} else {
fmt.Printf("[Model Experiments] Deleted Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", deleteTokenResp.Token.Id, deleteTokenResp.Token.Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("[Model Experiments] Deleted Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", deleteTokenResp.Token.Id, deleteTokenResp.Token.Name)
fmt.Printf("[Model Experiments] Triggered deletion of Model Experiments Instance Token with ID: \"%s\" and display name: \"%s\"\n", deleteTokenResp.Token.Id, deleteTokenResp.Token.Name)

)

// CreateModelExperimentsInstanceWaitHandler will wait for creation of Model Experiments instance
func CreateModelExperimentsInstanceWaitHandler(ctx context.Context, a modelexperiments.DefaultAPI, region, projectId, instanceId string) *wait.AsyncActionHandler[modelexperiments.GetInstanceResponse] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking if it is better to remove the ModelExperiments completely from the function name.

CreateInstanceWaitHandler
DeleteInstanceWaitHandler
CreateInstanceTokenWaitHandler
DeleteInstanceTokenWaitHandler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marceljk what do you think? Is it better without service name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants