How to set model custom metadata in Sagemaker ML pipeline

0

Hi there,

I am interested in using model custom metadata. Looks like it got released recently.
https://aws.amazon.com/about-aws/whats-new/2021/12/sagemaker-model-registry-endpoint-visibility-custom-metadata-model-metrics/

Metadata can be set and read successfully via cli aws sagemaker describe-model-package --model-package-name "arn:aws:sagemaker:us-east-1:ACCOUNT:model-package/MODEL_PACKAGE_NAME/1"

aws --profile dev sagemaker describe-model-package --model-package-name "arn:aws:sagemaker:us-east-1:ACCOUNT:model-package/MODEL_PACKAGE_NAME/1" | jq .CustomerMetadataProperties { "KeyName1": "string2", "KeyName2": "string2" }

However, it is not clear how custom metadata can be set in Sagemaker ML pipeline when model is train and registered using RegisterModel

Thanks in advance.

crawlik
demandé il y a 2 ans2030 vues
3 réponses
2
Réponse acceptée

Have you tried using this parameter on the RegisterModel step?

AWS
répondu il y a 2 ans
  • Perfect timing. This support got added 2 days ago! Thanks for pointing to it.

1

That is correct. Figured that. Looks like one to call that API is to have LambaStep and chain it after RegisterModel step . Here is lambda implementation. Feels a bit heavy workaround for this objective. So let me know if there is a better /lighter way to achieving the same. Thanks.

sagemaker_client = client = boto3.client("sagemaker")
def lambda_handler(event, context):

    print(boto3.__version__)
    logger.info(f"Received Event: {event}")
    logger.info(f"Boto version: {boto3.__version__}")
    
    model_arn = event['model_arn']
    model_arn = 'arn:aws:sagemaker:us-east-1:ACCOUNT:model-package/model_package_name/version'
    response = client.describe_model_package(
        ModelPackageName=model_arn
    )
    help(client.update_model_package)
    response = client.update_model_package(
        ModelPackageArn=model_arn,
        ModelApprovalStatus=response['ModelApprovalStatus'],
        CustomerMetadataProperties={'string': 'string'},
    )

    return {"statusCode": 200, "body": json.dumps("Model metadata updated successfully")}
crawlik
répondu il y a 2 ans
  • The only problem with approach getting registered model ARN in SageMaker pipelines. It is buried somewhere in RegisterModel step, but I can't seem to figure out how to extract it. However, SM Studio does access it and shows in UI as step output.

0

Hi,

You can use the UpdateModelPackage API to update custom metadata properties on an already registered model package whether it's in a pipeline or not.

AWS
répondu il y a 2 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions