Skip to content

start_session

start_session(
    work_group: WorkGroupName,
    engine_configuration: EngineConfiguration,
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    description: Optional[DescriptionString] = None,
    execution_role: Optional[RoleArn] = None,
    monitoring_configuration: Optional[MonitoringConfiguration] = None,
    notebook_version: Optional[NameString] = None,
    session_idle_timeout_in_minutes: Optional[SessionIdleTimeoutInMinutes] = None,
    client_request_token: Optional[IdempotencyToken] = None,
    tags: Optional[TagList] = None,
    copy_work_group_tags: Optional[BoxedBoolean] = None,
) -> StartSessionResponse

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

Parameters:

  • description (Optional[DescriptionString], default: None ) –

    The session description.

  • work_group (WorkGroupName) –

    The workgroup to which the session belongs.

  • engine_configuration (EngineConfiguration) –

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

  • execution_role (Optional[RoleArn], default: None ) –

    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.

  • monitoring_configuration (Optional[MonitoringConfiguration], default: None ) –

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

  • notebook_version (Optional[NameString], default: None ) –

    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.

  • session_idle_timeout_in_minutes (Optional[SessionIdleTimeoutInMinutes], default: None ) –

    The idle timeout in minutes for the session.

  • client_request_token (Optional[IdempotencyToken], default: None ) –

    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.

    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 (Optional[TagList], default: None ) –

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

  • copy_work_group_tags (Optional[BoxedBoolean], default: None ) –

    Copies the tags from the Workgroup to the Session when.

Raises:

Source code in docs_src/capo_athena/_services/athena.py
def start_session(
    self,
    work_group: "capo_athena.types.work_group_name.WorkGroupName",
    engine_configuration: "capo_athena.types.engine_configuration.EngineConfiguration",
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    description: Optional[
        "capo_athena.types.description_string.DescriptionString"
    ] = None,
    execution_role: Optional["capo_athena.types.role_arn.RoleArn"] = None,
    monitoring_configuration: Optional[
        "capo_athena.types.monitoring_configuration.MonitoringConfiguration"
    ] = None,
    notebook_version: Optional["capo_athena.types.name_string.NameString"] = None,
    session_idle_timeout_in_minutes: Optional[
        "capo_athena.types.session_idle_timeout_in_minutes.SessionIdleTimeoutInMinutes"
    ] = None,
    client_request_token: Optional[
        "capo_athena.types.idempotency_token.IdempotencyToken"
    ] = None,
    tags: Optional["capo_athena.types.tag_list.TagList"] = None,
    copy_work_group_tags: Optional[
        "capo_athena.types.boxed_boolean.BoxedBoolean"
    ] = None,
) -> "capo_athena.types.start_session_response.StartSessionResponse":
    """<p>Creates a session for running calculations within a workgroup. The session is ready when it reaches an <code>IDLE</code> state.</p>

    Args:
        description: <p>The session description.</p>
        work_group: <p>The workgroup to which the session belongs.</p>
        engine_configuration: <p>Contains engine data processing unit (DPU) configuration settings and parameter mappings.</p>
        execution_role: <p>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.</p>
        monitoring_configuration: <p>Contains the configuration settings for managed log persistence, delivering logs to Amazon S3 buckets, Amazon CloudWatch log groups etc.</p>
        notebook_version: <p>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 <code>Athena notebook version 1</code>. If you specify a value for <code>NotebookVersion</code>, you must also specify a value for <code>NotebookId</code>. See <a>EngineConfiguration$AdditionalConfigs</a>.</p>
        session_idle_timeout_in_minutes: <p>The idle timeout in minutes for the session.</p>
        client_request_token: <p>A unique case-sensitive string used to ensure the request to create the session is idempotent (executes only once). If another <code>StartSessionRequest</code> is received, the same response is returned and another session is not created. If a parameter has changed, an error is returned.</p> <important> <p>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.</p> </important>
        tags: <p>A list of comma separated tags to add to the session that is created.</p>
        copy_work_group_tags: <p>Copies the tags from the Workgroup to the Session when.</p>

    Raises:
        capo_athena.errors.internal_server_exception.InternalServerException: <p>Indicates a platform issue, which may be due to a transient condition or outage.</p>
        capo_athena.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.</p>
        capo_athena.errors.resource_not_found_exception.ResourceNotFoundException: <p>A resource, such as a workgroup, was not found.</p>
        capo_athena.errors.session_already_exists_exception.SessionAlreadyExistsException: <p>The specified session already exists.</p>
        capo_athena.errors.too_many_requests_exception.TooManyRequestsException: <p>Indicates that the request was throttled.</p>
        capo_athena.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_athena.types.start_session_request.StartSessionRequest]",
    ) -> OperationResponse[
        "capo_athena.types.start_session_response.StartSessionResponse"
    ]:
        import capo_athena._operations.amazon_athena.start_session

        output, http_response = (
            capo_athena._operations.amazon_athena.start_session.start_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartSession")
    )
    input_: capo_athena.types.start_session_request.StartSessionRequest = {
        "work_group": work_group,
        "engine_configuration": engine_configuration,
    }
    if description is not None:
        input_["description"] = description
    if execution_role is not None:
        input_["execution_role"] = execution_role
    if monitoring_configuration is not None:
        input_["monitoring_configuration"] = monitoring_configuration
    if notebook_version is not None:
        input_["notebook_version"] = notebook_version
    if session_idle_timeout_in_minutes is not None:
        input_["session_idle_timeout_in_minutes"] = session_idle_timeout_in_minutes
    if client_request_token is not None:
        input_["client_request_token"] = client_request_token
    if tags is not None:
        input_["tags"] = tags
    if copy_work_group_tags is not None:
        input_["copy_work_group_tags"] = copy_work_group_tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output