{-# 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.DebugHookConfig
-- 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.DebugHookConfig 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.CollectionConfiguration

-- | Configuration information for the Amazon SageMaker Debugger hook
-- parameters, metric and tensor collections, and storage paths. To learn
-- more about how to configure the @DebugHookConfig@ parameter, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-createtrainingjob-api.html Use the SageMaker and Debugger Configuration API Operations to Create, Update, and Debug Your Training Job>.
--
-- /See:/ 'newDebugHookConfig' smart constructor.
data DebugHookConfig = DebugHookConfig'
  { -- | Configuration information for Amazon SageMaker Debugger tensor
    -- collections. To learn more about how to configure the
    -- @CollectionConfiguration@ parameter, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-createtrainingjob-api.html Use the SageMaker and Debugger Configuration API Operations to Create, Update, and Debug Your Training Job>.
    DebugHookConfig -> Maybe [CollectionConfiguration]
collectionConfigurations :: Prelude.Maybe [CollectionConfiguration],
    -- | Configuration information for the Amazon SageMaker Debugger hook
    -- parameters.
    DebugHookConfig -> Maybe (HashMap Text Text)
hookParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Path to local storage location for metrics and tensors. Defaults to
    -- @\/opt\/ml\/output\/tensors\/@.
    DebugHookConfig -> Maybe Text
localPath :: Prelude.Maybe Prelude.Text,
    -- | Path to Amazon S3 storage location for metrics and tensors.
    DebugHookConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (DebugHookConfig -> DebugHookConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DebugHookConfig -> DebugHookConfig -> Bool
$c/= :: DebugHookConfig -> DebugHookConfig -> Bool
== :: DebugHookConfig -> DebugHookConfig -> Bool
$c== :: DebugHookConfig -> DebugHookConfig -> Bool
Prelude.Eq, ReadPrec [DebugHookConfig]
ReadPrec DebugHookConfig
Int -> ReadS DebugHookConfig
ReadS [DebugHookConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DebugHookConfig]
$creadListPrec :: ReadPrec [DebugHookConfig]
readPrec :: ReadPrec DebugHookConfig
$creadPrec :: ReadPrec DebugHookConfig
readList :: ReadS [DebugHookConfig]
$creadList :: ReadS [DebugHookConfig]
readsPrec :: Int -> ReadS DebugHookConfig
$creadsPrec :: Int -> ReadS DebugHookConfig
Prelude.Read, Int -> DebugHookConfig -> ShowS
[DebugHookConfig] -> ShowS
DebugHookConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DebugHookConfig] -> ShowS
$cshowList :: [DebugHookConfig] -> ShowS
show :: DebugHookConfig -> String
$cshow :: DebugHookConfig -> String
showsPrec :: Int -> DebugHookConfig -> ShowS
$cshowsPrec :: Int -> DebugHookConfig -> ShowS
Prelude.Show, forall x. Rep DebugHookConfig x -> DebugHookConfig
forall x. DebugHookConfig -> Rep DebugHookConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DebugHookConfig x -> DebugHookConfig
$cfrom :: forall x. DebugHookConfig -> Rep DebugHookConfig x
Prelude.Generic)

-- |
-- Create a value of 'DebugHookConfig' 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:
--
-- 'collectionConfigurations', 'debugHookConfig_collectionConfigurations' - Configuration information for Amazon SageMaker Debugger tensor
-- collections. To learn more about how to configure the
-- @CollectionConfiguration@ parameter, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-createtrainingjob-api.html Use the SageMaker and Debugger Configuration API Operations to Create, Update, and Debug Your Training Job>.
--
-- 'hookParameters', 'debugHookConfig_hookParameters' - Configuration information for the Amazon SageMaker Debugger hook
-- parameters.
--
-- 'localPath', 'debugHookConfig_localPath' - Path to local storage location for metrics and tensors. Defaults to
-- @\/opt\/ml\/output\/tensors\/@.
--
-- 's3OutputPath', 'debugHookConfig_s3OutputPath' - Path to Amazon S3 storage location for metrics and tensors.
newDebugHookConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  DebugHookConfig
newDebugHookConfig :: Text -> DebugHookConfig
newDebugHookConfig Text
pS3OutputPath_ =
  DebugHookConfig'
    { $sel:collectionConfigurations:DebugHookConfig' :: Maybe [CollectionConfiguration]
collectionConfigurations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:hookParameters:DebugHookConfig' :: Maybe (HashMap Text Text)
hookParameters = forall a. Maybe a
Prelude.Nothing,
      $sel:localPath:DebugHookConfig' :: Maybe Text
localPath = forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:DebugHookConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | Configuration information for Amazon SageMaker Debugger tensor
-- collections. To learn more about how to configure the
-- @CollectionConfiguration@ parameter, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/debugger-createtrainingjob-api.html Use the SageMaker and Debugger Configuration API Operations to Create, Update, and Debug Your Training Job>.
debugHookConfig_collectionConfigurations :: Lens.Lens' DebugHookConfig (Prelude.Maybe [CollectionConfiguration])
debugHookConfig_collectionConfigurations :: Lens' DebugHookConfig (Maybe [CollectionConfiguration])
debugHookConfig_collectionConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugHookConfig' {Maybe [CollectionConfiguration]
collectionConfigurations :: Maybe [CollectionConfiguration]
$sel:collectionConfigurations:DebugHookConfig' :: DebugHookConfig -> Maybe [CollectionConfiguration]
collectionConfigurations} -> Maybe [CollectionConfiguration]
collectionConfigurations) (\s :: DebugHookConfig
s@DebugHookConfig' {} Maybe [CollectionConfiguration]
a -> DebugHookConfig
s {$sel:collectionConfigurations:DebugHookConfig' :: Maybe [CollectionConfiguration]
collectionConfigurations = Maybe [CollectionConfiguration]
a} :: DebugHookConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Configuration information for the Amazon SageMaker Debugger hook
-- parameters.
debugHookConfig_hookParameters :: Lens.Lens' DebugHookConfig (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
debugHookConfig_hookParameters :: Lens' DebugHookConfig (Maybe (HashMap Text Text))
debugHookConfig_hookParameters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugHookConfig' {Maybe (HashMap Text Text)
hookParameters :: Maybe (HashMap Text Text)
$sel:hookParameters:DebugHookConfig' :: DebugHookConfig -> Maybe (HashMap Text Text)
hookParameters} -> Maybe (HashMap Text Text)
hookParameters) (\s :: DebugHookConfig
s@DebugHookConfig' {} Maybe (HashMap Text Text)
a -> DebugHookConfig
s {$sel:hookParameters:DebugHookConfig' :: Maybe (HashMap Text Text)
hookParameters = Maybe (HashMap Text Text)
a} :: DebugHookConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Path to local storage location for metrics and tensors. Defaults to
-- @\/opt\/ml\/output\/tensors\/@.
debugHookConfig_localPath :: Lens.Lens' DebugHookConfig (Prelude.Maybe Prelude.Text)
debugHookConfig_localPath :: Lens' DebugHookConfig (Maybe Text)
debugHookConfig_localPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugHookConfig' {Maybe Text
localPath :: Maybe Text
$sel:localPath:DebugHookConfig' :: DebugHookConfig -> Maybe Text
localPath} -> Maybe Text
localPath) (\s :: DebugHookConfig
s@DebugHookConfig' {} Maybe Text
a -> DebugHookConfig
s {$sel:localPath:DebugHookConfig' :: Maybe Text
localPath = Maybe Text
a} :: DebugHookConfig)

