-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Creates a default experiment at API server set up time #1089
Conversation
…s restarted without clearing DB
…nly covers existence of default experiment
/test kubeflow-pipeline-e2e-test |
|
||
// Check the namespace have ML job installed and ready | ||
func (s *InitializationTest) SetupTest() { | ||
if !*runIntegrationTests { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
backend/src/apiserver/main.go
Outdated
@@ -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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it. Done.
backend/src/apiserver/main.go
Outdated
// 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())) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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": ""} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add your name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/lgtm |
[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 |
/test kubeflow-pipeline-e2e-test |
1 similar comment
/test kubeflow-pipeline-e2e-test |
* fix nested param generation issue * change logic to only apply to parent counter
This experiment is named
Default
and is used whenever aCreateRun
request is received without specifying a containing experiment.This change is