@@ -312,7 +312,7 @@ def download_data(self, path, bucket, key_prefix="", extra_args=None):
312
312
# For each object key, create the directory on the local machine if needed, and then
313
313
# download the file.
314
314
for key in keys :
315
- tail_s3_uri_path = os .path .basename (key_prefix )
315
+ tail_s3_uri_path = os .path .basename (key )
316
316
if not os .path .splitext (key_prefix )[1 ]:
317
317
tail_s3_uri_path = os .path .relpath (key , key_prefix )
318
318
destination_path = os .path .join (path , tail_s3_uri_path )
@@ -2121,6 +2121,7 @@ def tune( # noqa: C901
2121
2121
stop_condition ,
2122
2122
tags ,
2123
2123
warm_start_config ,
2124
+ strategy_config = None ,
2124
2125
enable_network_isolation = False ,
2125
2126
image_uri = None ,
2126
2127
algorithm_arn = None ,
@@ -2136,6 +2137,8 @@ def tune( # noqa: C901
2136
2137
Args:
2137
2138
job_name (str): Name of the tuning job being created.
2138
2139
strategy (str): Strategy to be used for hyperparameter estimations.
2140
+ strategy_config (dict): A configuration for the hyperparameter tuning
2141
+ job optimisation strategy.
2139
2142
objective_type (str): The type of the objective metric for evaluating training jobs.
2140
2143
This value can be either 'Minimize' or 'Maximize'.
2141
2144
objective_metric_name (str): Name of the metric for evaluating training jobs.
@@ -2220,6 +2223,7 @@ def tune( # noqa: C901
2220
2223
objective_metric_name = objective_metric_name ,
2221
2224
parameter_ranges = parameter_ranges ,
2222
2225
early_stopping_type = early_stopping_type ,
2226
+ strategy_config = strategy_config ,
2223
2227
),
2224
2228
"TrainingJobDefinition" : self ._map_training_config (
2225
2229
static_hyperparameters = static_hyperparameters ,
@@ -2375,6 +2379,7 @@ def _map_tuning_config(
2375
2379
objective_type = None ,
2376
2380
objective_metric_name = None ,
2377
2381
parameter_ranges = None ,
2382
+ strategy_config = None ,
2378
2383
):
2379
2384
"""Construct tuning job configuration dictionary.
2380
2385
@@ -2392,6 +2397,8 @@ def _map_tuning_config(
2392
2397
objective_metric_name (str): Name of the metric for evaluating training jobs.
2393
2398
parameter_ranges (dict): Dictionary of parameter ranges. These parameter ranges can
2394
2399
be one of three types: Continuous, Integer, or Categorical.
2400
+ strategy_config (dict): A configuration for the hyperparameter tuning job optimisation
2401
+ strategy.
2395
2402
2396
2403
Returns:
2397
2404
A dictionary of tuning job configuration. For format details, please refer to
@@ -2415,6 +2422,8 @@ def _map_tuning_config(
2415
2422
if parameter_ranges is not None :
2416
2423
tuning_config ["ParameterRanges" ] = parameter_ranges
2417
2424
2425
+ if strategy_config is not None :
2426
+ tuning_config ["StrategyConfig" ] = strategy_config
2418
2427
return tuning_config
2419
2428
2420
2429
@classmethod
@@ -4332,6 +4341,56 @@ def update_feature_group(
4332
4341
FeatureGroupName = feature_group_name , FeatureAdditions = feature_additions
4333
4342
)
4334
4343
4344
+ def list_feature_groups (
4345
+ self ,
4346
+ name_contains ,
4347
+ feature_group_status_equals ,
4348
+ offline_store_status_equals ,
4349
+ creation_time_after ,
4350
+ creation_time_before ,
4351
+ sort_order ,
4352
+ sort_by ,
4353
+ max_results ,
4354
+ next_token ,
4355
+ ) -> Dict [str , Any ]:
4356
+ """List all FeatureGroups satisfying given filters.
4357
+
4358
+ Args:
4359
+ name_contains (str): A string that partially matches one or more FeatureGroups' names.
4360
+ Filters FeatureGroups by name.
4361
+ feature_group_status_equals (str): A FeatureGroup status.
4362
+ Filters FeatureGroups by FeatureGroup status.
4363
+ offline_store_status_equals (str): An OfflineStore status.
4364
+ Filters FeatureGroups by OfflineStore status.
4365
+ creation_time_after (datetime.datetime): Use this parameter to search for FeatureGroups
4366
+ created after a specific date and time.
4367
+ creation_time_before (datetime.datetime): Use this parameter to search for FeatureGroups
4368
+ created before a specific date and time.
4369
+ sort_order (str): The order in which FeatureGroups are listed.
4370
+ sort_by (str): The value on which the FeatureGroup list is sorted.
4371
+ max_results (int): The maximum number of results returned by ListFeatureGroups.
4372
+ next_token (str): A token to resume pagination of ListFeatureGroups results.
4373
+ Returns:
4374
+ Response dict from service.
4375
+ """
4376
+ list_feature_groups_args = {}
4377
+
4378
+ def check_object (key , value ):
4379
+ if value is not None :
4380
+ list_feature_groups_args [key ] = value
4381
+
4382
+ check_object ("NameContains" , name_contains )
4383
+ check_object ("FeatureGroupStatusEquals" , feature_group_status_equals )
4384
+ check_object ("OfflineStoreStatusEquals" , offline_store_status_equals )
4385
+ check_object ("CreationTimeAfter" , creation_time_after )
4386
+ check_object ("CreationTimeBefore" , creation_time_before )
4387
+ check_object ("SortOrder" , sort_order )
4388
+ check_object ("SortBy" , sort_by )
4389
+ check_object ("MaxResults" , max_results )
4390
+ check_object ("NextToken" , next_token )
4391
+
4392
+ return self .sagemaker_client .list_feature_groups (** list_feature_groups_args )
4393
+
4335
4394
def update_feature_metadata (
4336
4395
self ,
4337
4396
feature_group_name : str ,
@@ -4399,6 +4458,48 @@ def put_record(
4399
4458
Record = record ,
4400
4459
)
4401
4460
4461
+ def delete_record (
4462
+ self ,
4463
+ feature_group_name : str ,
4464
+ record_identifier_value_as_string : str ,
4465
+ event_time : str ,
4466
+ ):
4467
+ """Deletes a single record from the FeatureGroup.
4468
+
4469
+ Args:
4470
+ feature_group_name (str): name of the FeatureGroup.
4471
+ record_identifier_value_as_string (str): name of the record identifier.
4472
+ event_time (str): a timestamp indicating when the deletion event occurred.
4473
+ """
4474
+ return self .sagemaker_featurestore_runtime_client .delete_record (
4475
+ FeatureGroupName = feature_group_name ,
4476
+ RecordIdentifierValueAsString = record_identifier_value_as_string ,
4477
+ EventTime = event_time ,
4478
+ )
4479
+
4480
+ def get_record (
4481
+ self ,
4482
+ record_identifier_value_as_string : str ,
4483
+ feature_group_name : str ,
4484
+ feature_names : Sequence [str ],
4485
+ ) -> Dict [str , Sequence [Dict [str , str ]]]:
4486
+ """Gets a single record in the FeatureGroup.
4487
+
4488
+ Args:
4489
+ record_identifier_value_as_string (str): name of the record identifier.
4490
+ feature_group_name (str): name of the FeatureGroup.
4491
+ feature_names (Sequence[str]): list of feature names.
4492
+ """
4493
+ get_record_args = {
4494
+ "FeatureGroupName" : feature_group_name ,
4495
+ "RecordIdentifierValueAsString" : record_identifier_value_as_string ,
4496
+ }
4497
+
4498
+ if feature_names :
4499
+ get_record_args ["FeatureNames" ] = feature_names
4500
+
4501
+ return self .sagemaker_featurestore_runtime_client .get_record (** get_record_args )
4502
+
4402
4503
def start_query_execution (
4403
4504
self ,
4404
4505
catalog : str ,
0 commit comments