Skip to content

start_session

start_session(
    *,
    config_overrides: Optional[EMRClientConfig] = None,
    name: Optional[XmlStringMaxLen256] = None,
    cluster_id: Optional[ClusterId] = None,
    execution_role_arn: Optional[IAMRoleArn] = None,
    engine_configurations: Optional[ConfigurationList] = None,
    monitoring_configuration: Optional[SessionMonitoringConfiguration] = None,
    session_idle_timeout_in_minutes: Optional[Long] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    tags: Optional[TagList] = None,
) -> StartSessionOutput

Creates and starts a new Spark Connect session on the specified cluster. The cluster must be in the RUNNING or WAITING state and have sessions enabled. This operation is supported in Amazon EMR Spark 8.0.0 and later.

Parameters:

  • name (Optional[XmlStringMaxLen256], default: None ) –

    An optional name for the session.

  • cluster_id (Optional[ClusterId], default: None ) –

    The ID of the cluster on which to start the session.

  • execution_role_arn (Optional[IAMRoleArn], default: None ) –

    The execution role ARN for the session. Amazon EMR uses this role to access Amazon Web Services resources on your behalf during session execution.

  • engine_configurations (Optional[ConfigurationList], default: None ) –

    The configuration overrides for the session. Only runtime configuration overrides are supported.

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

    The monitoring configuration that controls where session logs are published, such as Amazon S3, CloudWatch, or managed logging.

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

    The idle timeout, in minutes. If the session is idle for this duration, Amazon EMR EC2 automatically terminates it.

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client request token, the service returns the original response without performing the operation again.

  • tags (Optional[TagList], default: None ) –

    The tags to assign to the session.

Raises:

Source code in docs_src/capo_emr/_services/emr.py
def start_session(
    self,
    *,
    config_overrides: Optional[EMRClientConfig] = None,
    name: Optional[
        "capo_emr.types.xml_string_max_len256.XmlStringMaxLen256"
    ] = None,
    cluster_id: Optional["capo_emr.types.cluster_id.ClusterId"] = None,
    execution_role_arn: Optional["capo_emr.types.iam_role_arn.IAMRoleArn"] = None,
    engine_configurations: Optional[
        "capo_emr.types.configuration_list.ConfigurationList"
    ] = None,
    monitoring_configuration: Optional[
        "capo_emr.types.session_monitoring_configuration.SessionMonitoringConfiguration"
    ] = None,
    session_idle_timeout_in_minutes: Optional["capo_emr.types.long.Long"] = None,
    client_request_token: Optional[
        "capo_emr.types.client_request_token.ClientRequestToken"
    ] = None,
    tags: Optional["capo_emr.types.tag_list.TagList"] = None,
) -> "capo_emr.types.start_session_output.StartSessionOutput":
    """<p>Creates and starts a new Spark Connect session on the specified cluster. The cluster must be in the <code>RUNNING</code> or <code>WAITING</code> state and have sessions enabled. This operation is supported in Amazon EMR Spark 8.0.0 and later.</p>

    Args:
        name: <p>An optional name for the session.</p>
        cluster_id: <p>The ID of the cluster on which to start the session.</p>
        execution_role_arn: <p>The execution role ARN for the session. Amazon EMR uses this role to access Amazon Web Services resources on your behalf during session execution.</p>
        engine_configurations: <p>The configuration overrides for the session. Only runtime configuration overrides are supported.</p>
        monitoring_configuration: <p>The monitoring configuration that controls where session logs are published, such as Amazon S3, CloudWatch, or managed logging.</p>
        session_idle_timeout_in_minutes: <p>The idle timeout, in minutes. If the session is idle for this duration, Amazon EMR EC2 automatically terminates it.</p>
        client_request_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client request token, the service returns the original response without performing the operation again.</p>
        tags: <p>The tags to assign to the session.</p>

    Raises:
        capo_emr.errors.internal_server_exception.InternalServerException: <p>This exception occurs when there is an internal failure in the Amazon EMR service.</p>
        capo_emr.errors.invalid_request_exception.InvalidRequestException: <p>This exception occurs when there is something wrong with user input.</p>
        capo_emr.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_emr.types.start_session_input.StartSessionInput]",
    ) -> OperationResponse[
        "capo_emr.types.start_session_output.StartSessionOutput"
    ]:
        import capo_emr._operations.elastic_map_reduce.start_session

        output, http_response = (
            capo_emr._operations.elastic_map_reduce.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_emr.types.start_session_input.StartSessionInput = {}
    if name is not None:
        input_["name"] = name
    if cluster_id is not None:
        input_["cluster_id"] = cluster_id
    if execution_role_arn is not None:
        input_["execution_role_arn"] = execution_role_arn
    if engine_configurations is not None:
        input_["engine_configurations"] = engine_configurations
    if monitoring_configuration is not None:
        input_["monitoring_configuration"] = monitoring_configuration
    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

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