13
13
"""This module contains code to create and manage SageMaker ``Actions``."""
14
14
from __future__ import absolute_import
15
15
16
+ from typing import Type , Iterator , Optional
17
+ from datetime import datetime
18
+
19
+ from sagemaker import Session
16
20
from sagemaker .apiutils import _base_types
17
21
from sagemaker .lineage import _api_types , _utils
22
+ from sagemaker .lineage ._api_types import ActionSource
18
23
19
24
20
25
class Action (_base_types .Record ):
@@ -53,46 +58,46 @@ class Action(_base_types.Record):
53
58
last_modified_by (obj): Contextual info on which account created the action.
54
59
"""
55
60
56
- action_arn = None
57
- action_name = None
58
- action_type = None
59
- description = None
60
- status = None
61
- source = None
62
- properties = None
63
- properties_to_remove = None
64
- tags = None
65
- creation_time = None
66
- created_by = None
67
- last_modified_time = None
68
- last_modified_by = None
69
-
70
- _boto_create_method = "create_action"
71
- _boto_load_method = "describe_action"
72
- _boto_update_method = "update_action"
73
- _boto_delete_method = "delete_action"
74
-
75
- _boto_update_members = [
61
+ action_arn : str = None
62
+ action_name : str = None
63
+ action_type : str = None
64
+ description : str = None
65
+ status : str = None
66
+ source : object = None
67
+ properties : dict [ str , str ] = None
68
+ properties_to_remove : list [ str ] = None
69
+ tags : list [ dict [ str , str ]] = None
70
+ creation_time : datetime = None
71
+ created_by : object = None
72
+ last_modified_time : datetime = None
73
+ last_modified_by : object = None
74
+
75
+ _boto_create_method : str = "create_action"
76
+ _boto_load_method : str = "describe_action"
77
+ _boto_update_method : str = "update_action"
78
+ _boto_delete_method : str = "delete_action"
79
+
80
+ _boto_update_members : list [ str ] = [
76
81
"action_name" ,
77
82
"description" ,
78
83
"status" ,
79
84
"properties" ,
80
85
"properties_to_remove" ,
81
86
]
82
87
83
- _boto_delete_members = ["action_name" ]
88
+ _boto_delete_members : list [ str ] = ["action_name" ]
84
89
85
- _custom_boto_types = {"source" : (_api_types .ActionSource , False )}
90
+ _custom_boto_types : dict [ str , tuple [ Type [ ActionSource ], bool ]] = {"source" : (_api_types .ActionSource , False )}
86
91
87
- def save (self ):
92
+ def save (self ) -> object :
88
93
"""Save the state of this Action to SageMaker.
89
94
90
95
Returns:
91
96
Action: A SageMaker ``Action``object.
92
97
"""
93
98
return self ._invoke_api (self ._boto_update_method , self ._boto_update_members )
94
99
95
- def delete (self , disassociate = False ):
100
+ def delete (self , disassociate : bool = False ):
96
101
"""Delete the action.
97
102
98
103
Args:
@@ -110,7 +115,7 @@ def delete(self, disassociate=False):
110
115
self ._invoke_api (self ._boto_delete_method , self ._boto_delete_members )
111
116
112
117
@classmethod
113
- def load (cls , action_name , sagemaker_session = None ):
118
+ def load (cls , action_name : str , sagemaker_session : Session = None ) -> object :
114
119
"""Load an existing action and return an ``Action`` object representing it.
115
120
116
121
Args:
@@ -130,7 +135,7 @@ def load(cls, action_name, sagemaker_session=None):
130
135
)
131
136
return result
132
137
133
- def set_tag (self , tag = None ):
138
+ def set_tag (self , tag : object = None ) -> list [{ str : str }] :
134
139
"""Add a tag to the object.
135
140
136
141
Args:
@@ -140,7 +145,7 @@ def set_tag(self, tag=None):
140
145
"""
141
146
return self ._set_tags (resource_arn = self .action_arn , tags = [tag ])
142
147
143
- def set_tags (self , tags = None ):
148
+ def set_tags (self , tags : list [{ str : str }] = None ) -> list [{ str : str }] :
144
149
"""Add tags to the object.
145
150
146
151
Args:
@@ -153,17 +158,17 @@ def set_tags(self, tags=None):
153
158
154
159
@classmethod
155
160
def create (
156
- cls ,
157
- action_name = None ,
158
- source_uri = None ,
159
- source_type = None ,
160
- action_type = None ,
161
- description = None ,
162
- status = None ,
163
- properties = None ,
164
- tags = None ,
165
- sagemaker_session = None ,
166
- ):
161
+ cls ,
162
+ action_name : str = None ,
163
+ source_uri : str = None ,
164
+ source_type : str = None ,
165
+ action_type : str = None ,
166
+ description : str = None ,
167
+ status : str = None ,
168
+ properties : dict [ str : str ] = None ,
169
+ tags : list [ dict [ str : str ]] = None ,
170
+ sagemaker_session : Session = None ,
171
+ ) -> object :
167
172
"""Create an action and return an ``Action`` object representing it.
168
173
169
174
Args:
@@ -197,17 +202,17 @@ def create(
197
202
198
203
@classmethod
199
204
def list (
200
- cls ,
201
- source_uri = None ,
202
- action_type = None ,
203
- created_after = None ,
204
- created_before = None ,
205
- sort_by = None ,
206
- sort_order = None ,
207
- sagemaker_session = None ,
208
- max_results = None ,
209
- next_token = None ,
210
- ):
205
+ cls ,
206
+ source_uri : Optional [ str ] = None ,
207
+ action_type : Optional [ str ] = None ,
208
+ created_after : Optional [ datetime ] = None ,
209
+ created_before : Optional [ datetime ] = None ,
210
+ sort_by : Optional [ str ] = None ,
211
+ sort_order : Optional [ str ] = None ,
212
+ sagemaker_session : Session = None ,
213
+ max_results : Optional [ int ] = None ,
214
+ next_token : Optional [ str ] = None ,
215
+ ) -> Iterator :
211
216
"""Return a list of action summaries.
212
217
213
218
Args:
0 commit comments