-- | Path to Amazon S3 storage location for metrics and tensors.
debugHookConfig_s3OutputPath :: Lens.Lens' DebugHookConfig Prelude.Text
debugHookConfig_s3OutputPath :: Lens' DebugHookConfig Text
debugHookConfig_s3OutputPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DebugHookConfig' {Text
s3OutputPath :: Text
$sel:s3OutputPath:DebugHookConfig' :: DebugHookConfig -> Text
s3OutputPath} -> Text
s3OutputPath) (\s :: DebugHookConfig
s@DebugHookConfig' {} Text
a -> DebugHookConfig
s {$sel:s3OutputPath:DebugHookConfig' :: Text
s3OutputPath = Text
a} :: DebugHookConfig)

instance Data.FromJSON DebugHookConfig where
  parseJSON :: Value -> Parser DebugHookConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DebugHookConfig"
      ( \Object
x ->
          Maybe [CollectionConfiguration]
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Text
-> DebugHookConfig
DebugHookConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CollectionConfigurations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"HookParameters" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LocalPath")
            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
"S3OutputPath")
      )

instance Prelude.Hashable DebugHookConfig where
  hashWithSalt :: Int -> DebugHookConfig -> Int
hashWithSalt Int
_salt DebugHookConfig' {Maybe [CollectionConfiguration]
Maybe Text
Maybe (HashMap Text Text)
Text
s3OutputPath :: Text
localPath :: Maybe Text
hookParameters :: Maybe (HashMap Text Text)
collectionConfigurations :: Maybe [CollectionConfiguration]
$sel:s3OutputPath:DebugHookConfig' :: DebugHookConfig -> Text
$sel:localPath:DebugHookConfig' :: DebugHookConfig -> Maybe Text
$sel:hookParameters:DebugHookConfig' :: DebugHookConfig -> Maybe (HashMap Text Text)
$sel:collectionConfigurations:DebugHookConfig' :: DebugHookConfig -> Maybe [CollectionConfiguration]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CollectionConfiguration]
collectionConfigurations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
hookParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
localPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
s3OutputPath

