{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SageMaker.Types.HyperParameterTuningInstanceConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.HyperParameterTuningInstanceConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.TrainingInstanceType

-- | The configuration for hyperparameter tuning resources for use in
-- training jobs launched by the tuning job. These resources include
-- compute instances and storage volumes. Specify one or more compute
-- instance configurations and allocation strategies to select resources
-- (optional).
--
-- /See:/ 'newHyperParameterTuningInstanceConfig' smart constructor.
data HyperParameterTuningInstanceConfig = HyperParameterTuningInstanceConfig'
  { -- | The instance type used for processing of hyperparameter optimization
    -- jobs. Choose from general purpose (no GPUs) instance types:
    -- ml.m5.xlarge, ml.m5.2xlarge, and ml.m5.4xlarge or compute optimized (no
    -- GPUs) instance types: ml.c5.xlarge and ml.c5.2xlarge. For more
    -- information about instance types, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/notebooks-available-instance-types.html instance type descriptions>.
    HyperParameterTuningInstanceConfig -> TrainingInstanceType
instanceType :: TrainingInstanceType,
    -- | The number of instances of the type specified by @InstanceType@. Choose
    -- an instance count larger than 1 for distributed training algorithms. See
    -- <https://docs.aws.amazon.com/data-parallel-use-api.html SageMaker distributed training jobs>
    -- for more informcration.
    HyperParameterTuningInstanceConfig -> Natural
instanceCount :: Prelude.Natural,
    -- | The volume size in GB of the data to be processed for hyperparameter
    -- optimization (optional).
    HyperParameterTuningInstanceConfig -> Natural
volumeSizeInGB :: Prelude.Natural
  }
  deriving (HyperParameterTuningInstanceConfig
-> HyperParameterTuningInstanceConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterTuningInstanceConfig
-> HyperParameterTuningInstanceConfig -> Bool
$c/= :: HyperParameterTuningInstanceConfig
-> HyperParameterTuningInstanceConfig -> Bool
== :: HyperParameterTuningInstanceConfig
-> HyperParameterTuningInstanceConfig -> Bool
$c== :: HyperParameterTuningInstanceConfig
-> HyperParameterTuningInstanceConfig -> Bool
Prelude.Eq, ReadPrec [HyperParameterTuningInstanceConfig]
ReadPrec HyperParameterTuningInstanceConfig
Int -> ReadS HyperParameterTuningInstanceConfig
ReadS [HyperParameterTuningInstanceConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterTuningInstanceConfig]
$creadListPrec :: ReadPrec [HyperParameterTuningInstanceConfig]
readPrec :: ReadPrec HyperParameterTuningInstanceConfig
$creadPrec :: ReadPrec HyperParameterTuningInstanceConfig
readList :: ReadS [HyperParameterTuningInstanceConfig]
$creadList :: ReadS [HyperParameterTuningInstanceConfig]
readsPrec :: Int -> ReadS HyperParameterTuningInstanceConfig
$creadsPrec :: Int -> ReadS HyperParameterTuningInstanceConfig
Prelude.Read, Int -> HyperParameterTuningInstanceConfig -> ShowS
[HyperParameterTuningInstanceConfig] -> ShowS
HyperParameterTuningInstanceConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterTuningInstanceConfig] -> ShowS
$cshowList :: [HyperParameterTuningInstanceConfig] -> ShowS
show :: HyperParameterTuningInstanceConfig -> String
$cshow :: HyperParameterTuningInstanceConfig -> String
showsPrec :: Int -> HyperParameterTuningInstanceConfig -> ShowS
$cshowsPrec :: Int -> HyperParameterTuningInstanceConfig -> ShowS
Prelude.Show, forall x.
Rep HyperParameterTuningInstanceConfig x
-> HyperParameterTuningInstanceConfig
forall x.
HyperParameterTuningInstanceConfig
-> Rep HyperParameterTuningInstanceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HyperParameterTuningInstanceConfig x
-> HyperParameterTuningInstanceConfig
$cfrom :: forall x.
HyperParameterTuningInstanceConfig
-> Rep HyperParameterTuningInstanceConfig x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterTuningInstanceConfig' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'instanceType', 'hyperParameterTuningInstanceConfig_instanceType' - The instance type used for processing of hyperparameter optimization
-- jobs. Choose from general purpose (no GPUs) instance types:
-- ml.m5.xlarge, ml.m5.2xlarge, and ml.m5.4xlarge or compute optimized (no
-- GPUs) instance types: ml.c5.xlarge and ml.c5.2xlarge. For more
-- information about instance types, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/notebooks-available-instance-types.html instance type descriptions>.
--
-- 'instanceCount', 'hyperParameterTuningInstanceConfig_instanceCount' - The number of instances of the type specified by @InstanceType@. Choose
-- an instance count larger than 1 for distributed training algorithms. See
-- <https://docs.aws.amazon.com/data-parallel-use-api.html SageMaker distributed training jobs>
-- for more informcration.
--
-- 'volumeSizeInGB', 'hyperParameterTuningInstanceConfig_volumeSizeInGB' - The volume size in GB of the data to be processed for hyperparameter
-- optimization (optional).
newHyperParameterTuningInstanceConfig ::
  -- | 'instanceType'
  TrainingInstanceType ->
  -- | 'instanceCount'
  Prelude.Natural ->
  -- | 'volumeSizeInGB'
  Prelude.Natural ->
  HyperParameterTuningInstanceConfig
newHyperParameterTuningInstanceConfig :: TrainingInstanceType
-> Natural -> Natural -> HyperParameterTuningInstanceConfig
newHyperParameterTuningInstanceConfig
  TrainingInstanceType
pInstanceType_
  Natural
pInstanceCount_
  Natural
pVolumeSizeInGB_ =
    HyperParameterTuningInstanceConfig'
      { $sel:instanceType:HyperParameterTuningInstanceConfig' :: TrainingInstanceType
instanceType =
          TrainingInstanceType
pInstanceType_,
        $sel:instanceCount:HyperParameterTuningInstanceConfig' :: Natural
instanceCount = Natural
pInstanceCount_,
        $sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: Natural
volumeSizeInGB = Natural
pVolumeSizeInGB_
      }

-- | The instance type used for processing of hyperparameter optimization
-- jobs. Choose from general purpose (no GPUs) instance types:
-- ml.m5.xlarge, ml.m5.2xlarge, and ml.m5.4xlarge or compute optimized (no
-- GPUs) instance types: ml.c5.xlarge and ml.c5.2xlarge. For more
-- information about instance types, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/notebooks-available-instance-types.html instance type descriptions>.
hyperParameterTuningInstanceConfig_instanceType :: Lens.Lens' HyperParameterTuningInstanceConfig TrainingInstanceType
hyperParameterTuningInstanceConfig_instanceType :: Lens' HyperParameterTuningInstanceConfig TrainingInstanceType
hyperParameterTuningInstanceConfig_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningInstanceConfig' {TrainingInstanceType
instanceType :: TrainingInstanceType
$sel:instanceType:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> TrainingInstanceType
instanceType} -> TrainingInstanceType
instanceType) (\s :: HyperParameterTuningInstanceConfig
s@HyperParameterTuningInstanceConfig' {} TrainingInstanceType
a -> HyperParameterTuningInstanceConfig
s {$sel:instanceType:HyperParameterTuningInstanceConfig' :: TrainingInstanceType
instanceType = TrainingInstanceType
a} :: HyperParameterTuningInstanceConfig)

