Skip to content

create_context

create_context(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    context_name: Optional[ContextName] = None,
    source: Optional[ContextSource] = None,
    context_type: Optional[String256] = None,
    description: Optional[ExperimentDescription] = None,
    properties: Optional[LineageEntityParameters] = None,
    tags: Optional[TagList] = None,
) -> CreateContextResponse

Creates a context. A context is a lineage tracking entity that represents a logical grouping of other tracking or experiment entities. Some examples are an endpoint and a model package. For more information, see Amazon SageMaker ML Lineage Tracking.

Parameters:

Raises:

  • ResourceLimitExceeded –

    You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def create_context(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    context_name: Optional["capo_sagemaker.types.context_name.ContextName"] = None,
    source: Optional["capo_sagemaker.types.context_source.ContextSource"] = None,
    context_type: Optional["capo_sagemaker.types.string256.String256"] = None,
    description: Optional[
        "capo_sagemaker.types.experiment_description.ExperimentDescription"
    ] = None,
    properties: Optional[
        "capo_sagemaker.types.lineage_entity_parameters.LineageEntityParameters"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_context_response.CreateContextResponse":
    """<p>Creates a <i>context</i>. A context is a lineage tracking entity that represents a logical grouping of other tracking or experiment entities. Some examples are an endpoint and a model package. For more information, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/lineage-tracking.html">Amazon SageMaker ML Lineage Tracking</a>.</p>

    Args:
        context_name: <p>The name of the context. Must be unique to your account in an Amazon Web Services Region.</p>
        source: <p>The source type, ID, and URI.</p>
        context_type: <p>The context type.</p>
        description: <p>The description of the context.</p>
        properties: <p>A list of properties to add to the context.</p>
        tags: <p>A list of tags to apply to the context.</p>

    Raises:
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.create_context_request.CreateContextRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.create_context_response.CreateContextResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.create_context

        output, http_response = (
            capo_sagemaker._operations.sage_maker.create_context.create_context(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateContext")
    )
    input_: capo_sagemaker.types.create_context_request.CreateContextRequest = {}
    if context_name is not None:
        input_["context_name"] = context_name
    if source is not None:
        input_["source"] = source
    if context_type is not None:
        input_["context_type"] = context_type
    if description is not None:
        input_["description"] = description
    if properties is not None:
        input_["properties"] = properties
    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