instance Prelude.NFData DebugHookConfig where
  rnf :: DebugHookConfig -> ()
rnf DebugHookConfig' {Maybe [CollectionConfiguration]
Maybe Text
Maybe (HashMap Text Text)
Text
s3OutputPath :: Text
localPath :: Maybe Text
hookParameters :: Maybe (HashMap Text Text)
collectionConfigurations :: Maybe [CollectionConfiguration]
$sel:s3OutputPath:DebugHookConfig' :: DebugHookConfig -> Text
$sel:localPath:DebugHookConfig' :: DebugHookConfig -> Maybe Text
$sel:hookParameters:DebugHookConfig' :: DebugHookConfig -> Maybe (HashMap Text Text)
$sel:collectionConfigurations:DebugHookConfig' :: DebugHookConfig -> Maybe [CollectionConfiguration]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CollectionConfiguration]
collectionConfigurations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
hookParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
localPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
s3OutputPath

instance Data.ToJSON DebugHookConfig where
  toJSON :: DebugHookConfig -> Value
toJSON DebugHookConfig' {Maybe [CollectionConfiguration]
Maybe Text
Maybe (HashMap Text Text)
Text
s3OutputPath :: Text
localPath :: Maybe Text
hookParameters :: Maybe (HashMap Text Text)
collectionConfigurations :: Maybe [CollectionConfiguration]
$sel:s3OutputPath:DebugHookConfig' :: DebugHookConfig -> Text
$sel:localPath:DebugHookConfig' :: DebugHookConfig -> Maybe Text
$sel:hookParameters:DebugHookConfig' :: DebugHookConfig -> Maybe (HashMap Text Text)
$sel:collectionConfigurations:DebugHookConfig' :: DebugHookConfig -> Maybe [CollectionConfiguration]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CollectionConfigurations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CollectionConfiguration]
collectionConfigurations,
            (Key
"HookParameters" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
hookParameters,
            (Key
"LocalPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
localPath,
            forall a. a -> Maybe a
Prelude.Just (Key
"S3OutputPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
s3OutputPath)
          ]
      )