-- | The number of instances of the type specified by @InstanceType@. Choose
-- an instance count larger than 1 for distributed training algorithms. See
-- <https://docs.aws.amazon.com/data-parallel-use-api.html SageMaker distributed training jobs>
-- for more informcration.
hyperParameterTuningInstanceConfig_instanceCount :: Lens.Lens' HyperParameterTuningInstanceConfig Prelude.Natural
hyperParameterTuningInstanceConfig_instanceCount :: Lens' HyperParameterTuningInstanceConfig Natural
hyperParameterTuningInstanceConfig_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningInstanceConfig' {Natural
instanceCount :: Natural
$sel:instanceCount:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
instanceCount} -> Natural
instanceCount) (\s :: HyperParameterTuningInstanceConfig
s@HyperParameterTuningInstanceConfig' {} Natural
a -> HyperParameterTuningInstanceConfig
s {$sel:instanceCount:HyperParameterTuningInstanceConfig' :: Natural
instanceCount = Natural
a} :: HyperParameterTuningInstanceConfig)

-- | The volume size in GB of the data to be processed for hyperparameter
-- optimization (optional).
hyperParameterTuningInstanceConfig_volumeSizeInGB :: Lens.Lens' HyperParameterTuningInstanceConfig Prelude.Natural
hyperParameterTuningInstanceConfig_volumeSizeInGB :: Lens' HyperParameterTuningInstanceConfig Natural
hyperParameterTuningInstanceConfig_volumeSizeInGB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningInstanceConfig' {Natural
volumeSizeInGB :: Natural
$sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
volumeSizeInGB} -> Natural
volumeSizeInGB) (\s :: HyperParameterTuningInstanceConfig
s@HyperParameterTuningInstanceConfig' {} Natural
a -> HyperParameterTuningInstanceConfig
s {$sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: Natural
volumeSizeInGB = Natural
a} :: HyperParameterTuningInstanceConfig)

