|
| 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 | +} |
0 commit comments