-
Notifications
You must be signed in to change notification settings - Fork 443
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
fix: check if parameter references exist in experiment parameters #1726
fix: check if parameter references exist in experiment parameters #1726
Conversation
Hi @henrysecond1. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: henrysecond1 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Thank you for such a nice contribution :) I think this feature helps many others
// Check if parameter references exist in experiment parameters | ||
if _, ok := experimentParameterNames[parameter.Reference]; !ok { | ||
return fmt.Errorf("parameter reference %v does not exists in spec.Parameters: %v", parameter.Reference, instance.Spec.Parameters) | ||
} |
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.
IMHO, How about move these codes after
trialParametersNames[parameter.Name] = true
trialParametersRefs[parameter.Reference] = true
It may not important, but I feel like these should be right after codes right after checking duplicates.
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.
Thanks for the suggestion, done :)
@@ -283,6 +288,10 @@ func (g *DefaultValidator) validateTrialTemplate(instance *experimentsv1beta1.Ex | |||
if _, ok := trialParametersRefs[parameter.Reference]; ok { | |||
return fmt.Errorf("parameter reference %v can't be duplicated in spec.trialTemplate.trialParameters: %v", parameter.Reference, trialTemplate.TrialParameters) | |||
} | |||
// Check if parameter references exist in experiment parameters | |||
if _, ok := experimentParameterNames[parameter.Reference]; !ok { | |||
return fmt.Errorf("parameter reference %v does not exists in spec.Parameters: %v", parameter.Reference, instance.Spec.Parameters) |
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.
nit: does not exist
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
@@ -283,6 +288,10 @@ func (g *DefaultValidator) validateTrialTemplate(instance *experimentsv1beta1.Ex | |||
if _, ok := trialParametersRefs[parameter.Reference]; ok { | |||
return fmt.Errorf("parameter reference %v can't be duplicated in spec.trialTemplate.trialParameters: %v", parameter.Reference, trialTemplate.TrialParameters) | |||
} | |||
// Check if parameter references exist in experiment parameters |
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.
nit: parameter reference exist
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
// Wrong parameter reference in trialParameters | ||
{ | ||
Instance: func() *experimentsv1beta1.Experiment { | ||
i := newFakeInstance() | ||
i.Spec.TrialTemplate.TrialParameters[1].Reference = "wrong-ref" | ||
return i | ||
}(), | ||
Err: true, | ||
testDescription: "Wrong reference in Trial parameters", | ||
}, |
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.
nit: How about make this test case as invalidReferenceParameterTemplate
or unknownReferenceParameterTemplate
rather than validTemplate5
?
Also, how about more detailed description? something like Trial template contains Trial Parameters which weren't referenced from spec.parameters
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.
I don't like the name validTemplate5
either and I agree that invalidReferenceParameterTemplate
is better.. but I guess that some rules are applied to mock template names (maybe I misunderstood it?).
- Mock templates with name
validTemplate*
have a valid job, while mock templates with specific names likemissedParameterTemplate
,invalidParameterTemplate
have a invalid job.
So I named it as a validTemplate5
(since it has a valid job)... Please let me know if you still think it's better to name it as invalidReferenceParameterTemplate
instead of validTemplate5
?
I changed the description as you suggested, thanks :)
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.
Since the validation logic was changed to check only it's empty, maybe we could change the test code :)
And in that case, yes the variable name validTemplate5
would be better.
/ok-to-test |
@anencore94 Thanks for the review! PTAL |
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.
Thank you for driving this @henrysecond1!
I left comment.
if _, ok := experimentParameterNames[parameter.Reference]; !ok { | ||
return fmt.Errorf("parameter reference %v does not exist in spec.parameters: %v", parameter.Reference, instance.Spec.Parameters) | ||
} |
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.
I think for NAS Experiments that doesn't work.
For example, for the ENAS Experiment, the Suggestion returns architecture
and nn_config
which don't exist in spec.Parameters
.
For HP Experiments, currently all parameters that Suggestions return exist in spec.parameters
, but I am not sure if for other AutoML techniques that always be true (for example for PBT, AutoMC, etc.).
I think for now, we can check if experimentParameterNames
is not empty than we can apply this check.
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.
SGTM!
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.
@andreyvelich Thank you for pointing it out. Sounds good to me, too :)
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.
Yes that make sense ! Thanks
@anencore94 @andreyvelich I updated the test code (for the case when |
Thank you for updating this @henrysecond1! |
/lgtm |
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gaocegege, henrysecond1 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 |
What this PR does / why we need it:
Hi, we experienced that the users tend to make mistakes like below when creating experiments using new UI (Thanks for the nice UI update!)
When users set parameter references in trial templates like below,
they need to enter the parameter reference as same as the hyperparameter defined in the experiment spec.
The experiment is created without errors even if the users mistakenly set the wrong parameter reference.
I think it would be better to check the wrong parameter reference in the validating webhook
so that experiments are not created with the wrong parameter reference.
Please take a look, thanks!