instance
  Data.FromJSON
    HyperParameterTuningInstanceConfig
  where
  parseJSON :: Value -> Parser HyperParameterTuningInstanceConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HyperParameterTuningInstanceConfig"
      ( \Object
x ->
          TrainingInstanceType
-> Natural -> Natural -> HyperParameterTuningInstanceConfig
HyperParameterTuningInstanceConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"InstanceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"InstanceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"VolumeSizeInGB")
      )

instance
  Prelude.Hashable
    HyperParameterTuningInstanceConfig
  where
  hashWithSalt :: Int -> HyperParameterTuningInstanceConfig -> Int
hashWithSalt
    Int
_salt
    HyperParameterTuningInstanceConfig' {Natural
TrainingInstanceType
volumeSizeInGB :: Natural
instanceCount :: Natural
instanceType :: TrainingInstanceType
$sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceCount:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceType:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> TrainingInstanceType
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TrainingInstanceType
instanceType
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
instanceCount
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
volumeSizeInGB

instance
  Prelude.NFData
    HyperParameterTuningInstanceConfig
  where
  rnf :: HyperParameterTuningInstanceConfig -> ()
rnf HyperParameterTuningInstanceConfig' {Natural
TrainingInstanceType
volumeSizeInGB :: Natural
instanceCount :: Natural
instanceType :: TrainingInstanceType
$sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceCount:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceType:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> TrainingInstanceType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf TrainingInstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
volumeSizeInGB

instance
  Data.ToJSON
    HyperParameterTuningInstanceConfig
  where
  toJSON :: HyperParameterTuningInstanceConfig -> Value
toJSON HyperParameterTuningInstanceConfig' {Natural
TrainingInstanceType
volumeSizeInGB :: Natural
instanceCount :: Natural
instanceType :: TrainingInstanceType
$sel:volumeSizeInGB:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceCount:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> Natural
$sel:instanceType:HyperParameterTuningInstanceConfig' :: HyperParameterTuningInstanceConfig -> TrainingInstanceType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"InstanceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TrainingInstanceType
instanceType),
            forall a. a -> Maybe a
Prelude.Just (Key
"InstanceCount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
instanceCount),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"VolumeSizeInGB" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
volumeSizeInGB)
          ]
      )