Skip to content

Commit 3e1d5d4

Browse files
authored
set server detaults for hpo (#37)
1 parent 93f8034 commit 3e1d5d4

File tree

5 files changed

+53
-3
lines changed

5 files changed

+53
-3
lines changed

generator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ resources:
276276
- InvalidAction
277277
- UnrecognizedClientException
278278
hooks:
279+
delta_pre_compare:
280+
code: customSetDefaults(a, b)
279281
sdk_delete_pre_build_request:
280282
template_path: hyper_parameter_tuning_job/sdk_delete_pre_build_request.go.tpl
281283
sdk_create_post_set_output:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/aws-controllers-k8s/sagemaker-controller
33
go 1.14
44

55
require (
6-
github.com/aws-controllers-k8s/runtime v0.2.0
6+
github.com/aws-controllers-k8s/runtime v0.2.1-0.20210527234121-a3e2184a6be7
77
github.com/aws/aws-sdk-go v1.38.11
88
github.com/go-logr/logr v0.1.0
99
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo
2323
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
2424
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
2525
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
26-
github.com/aws-controllers-k8s/runtime v0.2.0 h1:gd0Kq8xGelgkZoNjr8yZbHfpvPA1R+wfMCi1lT4H8x4=
27-
github.com/aws-controllers-k8s/runtime v0.2.0/go.mod h1:xA2F18PJerBHaqrS4de1lpP7skeSMeStkmh+3x5sWvw=
26+
github.com/aws-controllers-k8s/runtime v0.2.1-0.20210527234121-a3e2184a6be7 h1:BbMM37IAVNctZdtkL0clsl5KbKtOyLWPWaFvS+tdhlA=
27+
github.com/aws-controllers-k8s/runtime v0.2.1-0.20210527234121-a3e2184a6be7/go.mod h1:xA2F18PJerBHaqrS4de1lpP7skeSMeStkmh+3x5sWvw=
2828
github.com/aws/aws-sdk-go v1.37.4 h1:tWxrpMK/oRSXVnjUzhGeCWLR00fW0WF4V4sycYPPrJ8=
2929
github.com/aws/aws-sdk-go v1.37.4/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
3030
github.com/aws/aws-sdk-go v1.38.11 h1:jmxKh557ZRc+Z8fALnGrL01Ctjks2aSUFLb7n/BZoEs=
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
// not use this file except in compliance with the License. A copy of the
5+
// License is located at
6+
//
7+
// http://aws.amazon.com/apache2.0/
8+
//
9+
// or in the "license" file accompanying this file. This file is distributed
10+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
// express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
package hyper_parameter_tuning_job
15+
16+
import (
17+
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
18+
)
19+
20+
func customSetDefaults(
21+
a *resource,
22+
b *resource,
23+
) {
24+
if ackcompare.IsNotNil(a.ko.Spec.TrainingJobDefinition) && ackcompare.IsNotNil(b.ko.Spec.TrainingJobDefinition) {
25+
// SageMaker adds StaticHyperParameters prefixed with an underscore. We must ignore these when comparing.
26+
latestStaticHyperParameters := b.ko.Spec.TrainingJobDefinition.StaticHyperParameters
27+
if ackcompare.IsNotNil(latestStaticHyperParameters) {
28+
for key, _ := range latestStaticHyperParameters {
29+
if key[0:1] == "_" {
30+
delete(b.ko.Spec.TrainingJobDefinition.StaticHyperParameters, key)
31+
}
32+
}
33+
}
34+
35+
if ackcompare.IsNil(a.ko.Spec.TrainingJobDefinition.EnableManagedSpotTraining) && ackcompare.IsNotNil(b.ko.Spec.TrainingJobDefinition.EnableManagedSpotTraining) {
36+
a.ko.Spec.TrainingJobDefinition.EnableManagedSpotTraining = b.ko.Spec.TrainingJobDefinition.EnableManagedSpotTraining
37+
}
38+
39+
if ackcompare.IsNil(a.ko.Spec.TrainingJobDefinition.EnableNetworkIsolation) && ackcompare.IsNotNil(b.ko.Spec.TrainingJobDefinition.EnableNetworkIsolation) {
40+
a.ko.Spec.TrainingJobDefinition.EnableNetworkIsolation = b.ko.Spec.TrainingJobDefinition.EnableNetworkIsolation
41+
}
42+
43+
if ackcompare.IsNil(a.ko.Spec.TrainingJobDefinition.EnableInterContainerTrafficEncryption) && ackcompare.IsNotNil(b.ko.Spec.TrainingJobDefinition.EnableInterContainerTrafficEncryption) {
44+
a.ko.Spec.TrainingJobDefinition.EnableInterContainerTrafficEncryption = b.ko.Spec.TrainingJobDefinition.EnableInterContainerTrafficEncryption
45+
}
46+
}
47+
}

pkg/resource/hyper_parameter_tuning_job/delta.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)