sagemaker.core.lineage.context#
This module contains code to create and manage SageMaker Context.
Classes
|
An Amazon SageMaker context, which is part of a SageMaker lineage. |
|
An Amazon SageMaker endpoint context, which is part of a SageMaker lineage. |
|
An Amazon SageMaker model package group context, which is part of a SageMaker lineage. |
- class sagemaker.core.lineage.context.Context(sagemaker_session=None, **kwargs)[source]#
Bases:
RecordAn Amazon SageMaker context, which is part of a SageMaker lineage.
- context_arn#
The ARN of the context.
- Type:
str
- context_name#
The name of the context.
- Type:
str
- context_type#
The type of the context.
- Type:
str
- description#
A description of the context.
- Type:
str
- source#
The source of the context with a URI and type.
- Type:
obj
- properties#
Dictionary of properties.
- Type:
dict
- tags#
A list of tags to associate with the context.
- Type:
List[dict[str, str]]
- creation_time#
When the context was created.
- Type:
datetime
- created_by#
Contextual info on which account created the context.
- Type:
obj
- last_modified_time#
When the context was last modified.
- Type:
datetime
- last_modified_by#
Contextual info on which account created the context.
- Type:
obj
- actions(direction: LineageQueryDirectionEnum) List[Action][source]#
Use the lineage query to retrieve actions that use this context.
- Parameters:
direction (LineageQueryDirectionEnum) – The query direction.
- Returns:
Actions.
- Return type:
list of Actions
- context_arn: str = None#
- context_name: str = None#
- context_type: str = None#
- classmethod create(context_name: str | None = None, source_uri: str | None = None, source_type: str | None = None, context_type: str | None = None, description: str | None = None, properties: dict | None = None, tags: dict | None = None, sagemaker_session=None) Context[source]#
Create a context and return a
Contextobject representing it.- Parameters:
context_name (str) – The name of the context.
source_uri (str) – The source URI of the context.
source_type (str) – The type of the source.
context_type (str) – The type of the context.
description (str) – Description of the context.
properties (dict) – Metadata associated with the context.
tags (dict) – Tags to add to the context.
sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created using the default AWS configuration chain.
- Returns:
A SageMaker
Contextobject.- Return type:
- created_by: str = None#
- creation_time: datetime = None#
- delete(disassociate: bool = False)[source]#
Delete the context object.
- Parameters:
disassociate (bool) – When set to true, disassociate incoming and outgoing association.
- Returns:
boto API response.
- Return type:
obj
- last_modified_by: str = None#
- last_modified_time: datetime = None#
- classmethod list(source_uri: str | None = None, context_type: str | None = None, created_after: datetime | None = None, created_before: datetime | None = None, sort_by: str | None = None, sort_order: str | None = None, max_results: int | None = None, next_token: str | None = None, sagemaker_session=None) Iterator[ContextSummary][source]#
Return a list of context summaries.
- Parameters:
source_uri (str, optional) – A source URI.
context_type (str, optional) – An context type.
created_before (datetime.datetime, optional) – Return contexts created before this instant.
created_after (datetime.datetime, optional) – Return contexts created after this instant.
sort_by (str, optional) – Which property to sort results by. One of ‘SourceArn’, ‘CreatedBefore’, ‘CreatedAfter’
sort_order (str, optional) – One of ‘Ascending’, or ‘Descending’.
max_results (int, optional) – maximum number of contexts to retrieve
next_token (str, optional) – token for next page of results
sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created using the default AWS configuration chain.
- Returns:
- An iterator
over
ContextSummaryobjects.
- Return type:
collections.Iterator[ContextSummary]
- classmethod load(context_name: str, sagemaker_session=None) Context[source]#
Load an existing context and return an
Contextobject representing it.Examples
from sagemaker.lineage import context my_context = context.Context.create( context_name='MyContext', context_type='Endpoint', source_uri='arn:aws:...') my_context.properties["added"] = "property" my_context.save() for ctx in context.Context.list(): print(ctx) my_context.delete()
- Args:
context_name (str): Name of the context sagemaker_session (sagemaker.session.Session): Session object which
manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created using the default AWS configuration chain.
- Returns:
Context: A SageMaker
Contextobject
- properties: dict = None#
- save() Context[source]#
Save the state of this Context to SageMaker.
- Returns:
boto API response.
- Return type:
obj
- set_tag(tag=None)[source]#
Add a tag to the object.
- Parameters:
tag (obj) – Key value pair to set tag.
- Returns:
str}): a list of key value pairs
- Return type:
list({str
- set_tags(tags=None)[source]#
Add tags to the object.
- Parameters:
([{key (tags) – value}]): list of key value pairs.
- Returns:
str}): a list of key value pairs
- Return type:
list({str
- tags: list = None#
- class sagemaker.core.lineage.context.EndpointContext(sagemaker_session=None, **kwargs)[source]#
Bases:
ContextAn Amazon SageMaker endpoint context, which is part of a SageMaker lineage.
- dataset_artifacts(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[Artifact][source]#
Use the lineage query to retrieve datasets that use this endpoint.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Artifacts representing a dataset.
- Return type:
list of Artifacts
- models() List[Association][source]#
Use Lineage API to get all models deployed by this endpoint.
- Returns:
Associations that destination represents an endpoint’s model.
- Return type:
list of Associations
- models_v2(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.DESCENDANTS) List[Artifact][source]#
Use the lineage query to retrieve downstream model artifacts that use this endpoint.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Artifacts representing a model.
- Return type:
list of Artifacts
- pipeline_execution_arn(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) str[source]#
Get the ARN for the pipeline execution associated with this endpoint (if any).
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
A pipeline execution ARN.
- Return type:
str
- processing_jobs(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[LineageTrialComponent][source]#
Use the lineage query to retrieve processing jobs that use this endpoint.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Lineage trial component that represent Processing jobs.
- Return type:
list of LineageTrialComponent
- training_job_arns(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[str][source]#
Get ARNs for all training jobs that appear in the endpoint’s lineage.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Training job ARNs.
- Return type:
list of str
- transform_jobs(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[LineageTrialComponent][source]#
Use the lineage query to retrieve transform jobs that use this endpoint.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Lineage trial component that represent Transform jobs.
- Return type:
list of LineageTrialComponent
- trial_components(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[LineageTrialComponent][source]#
Use the lineage query to retrieve trial components that use this endpoint.
- Parameters:
direction (LineageQueryDirectionEnum, optional) – The query direction.
- Returns:
Lineage trial component.
- Return type:
list of LineageTrialComponent