@@ -163,12 +163,15 @@ class IngestionManagerPandas:
163
163
max_workers (int): number of threads to create.
164
164
max_processes (int): number of processes to create. Each process spawns
165
165
``max_workers`` threads.
166
+ profile_name (str): the profile credential should be used for ``PutRecord``
167
+ (default: None).
166
168
"""
167
169
168
170
feature_group_name : str = attr .ib ()
169
171
sagemaker_fs_runtime_client_config : Config = attr .ib ()
170
172
max_workers : int = attr .ib (default = 1 )
171
173
max_processes : int = attr .ib (default = 1 )
174
+ profile_name : str = attr .ib (default = None )
172
175
_async_result : AsyncResult = attr .ib (default = None )
173
176
_processing_pool : ProcessingPool = attr .ib (default = None )
174
177
_failed_indices : List [int ] = attr .ib (factory = list )
@@ -180,6 +183,7 @@ def _ingest_single_batch(
180
183
client_config : Config ,
181
184
start_index : int ,
182
185
end_index : int ,
186
+ profile_name : str = None ,
183
187
) -> List [int ]:
184
188
"""Ingest a single batch of DataFrame rows into FeatureStore.
185
189
@@ -190,6 +194,8 @@ def _ingest_single_batch(
190
194
client to perform boto calls.
191
195
start_index (int): starting position to ingest in this batch.
192
196
end_index (int): ending position to ingest in this batch.
197
+ profile_name (str): the profile credential should be used for ``PutRecord``
198
+ (default: None).
193
199
194
200
Returns:
195
201
List of row indices that failed to be ingested.
@@ -198,7 +204,7 @@ def _ingest_single_batch(
198
204
if "max_attempts" not in retry_config and "total_max_attempts" not in retry_config :
199
205
client_config = copy .deepcopy (client_config )
200
206
client_config .retries = {"max_attempts" : 10 , "mode" : "standard" }
201
- sagemaker_featurestore_runtime_client = boto3 .Session ().client (
207
+ sagemaker_featurestore_runtime_client = boto3 .Session (profile_name = profile_name ).client (
202
208
service_name = "sagemaker-featurestore-runtime" , config = client_config
203
209
)
204
210
@@ -287,6 +293,7 @@ def _run_multi_process(self, data_frame: DataFrame, wait=True, timeout=None):
287
293
data_frame [start_index :end_index ],
288
294
start_index ,
289
295
timeout ,
296
+ self .profile_name ,
290
297
)
291
298
]
292
299
@@ -311,6 +318,7 @@ def _run_multi_threaded(
311
318
data_frame : DataFrame ,
312
319
row_offset = 0 ,
313
320
timeout = None ,
321
+ profile_name = None ,
314
322
) -> List [int ]:
315
323
"""Start the ingestion process.
316
324
@@ -321,6 +329,8 @@ def _run_multi_threaded(
321
329
wait (bool): whether to wait for the ingestion to finish or not.
322
330
timeout (Union[int, float]): ``concurrent.futures.TimeoutError`` will be raised
323
331
if timeout is reached.
332
+ profile_name (str): the profile credential should be used for ``PutRecord``
333
+ (default: None).
324
334
325
335
Returns:
326
336
List of row indices that failed to be ingested.
@@ -342,6 +352,7 @@ def _run_multi_threaded(
342
352
start_index = start_index ,
343
353
end_index = end_index ,
344
354
client_config = sagemaker_fs_runtime_client_config ,
355
+ profile_name = profile_name ,
345
356
)
346
357
] = (start_index + row_offset , end_index + row_offset )
347
358
@@ -581,6 +592,7 @@ def ingest(
581
592
max_processes : int = 1 ,
582
593
wait : bool = True ,
583
594
timeout : Union [int , float ] = None ,
595
+ profile_name : str = None ,
584
596
) -> IngestionManagerPandas :
585
597
"""Ingest the content of a pandas DataFrame to feature store.
586
598
@@ -599,6 +611,11 @@ def ingest(
599
611
They can also be found from the IngestionManagerPandas' ``failed_rows`` function after
600
612
the exception is thrown.
601
613
614
+ `profile_name` argument is an optional one. It will use the default credential if None is
615
+ passed. This `profile_name` is used in the sagemaker_featurestore_runtime client only. See
616
+ https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html for more
617
+ about the default credential.
618
+
602
619
Args:
603
620
data_frame (DataFrame): data_frame to be ingested to feature store.
604
621
max_workers (int): number of threads to be created.
@@ -607,6 +624,8 @@ def ingest(
607
624
wait (bool): whether to wait for the ingestion to finish or not.
608
625
timeout (Union[int, float]): ``concurrent.futures.TimeoutError`` will be raised
609
626
if timeout is reached.
627
+ profile_name (str): the profile credential should be used for ``PutRecord``
628
+ (default: None).
610
629
611
630
Returns:
612
631
An instance of IngestionManagerPandas.
@@ -622,6 +641,7 @@ def ingest(
622
641
sagemaker_fs_runtime_client_config = self .sagemaker_session .sagemaker_featurestore_runtime_client .meta .config ,
623
642
max_workers = max_workers ,
624
643
max_processes = max_processes ,
644
+ profile_name = profile_name ,
625
645
)
626
646
627
647
manager .run (data_frame = data_frame , wait = wait , timeout = timeout )
0 commit comments