{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.DebugHookConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.CollectionConfiguration

-- | Configuration information for the 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'
  { -- | Path to local storage location for metrics and tensors. Defaults to
    -- @\/opt\/ml\/output\/tensors\/@.
    DebugHookConfig -> Maybe Text
localPath :: Prelude.Maybe Prelude.Text,
    -- | Configuration information for 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 Debugger hook parameters.
    DebugHookConfig -> Maybe (HashMap Text Text)
hookParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Path to Amazon S3 storage location for metrics and tensors.
    DebugHookConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (DebugHookConfig -> DebugHookConfig -> Bool
(DebugHookConfig -> DebugHookConfig -> Bool)
-> (DebugHookConfig -> DebugHookConfig -> Bool)
-> Eq DebugHookConfig
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]
(Int -> ReadS DebugHookConfig)
-> ReadS [DebugHookConfig]
-> ReadPrec DebugHookConfig
-> ReadPrec [DebugHookConfig]
-> Read 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
(Int -> DebugHookConfig -> ShowS)
-> (DebugHookConfig -> String)
-> ([DebugHookConfig] -> ShowS)
-> Show DebugHookConfig
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. DebugHookConfig -> Rep DebugHookConfig x)
-> (forall x. Rep DebugHookConfig x -> DebugHookConfig)
-> Generic DebugHookConfig
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:
--
-- 'localPath', 'debugHookConfig_localPath' - Path to local storage location for metrics and tensors. Defaults to
-- @\/opt\/ml\/output\/tensors\/@.
--
-- 'collectionConfigurations', 'debugHookConfig_collectionConfigurations' - Configuration information for 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 Debugger hook parameters.
--
-- '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' :: Maybe Text
-> Maybe [CollectionConfiguration]
-> Maybe (HashMap Text Text)
-> Text
-> DebugHookConfig
DebugHookConfig'
    { $sel:localPath:DebugHookConfig' :: Maybe Text
localPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:collectionConfigurations:DebugHookConfig' :: Maybe [CollectionConfiguration]
collectionConfigurations = Maybe [CollectionConfiguration]
forall a. Maybe a
Prelude.Nothing,
      $sel:hookParameters:DebugHookConfig' :: Maybe (HashMap Text Text)
hookParameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:DebugHookConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> DebugHookConfig -> f DebugHookConfig
debugHookConfig_localPath = (DebugHookConfig -> Maybe Text)
-> (DebugHookConfig -> Maybe Text -> DebugHookConfig)
-> Lens DebugHookConfig DebugHookConfig (Maybe Text) (Maybe Text)
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)

-- | Configuration information for 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 :: (Maybe [CollectionConfiguration]
 -> f (Maybe [CollectionConfiguration]))
-> DebugHookConfig -> f DebugHookConfig
debugHookConfig_collectionConfigurations = (DebugHookConfig -> Maybe [CollectionConfiguration])
-> (DebugHookConfig
    -> Maybe [CollectionConfiguration] -> DebugHookConfig)
-> Lens
     DebugHookConfig
     DebugHookConfig
     (Maybe [CollectionConfiguration])
     (Maybe [CollectionConfiguration])
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) ((Maybe [CollectionConfiguration]
  -> f (Maybe [CollectionConfiguration]))
 -> DebugHookConfig -> f DebugHookConfig)
-> ((Maybe [CollectionConfiguration]
     -> f (Maybe [CollectionConfiguration]))
    -> Maybe [CollectionConfiguration]
    -> f (Maybe [CollectionConfiguration]))
-> (Maybe [CollectionConfiguration]
    -> f (Maybe [CollectionConfiguration]))
-> DebugHookConfig
-> f DebugHookConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CollectionConfiguration]
  [CollectionConfiguration]
  [CollectionConfiguration]
  [CollectionConfiguration]
-> Iso
     (Maybe [CollectionConfiguration])
     (Maybe [CollectionConfiguration])
     (Maybe [CollectionConfiguration])
     (Maybe [CollectionConfiguration])
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 AnIso
  [CollectionConfiguration]
  [CollectionConfiguration]
  [CollectionConfiguration]
  [CollectionConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Configuration information for the Debugger hook parameters.
debugHookConfig_hookParameters :: Lens.Lens' DebugHookConfig (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
debugHookConfig_hookParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DebugHookConfig -> f DebugHookConfig
debugHookConfig_hookParameters = (DebugHookConfig -> Maybe (HashMap Text Text))
-> (DebugHookConfig
    -> Maybe (HashMap Text Text) -> DebugHookConfig)
-> Lens
     DebugHookConfig
     DebugHookConfig
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DebugHookConfig -> f DebugHookConfig)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DebugHookConfig
-> f DebugHookConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Path to Amazon S3 storage location for metrics and tensors.
debugHookConfig_s3OutputPath :: Lens.Lens' DebugHookConfig Prelude.Text
debugHookConfig_s3OutputPath :: (Text -> f Text) -> DebugHookConfig -> f DebugHookConfig
debugHookConfig_s3OutputPath = (DebugHookConfig -> Text)
-> (DebugHookConfig -> Text -> DebugHookConfig)
-> Lens DebugHookConfig DebugHookConfig Text Text
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 Core.FromJSON DebugHookConfig where
  parseJSON :: Value -> Parser DebugHookConfig
parseJSON =
    String
-> (Object -> Parser DebugHookConfig)
-> Value
-> Parser DebugHookConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DebugHookConfig"
      ( \Object
x ->
          Maybe Text
-> Maybe [CollectionConfiguration]
-> Maybe (HashMap Text Text)
-> Text
-> DebugHookConfig
DebugHookConfig'
            (Maybe Text
 -> Maybe [CollectionConfiguration]
 -> Maybe (HashMap Text Text)
 -> Text
 -> DebugHookConfig)
-> Parser (Maybe Text)
-> Parser
     (Maybe [CollectionConfiguration]
      -> Maybe (HashMap Text Text) -> Text -> DebugHookConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LocalPath")
            Parser
  (Maybe [CollectionConfiguration]
   -> Maybe (HashMap Text Text) -> Text -> DebugHookConfig)
-> Parser (Maybe [CollectionConfiguration])
-> Parser (Maybe (HashMap Text Text) -> Text -> DebugHookConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [CollectionConfiguration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CollectionConfigurations"
                            Parser (Maybe (Maybe [CollectionConfiguration]))
-> Maybe [CollectionConfiguration]
-> Parser (Maybe [CollectionConfiguration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CollectionConfiguration]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe (HashMap Text Text) -> Text -> DebugHookConfig)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Text -> DebugHookConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HookParameters" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> DebugHookConfig)
-> Parser Text -> Parser DebugHookConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3OutputPath")
      )

instance Prelude.Hashable DebugHookConfig

instance Prelude.NFData DebugHookConfig

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