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

Creates a default experiment at API server set up time #1089

Merged
merged 12 commits into from
Apr 15, 2019

Conversation

rileyjbauer
Copy link
Contributor

@rileyjbauer rileyjbauer commented Apr 5, 2019

This experiment is named Default and is used whenever a CreateRun request is received without specifying a containing experiment.


This change is Reviewable

@rileyjbauer
Copy link
Contributor Author

/test kubeflow-pipeline-e2e-test

@rileyjbauer rileyjbauer changed the title [WIP] - Creates a default experiment at API server set up time Creates a default experiment at API server set up time Apr 8, 2019

// Check the namespace have ML job installed and ready
func (s *InitializationTest) SetupTest() {
if !*runIntegrationTests {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this switch?

BTW, go test supports test case regex which allows only running the tests you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevents the test from running as part of the the travis CI tests

@@ -61,6 +62,11 @@ func main() {
glog.Fatalf("Failed to load samples. Err: %v", err.Error())
}

err = createDefaultExperiment(resourceManager)
if err != nil {
glog.Fatalf("Failed to create default experiment. Err: %v", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for err.Error(), as %v format will do the right thing. err.Error() returns a string, while %v will defer to the String() call of the passed in argument. It's better to defer this to the latter. Here and elsewhere in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, got it. Done.

// First check that we don't already have a default experiment ID in the DB.
defaultExperimentId, err := resourceManager.GetDefaultExperimentId()
if err != nil {
return errors.New(fmt.Sprintf("Failed to check if default experiment exists. Err: %v", err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use fmt.Errorf instead of errors.New(fmt.Sprintf(... to achieve the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good to know!

defaultDBValue = sq.Eq{"DefaultExperimentId": ""}
)

type DefaultExperimentStoreInterface interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use this interface anywhere btw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in client_manager and resource_manager. This is what we do in all of the stores, which of course doesn't mean it's correct, but they should all be changed if it is not, and that should be a separate PR.

)

var (
defaultDBValue = sq.Eq{"DefaultExperimentId": ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe defaultExperimentDBValue (since this is shared across all files under storage)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.


func (s *DefaultExperimentStore) InitializeDefaultExperimentTable() error {
// First check that the table is in fact empty
getDefaultExperimentSql, getDefaultExperimentArgs, err := sq.Select("*").From("default_experiments").ToSql()
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use shorter names here e.g. querySql and queryArgs. Up to you.

Also, you may want to just write this as SELECT * from default_experiments. There are no parameters here, and the use of sq.select doesn't buy us anything, and probably makes it harder to read. Also, saves having to check error below, since that cannot happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I updated db_status_store as well

Copy link
Contributor

@neuromage neuromage left a comment

Choose a reason for hiding this comment

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

/lgtm

@@ -214,6 +217,31 @@ func (r *ResourceManager) CreateRun(apiRun *api.Run) (*model.RunDetail, error) {
return nil, util.NewInternalServerError(err, "Failed to create a workflow for (%s)", workflow.Name)
}

hasExperiment := false
Copy link
Member

Choose a reason for hiding this comment

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

could you move the logic here into a util function, maybe named something like setExperimentIfNotPresent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

// Implementation of a DefaultExperimentStoreInterface. This stores the default experiment's ID,
// which is created as the API server is initialized.
Copy link
Member

Choose a reason for hiding this comment

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

the first time the API server is initialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

db *DB
}

func (s *DefaultExperimentStore) InitializeDefaultExperimentTable() error {
Copy link
Member

Choose a reason for hiding this comment

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

this can be a private method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,6 @@
approvers:
Copy link
Member

Choose a reason for hiding this comment

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

add your name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@IronPan
Copy link
Member

IronPan commented Apr 15, 2019

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: IronPan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rileyjbauer
Copy link
Contributor Author

/test kubeflow-pipeline-e2e-test

1 similar comment
@rileyjbauer
Copy link
Contributor Author

/test kubeflow-pipeline-e2e-test

@k8s-ci-robot k8s-ci-robot merged commit fbae0f8 into kubeflow:master Apr 15, 2019
@rileyjbauer rileyjbauer deleted the create-default-experiment branch May 6, 2019 22:13
HumairAK pushed a commit to red-hat-data-services/data-science-pipelines that referenced this pull request Mar 11, 2024
* fix nested param generation issue

* change logic to only apply to parent counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants