{-# 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.ProfilerConfig
-- 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.ProfilerConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information for Debugger system monitoring, framework
-- profiling, and storage paths.
--
-- /See:/ 'newProfilerConfig' smart constructor.
data ProfilerConfig = ProfilerConfig'
  { -- | Configuration information for capturing framework metrics. Available key
    -- strings for different profiling options are @DetailedProfilingConfig@,
    -- @PythonProfilingConfig@, and @DataLoaderProfilingConfig@. The following
    -- codes are configuration structures for the @ProfilingParameters@
    -- parameter. To learn more about how to configure the
    -- @ProfilingParameters@ 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>.
    ProfilerConfig -> Maybe (HashMap Text Text)
profilingParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A time interval for capturing system metrics in milliseconds. Available
    -- values are 100, 200, 500, 1000 (1 second), 5000 (5 seconds), and 60000
    -- (1 minute) milliseconds. The default value is 500 milliseconds.
    ProfilerConfig -> Maybe Integer
profilingIntervalInMilliseconds :: Prelude.Maybe Prelude.Integer,
    -- | Path to Amazon S3 storage location for system and framework metrics.
    ProfilerConfig -> Text
s3OutputPath :: Prelude.Text
  }
  deriving (ProfilerConfig -> ProfilerConfig -> Bool
(ProfilerConfig -> ProfilerConfig -> Bool)
-> (ProfilerConfig -> ProfilerConfig -> Bool) -> Eq ProfilerConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProfilerConfig -> ProfilerConfig -> Bool
$c/= :: ProfilerConfig -> ProfilerConfig -> Bool
== :: ProfilerConfig -> ProfilerConfig -> Bool
$c== :: ProfilerConfig -> ProfilerConfig -> Bool
Prelude.Eq, ReadPrec [ProfilerConfig]
ReadPrec ProfilerConfig
Int -> ReadS ProfilerConfig
ReadS [ProfilerConfig]
(Int -> ReadS ProfilerConfig)
-> ReadS [ProfilerConfig]
-> ReadPrec ProfilerConfig
-> ReadPrec [ProfilerConfig]
-> Read ProfilerConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProfilerConfig]
$creadListPrec :: ReadPrec [ProfilerConfig]
readPrec :: ReadPrec ProfilerConfig
$creadPrec :: ReadPrec ProfilerConfig
readList :: ReadS [ProfilerConfig]
$creadList :: ReadS [ProfilerConfig]
readsPrec :: Int -> ReadS ProfilerConfig
$creadsPrec :: Int -> ReadS ProfilerConfig
Prelude.Read, Int -> ProfilerConfig -> ShowS
[ProfilerConfig] -> ShowS
ProfilerConfig -> String
(Int -> ProfilerConfig -> ShowS)
-> (ProfilerConfig -> String)
-> ([ProfilerConfig] -> ShowS)
-> Show ProfilerConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProfilerConfig] -> ShowS
$cshowList :: [ProfilerConfig] -> ShowS
show :: ProfilerConfig -> String
$cshow :: ProfilerConfig -> String
showsPrec :: Int -> ProfilerConfig -> ShowS
$cshowsPrec :: Int -> ProfilerConfig -> ShowS
Prelude.Show, (forall x. ProfilerConfig -> Rep ProfilerConfig x)
-> (forall x. Rep ProfilerConfig x -> ProfilerConfig)
-> Generic ProfilerConfig
forall x. Rep ProfilerConfig x -> ProfilerConfig
forall x. ProfilerConfig -> Rep ProfilerConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProfilerConfig x -> ProfilerConfig
$cfrom :: forall x. ProfilerConfig -> Rep ProfilerConfig x
Prelude.Generic)

-- |
-- Create a value of 'ProfilerConfig' 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:
--
-- 'profilingParameters', 'profilerConfig_profilingParameters' - Configuration information for capturing framework metrics. Available key
-- strings for different profiling options are @DetailedProfilingConfig@,
-- @PythonProfilingConfig@, and @DataLoaderProfilingConfig@. The following
-- codes are configuration structures for the @ProfilingParameters@
-- parameter. To learn more about how to configure the
-- @ProfilingParameters@ 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>.
--
-- 'profilingIntervalInMilliseconds', 'profilerConfig_profilingIntervalInMilliseconds' - A time interval for capturing system metrics in milliseconds. Available
-- values are 100, 200, 500, 1000 (1 second), 5000 (5 seconds), and 60000
-- (1 minute) milliseconds. The default value is 500 milliseconds.
--
-- 's3OutputPath', 'profilerConfig_s3OutputPath' - Path to Amazon S3 storage location for system and framework metrics.
newProfilerConfig ::
  -- | 's3OutputPath'
  Prelude.Text ->
  ProfilerConfig
newProfilerConfig :: Text -> ProfilerConfig
newProfilerConfig Text
pS3OutputPath_ =
  ProfilerConfig' :: Maybe (HashMap Text Text)
