1

使用 SageMaker Python SDK 删除特征组的方法如下:

my_feature_group.delete()

但这只会删除您当前正在处理的功能组。如何从以前的会话中删除功能组?我尝试直接将它们从 S3 存储桶中删除,但它们仍然出现在 Feature Store UI 中。

如果可以通过 UI 删除功能组,那就太好了。但如果没有,有没有办法使用全名删除功能组?使用以下方法创建的那个:

my-feature-group-" + strftime("%d-%H-%M-%S", gmtime())
4

2 回答 2

2

您可以创建FeatureGroup对象并调用delete或通过cliSageMakerFeatureStoreRuntime客户端

来源:aws

于 2021-07-22T17:21:13.770 回答
0

您可以循环list_feature_groups如下:

def extract_feature_groups(feature_groups):
    list_feature_groups = []
    list_feature_groups.extend([x['FeatureGroupName'] for x in feature_groups['FeatureGroupSummaries']])
    next_token = '' if not ('NextToken' in feature_groups.keys()) else feature_groups['NextToken']
    while not (next_token==''):
        page_feature_groups = boto_client.list_feature_groups(NextToken=next_token)
        list_feature_groups.extend([x['FeatureGroupName'] for x in page_feature_groups['FeatureGroupSummaries']])
        next_token = '' if not ('NextToken' in page_feature_groups.keys()) else page_feature_groups['NextToken']
    return list_feature_groups

region_name = <your_region_name>
boto_client = boto3.client('sagemaker', region_name=region_name)
boto_session = boto3.session.Session(region_name=region_name)
fs_sagemaker_session = sagemaker.Session(boto_session=boto_session)
feature_groups = boto_client.list_feature_groups()
list_features_groups = extract_feature_groups(feature_groups)

for fg in list_features_groups:
            <make sure to include appropriate name filter and/or confirmation requests>
            feature_group = FeatureGroup(name = feature, sagemaker_session = fs_sagemaker_session)
            feature_group.delete()

特征组需要时间来完成删除;您可能想添加一个检查删除是否成功结束的功能。

于 2021-12-23T10:18:54.023 回答