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

-- | Configuration information for Amazon SageMaker Debugger system
-- monitoring, framework profiling, and storage paths.
--
-- /See:/ 'newProfilerConfig' smart constructor.
data ProfilerConfig = ProfilerConfig'
  { -- | Configuration to turn off Amazon SageMaker Debugger\'s system monitoring
    -- and profiling functionality. To turn it off, set to @True@.
    ProfilerConfig -> Maybe Bool
disableProfiler :: Prelude.Maybe Prelude.Bool,
    -- | 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,
    -- | 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),
    -- | Path to Amazon S3 storage location for system and framework metrics.
    ProfilerConfig -> Maybe Text
s3OutputPath :: Prelude.Maybe Prelude.Text
  }
  deriving (ProfilerConfig -> ProfilerConfig -> Bool
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]
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
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. 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:
--
-- 'disableProfiler', 'profilerConfig_disableProfiler' - Configuration to turn off Amazon SageMaker Debugger\'s system monitoring
-- and profiling functionality. To turn it off, set to @True@.
--
-- '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.
--
-- '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>.
--
-- 's3OutputPath', 'profilerConfig_s3OutputPath' - Path to Amazon S3 storage location for system and framework metrics.
newProfilerConfig ::
  ProfilerConfig
newProfilerConfig :: ProfilerConfig
newProfilerConfig =
  ProfilerConfig'
    { $sel:disableProfiler:ProfilerConfig' :: Maybe Bool
disableProfiler = forall a. Maybe a
Prelude.Nothing,
      $sel:profilingIntervalInMilliseconds:ProfilerConfig' :: Maybe Integer
profilingIntervalInMilliseconds = forall a. Maybe a
Prelude.Nothing,
      $sel:profilingParameters:ProfilerConfig' :: Maybe (HashMap Text Text)
profilingParameters = forall a. Maybe a
Prelude.Nothing,
      $sel:s3OutputPath:ProfilerConfig' :: Maybe Text
s3OutputPath = forall a. Maybe a
Prelude.Nothing
    }

-- | Configuration to turn off Amazon SageMaker Debugger\'s system monitoring
-- and profiling functionality. To turn it off, set to @True@.
profilerConfig_disableProfiler :: Lens.Lens' ProfilerConfig (Prelude.Maybe Prelude.Bool)
profilerConfig_disableProfiler :: Lens' ProfilerConfig (Maybe Bool)
profilerConfig_disableProfiler = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProfilerConfig' {Maybe Bool
disableProfiler :: Maybe Bool
$sel:disableProfiler:ProfilerConfig' :: ProfilerConfig -> Maybe Bool
disableProfiler} -> Maybe Bool
disableProfiler) (\s :: ProfilerConfig
s@ProfilerConfig' {} Maybe Bool
a -> ProfilerConfig
s {$sel:disableProfiler:ProfilerConfig' :: Maybe Bool
disableProfiler = Maybe Bool
a} :: ProfilerConfig)

-- | 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 :: Lens' ProfilerConfig (Maybe Integer)
profilerConfig_profilingIntervalInMilliseconds = 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)

-- | 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 :: Lens' ProfilerConfig (Maybe (HashMap Text Text))
profilerConfig_profilingParameters = 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) 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 Amazon S3 storage location for system and framework metrics.
profilerConfig_s3OutputPath :: Lens.Lens' ProfilerConfig (Prelude.Maybe Prelude.Text)
profilerConfig_s3OutputPath :: Lens' ProfilerConfig (Maybe Text)
profilerConfig_s3OutputPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProfilerConfig' {Maybe Text
s3OutputPath :: Maybe Text
$sel:s3OutputPath:ProfilerConfig' :: ProfilerConfig -> Maybe Text
s3OutputPath} -> Maybe Text
s3OutputPath) (\s :: ProfilerConfig
s@ProfilerConfig' {} Maybe Text
a -> ProfilerConfig
s {$sel:s3OutputPath:ProfilerConfig' :: Maybe Text
s3OutputPath = Maybe Text
a} :: ProfilerConfig)

instance Data.FromJSON ProfilerConfig where
  parseJSON :: Value -> Parser ProfilerConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProfilerConfig"
      ( \Object
x ->
          Maybe Bool
-> Maybe Integer
-> Maybe (HashMap Text Text)
-> Maybe Text
-> ProfilerConfig
ProfilerConfig'
            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
"DisableProfiler")
            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
"ProfilingIntervalInMilliseconds")
            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
"ProfilingParameters"
                            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
"S3OutputPath")
      )

instance Prelude.Hashable ProfilerConfig where
  hashWithSalt :: Int -> ProfilerConfig -> Int
hashWithSalt Int
_salt ProfilerConfig' {Maybe Bool
Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
s3OutputPath :: Maybe Text
profilingParameters :: Maybe (HashMap Text Text)
profilingIntervalInMilliseconds :: Maybe Integer
disableProfiler :: Maybe Bool
$sel:s3OutputPath:ProfilerConfig' :: ProfilerConfig -> Maybe Text
$sel:profilingParameters:ProfilerConfig' :: ProfilerConfig -> Maybe (HashMap Text Text)
$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: ProfilerConfig -> Maybe Integer
$sel:disableProfiler:ProfilerConfig' :: ProfilerConfig -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
disableProfiler
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
profilingIntervalInMilliseconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
profilingParameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3OutputPath

instance Prelude.NFData ProfilerConfig where
  rnf :: ProfilerConfig -> ()
rnf ProfilerConfig' {Maybe Bool
Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
s3OutputPath :: Maybe Text
profilingParameters :: Maybe (HashMap Text Text)
profilingIntervalInMilliseconds :: Maybe Integer
disableProfiler :: Maybe Bool
$sel:s3OutputPath:ProfilerConfig' :: ProfilerConfig -> Maybe Text
$sel:profilingParameters:ProfilerConfig' :: ProfilerConfig -> Maybe (HashMap Text Text)
$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: ProfilerConfig -> Maybe Integer
$sel:disableProfiler:ProfilerConfig' :: ProfilerConfig -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
disableProfiler
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
profilingIntervalInMilliseconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
profilingParameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3OutputPath

instance Data.ToJSON ProfilerConfig where
  toJSON :: ProfilerConfig -> Value
toJSON ProfilerConfig' {Maybe Bool
Maybe Integer
Maybe Text
Maybe (HashMap Text Text)
s3OutputPath :: Maybe Text
profilingParameters :: Maybe (HashMap Text Text)
profilingIntervalInMilliseconds :: Maybe Integer
disableProfiler :: Maybe Bool
$sel:s3OutputPath:ProfilerConfig' :: ProfilerConfig -> Maybe Text
$sel:profilingParameters:ProfilerConfig' :: ProfilerConfig -> Maybe (HashMap Text Text)
$sel:profilingIntervalInMilliseconds:ProfilerConfig' :: ProfilerConfig -> Maybe Integer
$sel:disableProfiler:ProfilerConfig' :: ProfilerConfig -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DisableProfiler" 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 Bool
disableProfiler,
            (Key
"ProfilingIntervalInMilliseconds" 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 Integer
profilingIntervalInMilliseconds,
            (Key
"ProfilingParameters" 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)
profilingParameters,
            (Key
"S3OutputPath" 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
s3OutputPath
          ]
      )