-> Maybe Integer -> Text -> ProfilerConfig
ProfilerConfig'
    { $sel:profilingParameters:ProfilerConfig' :: Maybe (HashMap Text Text)
profilingParameters =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:profilingIntervalInMilliseconds:ProfilerConfig' :: Maybe Integer
profilingIntervalInMilliseconds = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:ProfilerConfig' :: Text
s3OutputPath = Text
pS3OutputPath_
    }

-- | Configuration information for capturing framework metrics. Available key
-- strings for different profiling options are @DetailedProfilingConfig@,
-- @PythonProfilingConfig@, and @DataLoaderProfilingConfig@. The following
-- codes are configuration structures for the @ProfilingParameters@
-- parameter. To learn more about how to configure the
-- @ProfilingParameters@ 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>.
profilerConfig_profilingParameters :: Lens.Lens' ProfilerConfig (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
profilerConfig_profilingParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ProfilerConfig -> f ProfilerConfig
profilerConfig_profilingParameters = (ProfilerConfig -> Maybe (HashMap Text Text))
-> (ProfilerConfig -> Maybe (HashMap Text Text) -> ProfilerConfig)
-> Lens
     ProfilerConfig
     ProfilerConfig
     (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 (\ProfilerConfig' {Maybe (HashMap Text Text)
profilingParameters :: Maybe (HashMap Text Text)
$sel:profilingParameters:ProfilerConfig' :: ProfilerConfig -> Maybe (HashMap Text Text)
profilingParameters} -> Maybe (HashMap Text Text)
profilingParameters) (\s :: ProfilerConfig
s@ProfilerConfig' {} Maybe (HashMap Text Text)
a -> ProfilerConfig
s {$sel:profilingParameters:ProfilerConfig' :: Maybe (HashMap Text Text)
profilingParameters = Maybe (HashMap Text Text)
a} :: ProfilerConfig) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ProfilerConfig -> f ProfilerConfig)
-> ((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)))
-> ProfilerConfig
-> f ProfilerConfig
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

-- | A time interval for capturing system metrics in milliseconds. Available
-- values are 100, 200, 500, 1000 (1 second), 5000 (5 seconds), and 60000
-- (1 minute) milliseconds. The default value is 500 milliseconds.
profilerConfig_profilingIntervalInMilliseconds :: Lens.Lens' ProfilerConfig (Prelude.Maybe Prelude.Integer)
profilerConfig_profilingIntervalInMilliseconds :: (Maybe Integer -> f (Maybe Integer))
-> ProfilerConfig -> f ProfilerConfig
profilerConfig_profilingIntervalInMilliseconds = (ProfilerConfig -> Maybe Integer)
-> (ProfilerConfig -> Maybe Integer -> ProfilerConfig)
-> Lens
     ProfilerConfig ProfilerConfig (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProfilerConfig' {Maybe Integer
profilingIntervalInMilliseconds :: Maybe Integer
$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: ProfilerConfig -> Maybe Integer
profilingIntervalInMilliseconds} -> Maybe Integer
profilingIntervalInMilliseconds) (\s :: ProfilerConfig
s@ProfilerConfig' {} Maybe Integer
a -> ProfilerConfig
s {$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: Maybe Integer
profilingIntervalInMilliseconds = Maybe Integer
a} :: ProfilerConfig)

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

instance Core.FromJSON ProfilerConfig where
  parseJSON :: Value -> Parser ProfilerConfig
parseJSON =
    String
-> (Object -> Parser ProfilerConfig)
-> Value
-> Parser ProfilerConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProfilerConfig"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe Integer -> Text -> ProfilerConfig
ProfilerConfig'
            (Maybe (HashMap Text Text)
 -> Maybe Integer -> Text -> ProfilerConfig)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Integer -> Text -> ProfilerConfig)
forall (f :: * -> *) a b. Functor 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
"ProfilingParameters"
                            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 (Maybe Integer -> Text -> ProfilerConfig)
-> Parser (Maybe Integer) -> Parser (Text -> ProfilerConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProfilingIntervalInMilliseconds")
            Parser (Text -> ProfilerConfig)
-> Parser Text -> Parser ProfilerConfig
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 ProfilerConfig

instance Prelude.NFData ProfilerConfig

instance Core.ToJSON ProfilerConfig where
  toJSON :: ProfilerConfig -> Value
toJSON ProfilerConfig' {Maybe Integer
Maybe (HashMap Text Text)
Text
s3OutputPath :: Text
profilingIntervalInMilliseconds :: Maybe Integer
profilingParameters :: Maybe (HashMap Text Text)
$sel:s3OutputPath:ProfilerConfig' :: ProfilerConfig -> Text
$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: ProfilerConfig -> Maybe Integer
$sel:profilingParameters:ProfilerConfig' :: ProfilerConfig -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProfilingParameters" 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)
profilingParameters,
            (Text
"ProfilingIntervalInMilliseconds" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
profilingIntervalInMilliseconds,
            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)
          ]
      )