sagemaker.core.lineage.action#

This module contains code to create and manage SageMaker Actions.

Classes

Action([sagemaker_session])

An Amazon SageMaker action, which is part of a SageMaker lineage.

ModelPackageApprovalAction([sagemaker_session])

An Amazon SageMaker model package approval action, which is part of a SageMaker lineage.

class sagemaker.core.lineage.action.Action(sagemaker_session=None, **kwargs)[source]#

Bases: Record

An Amazon SageMaker action, which is part of a SageMaker lineage.

Examples

from sagemaker.lineage import action

my_action = action.Action.create(
    action_name='MyAction',
    action_type='EndpointDeployment',
    source_uri='s3://...')

my_action.properties["added"] = "property"
my_action.save()

for actn in action.Action.list():
    print(actn)

my_action.delete()
action_arn#

The ARN of the action.

Type:

str

action_name#

The name of the action.

Type:

str

action_type#

The type of the action.

Type:

str

description#

A description of the action.

Type:

str

status#

The status of the action.

Type:

str

source#

The source of the action with a URI and type.

Type:

obj

properties#

Dictionary of properties.

Type:

dict

tags#

A list of tags to associate with the action.

Type:

List[dict[str, str]]

creation_time#

When the action was created.

Type:

datetime

created_by#

Contextual info on which account created the action.

Type:

obj

last_modified_time#

When the action was last modified.

Type:

datetime

last_modified_by#

Contextual info on which account created the action.

Type:

obj

action_arn: str = None#
action_name: str = None#
action_type: str = None#
artifacts(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.BOTH) List[Artifact][source]#

Use a lineage query to retrieve all artifacts that use this action.

Parameters:

direction (LineageQueryDirectionEnum, optional) – The query direction.

Returns:

Artifacts.

Return type:

list of Artifacts

classmethod create(action_name: str | None = None, source_uri: str | None = None, source_type: str | None = None, action_type: str | None = None, description: str | None = None, status: str | None = None, properties: dict | None = None, tags: dict | None = None, sagemaker_session: Session | None = None) Action[source]#

Create an action and return an Action object representing it.

Parameters:
  • action_name (str) – Name of the action

  • source_uri (str) – Source URI of the action

  • source_type (str) – Source type of the action

  • action_type (str) – The type of the action

  • description (str) – Description of the action

  • status (str) – Status of the action.

  • properties (dict) – key/value properties

  • tags (dict) – AWS tags for the action

  • 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 Action object.

Return type:

Action

created_by: str = None#
creation_time: datetime = None#
delete(disassociate: bool = False)[source]#

Delete the action.

Parameters:

disassociate (bool) – When set to true, disassociate incoming and outgoing association.

description: str = None#
last_modified_by: str = None#
last_modified_time: datetime = None#
classmethod list(source_uri: str | None = None, action_type: str | None = None, created_after: datetime | None = None, created_before: datetime | None = None, sort_by: str | None = None, sort_order: str | None = None, sagemaker_session: Session | None = None, max_results: int | None = None, next_token: str | None = None) Iterator[ActionSummary][source]#

Return a list of action summaries.

Parameters:
  • source_uri (str, optional) – A source URI.

  • action_type (str, optional) – An action type.

  • created_before (datetime.datetime, optional) – Return actions created before this instant.

  • created_after (datetime.datetime, optional) – Return actions 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 actions 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 ActionSummary objects.

Return type:

collections.Iterator[ActionSummary]

classmethod load(action_name: str, sagemaker_session=None) Action[source]#

Load an existing action and return an Action object representing it.

Parameters:
  • action_name (str) – Name of the action

  • 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 Action object

Return type:

Action

properties: dict = None#
properties_to_remove: list = None#
save() Action[source]#

Save the state of this Action to SageMaker.

Returns:

A SageMaker ``Action``object.

Return type:

Action

set_tag(tag=None)[source]#

Add a tag to the object.

Args:

Returns:

str}): a list of key value pairs

Return type:

list({str

set_tags(tags=None)[source]#

Add tags to the object.

Parameters:

tags (Optional[Tags]) – list of key value pairs.

Returns:

str}): a list of key value pairs

Return type:

list({str

source: ActionSource = None#
status: str = None#
tags: list = None#
class sagemaker.core.lineage.action.ModelPackageApprovalAction(sagemaker_session=None, **kwargs)[source]#

Bases: Action

An Amazon SageMaker model package approval action, which is part of a SageMaker lineage.

datasets(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.ASCENDANTS) List[Artifact][source]#

Use a lineage query to retrieve all upstream datasets that use this action.

Parameters:

direction (LineageQueryDirectionEnum, optional) – The query direction.

Returns:

Artifacts representing a dataset.

Return type:

list of Artifacts

endpoints(direction: LineageQueryDirectionEnum = LineageQueryDirectionEnum.DESCENDANTS) List[source]#

Use a lineage query to retrieve downstream endpoint contexts that use this action.

Parameters:

direction (LineageQueryDirectionEnum, optional) – The query direction.

Returns:

Contexts representing an endpoint.

Return type:

list of Contexts

model_package()[source]#

Get model package from model package approval action.

Returns:

Model package.