Athena / Client / start_session

start_session

Athena.Client.start_session(**kwargs)

Creates a session for running calculations within a workgroup. The session is ready when it reaches an IDLE state.

See also: AWS API Documentation

Request Syntax

response = client.start_session(
    Description='string',
    WorkGroup='string',
    EngineConfiguration={
        'CoordinatorDpuSize': 123,
        'MaxConcurrentDpus': 123,
        'DefaultExecutorDpuSize': 123,
        'AdditionalConfigs': {
            'string': 'string'
        },
        'SparkProperties': {
            'string': 'string'
        },
        'Classifications': [
            {
                'Name': 'string',
                'Properties': {
                    'string': 'string'
                }
            },
        ]
    },
    ExecutionRole='string',
    MonitoringConfiguration={
        'CloudWatchLoggingConfiguration': {
            'Enabled': True|False,
            'LogGroup': 'string',
            'LogStreamNamePrefix': 'string',
            'LogTypes': {
                'string': [
                    'string',
                ]
            }
        },
        'ManagedLoggingConfiguration': {
            'Enabled': True|False,
            'KmsKey': 'string'
        },
        'S3LoggingConfiguration': {
            'Enabled': True|False,
            'KmsKey': 'string',
            'LogLocation': 'string'
        }
    },
    NotebookVersion='string',
    SessionIdleTimeoutInMinutes=123,
    ClientRequestToken='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    CopyWorkGroupTags=True|False
)
Parameters:
  • Description (string) – The session description.

  • WorkGroup (string) –

    [REQUIRED]

    The workgroup to which the session belongs.

  • EngineConfiguration (dict) –

    [REQUIRED]

    Contains engine data processing unit (DPU) configuration settings and parameter mappings.

    • CoordinatorDpuSize (integer) –

      The number of DPUs to use for the coordinator. A coordinator is a special executor that orchestrates processing work and manages other executors in a notebook session. The default is 1.

    • MaxConcurrentDpus (integer) –

      The maximum number of DPUs that can run concurrently.

    • DefaultExecutorDpuSize (integer) –

      The default number of DPUs to use for executors. An executor is the smallest unit of compute that a notebook session can request from Athena. The default is 1.

    • AdditionalConfigs (dict) –

      Contains additional notebook engine MAP<string, string> parameter mappings in the form of key-value pairs. To specify an Athena notebook that the Jupyter server will download and serve, specify a value for the StartSessionRequest$NotebookVersion field, and then add a key named NotebookId to AdditionalConfigs that has the value of the Athena notebook ID.

      • (string) –

        • (string) –

    • SparkProperties (dict) –

      Specifies custom jar files and Spark properties for use cases like cluster encryption, table formats, and general Spark tuning.

      • (string) –

        • (string) –

    • Classifications (list) –

      The configuration classifications that can be specified for the engine.

      • (dict) –

        A classification refers to a set of specific configurations.

        • Name (string) –

          The name of the configuration classification.

        • Properties (dict) –

          A set of properties specified within a configuration classification.

          • (string) –

            • (string) –

  • ExecutionRole (string) – The ARN of the execution role used to access user resources for Spark sessions and Identity Center enabled workgroups. This property applies only to Spark enabled workgroups and Identity Center enabled workgroups.

  • MonitoringConfiguration (dict) –

    Contains the configuration settings for managed log persistence, delivering logs to Amazon S3 buckets, Amazon CloudWatch log groups etc.

    • CloudWatchLoggingConfiguration (dict) –

      Configuration settings for delivering logs to Amazon CloudWatch log groups.

      • Enabled (boolean) – [REQUIRED]

        Enables CloudWatch logging.

      • LogGroup (string) –

        The name of the log group in Amazon CloudWatch Logs where you want to publish your logs.

      • LogStreamNamePrefix (string) –

        Prefix for the CloudWatch log stream name.

      • LogTypes (dict) –

        The types of logs that you want to publish to CloudWatch.

        • (string) –

          • (list) –

            • (string) –

    • ManagedLoggingConfiguration (dict) –

      Configuration settings for managed log persistence.

      • Enabled (boolean) – [REQUIRED]

        Enables mamanged log persistence.

      • KmsKey (string) –

        The KMS key ARN to encrypt the logs stored in managed log persistence.

    • S3LoggingConfiguration (dict) –

      Configuration settings for delivering logs to Amazon S3 buckets.

      • Enabled (boolean) – [REQUIRED]

        Enables S3 log delivery.

      • KmsKey (string) –

        The KMS key ARN to encrypt the logs published to the given Amazon S3 destination.

      • LogLocation (string) –

        The Amazon S3 destination URI for log publishing.

  • NotebookVersion (string) – The notebook version. This value is supplied automatically for notebook sessions in the Athena console and is not required for programmatic session access. The only valid notebook version is Athena notebook version 1. If you specify a value for NotebookVersion, you must also specify a value for NotebookId. See EngineConfiguration$AdditionalConfigs.

  • SessionIdleTimeoutInMinutes (integer) – The idle timeout in minutes for the session.

  • ClientRequestToken (string) –

    A unique case-sensitive string used to ensure the request to create the session is idempotent (executes only once). If another StartSessionRequest is received, the same response is returned and another session is not created. If a parameter has changed, an error is returned.

    Warning

    This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.

  • Tags (list) –

    A list of comma separated tags to add to the session that is created.

    • (dict) –

      A label that you assign to a resource. Athena resources include workgroups, data catalogs, and capacity reservations. Each tag consists of a key and an optional value, both of which you define. For example, you can use tags to categorize Athena resources by purpose, owner, or environment. Use a consistent set of tag keys to make it easier to search and filter the resources in your account. For best practices, see Tagging Best Practices. Tag keys can be from 1 to 128 UTF-8 Unicode characters, and tag values can be from 0 to 256 UTF-8 Unicode characters. Tags can use letters and numbers representable in UTF-8, and the following characters: + - = . _ : / @. Tag keys and values are case-sensitive. Tag keys must be unique per resource. If you specify more than one tag, separate them by commas.

      • Key (string) –

        A tag key. The tag key length is from 1 to 128 Unicode characters in UTF-8. You can use letters and numbers representable in UTF-8, and the following characters: + - = . _ : / @. Tag keys are case-sensitive and must be unique per resource.

      • Value (string) –

        A tag value. The tag value length is from 0 to 256 Unicode characters in UTF-8. You can use letters and numbers representable in UTF-8, and the following characters: + - = . _ : / @. Tag values are case-sensitive.

  • CopyWorkGroupTags (boolean) – Copies the tags from the Workgroup to the Session when.

Return type:

dict

Returns:

Response Syntax

{
    'SessionId': 'string',
    'State': 'CREATING'|'CREATED'|'IDLE'|'BUSY'|'TERMINATING'|'TERMINATED'|'DEGRADED'|'FAILED'
}

Response Structure

  • (dict) –

    • SessionId (string) –

      The session ID.

    • State (string) –

      The state of the session. A description of each state follows.

      CREATING - The session is being started, including acquiring resources.

      CREATED - The session has been started.

      IDLE - The session is able to accept a calculation.

      BUSY - The session is processing another task and is unable to accept a calculation.

      TERMINATING - The session is in the process of shutting down.

      TERMINATED - The session and its resources are no longer running.

      DEGRADED - The session has no healthy coordinators.

      FAILED - Due to a failure, the session and its resources are no longer running.

Exceptions

  • Athena.Client.exceptions.InternalServerException

  • Athena.Client.exceptions.InvalidRequestException

  • Athena.Client.exceptions.ResourceNotFoundException

  • Athena.Client.exceptions.SessionAlreadyExistsException

  • Athena.Client.exceptions.TooManyRequestsException