TobyTYL / SageMaker-Practice-on-AWS

SageMaker Practice on AWS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SageMaker Hands-On on AWS

ViewCount GitHub top language GitHub language count Stars Badge Forks Badge Pull Requests Badge Total Downloads

💻 Practical Appilcation of Real Life Scenarios on AWS SageMaker Studio / Notebook Instances

Name Source
Employee Salary Prediction - Using AWS SageMaker Linear Learner Udemy
Medical Insurance Premium Prediction - Linear Learner - Artificial Neural Network Udemy
Retail Sales Prediction - Using AWS SageMaker XGBoost (Regression) Udemy

🤺 AWS Sagemaker CLI Commands

1. Retrieve the list of domains in your account.
aws --region Region sagemaker list-domains

Example

aws --region us-east-2 sagemaker list-domains

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker list-domains
{
    "Domains": [
        {
            "DomainArn": "arn:aws:sagemaker:us-east-2:807100423897:domain/d-mxkxcy82frnd",
            "DomainId": "d-mxkxcy82frnd",
            "DomainName": "default-1634999453430",
            "Status": "InService",
            "CreationTime": "2021-10-23T14:30:55.857000+00:00",
            "LastModifiedTime": "2021-10-23T14:35:41.514000+00:00",
            "Url": "https://d-mxkxcy82frnd.studio.us-east-2.sagemaker.aws"
        }
    ]
}
2. Retrieve the list of applications for the domain to be deleted.
aws --region Region sagemaker list-apps \
    --domain-id-equals DomainId

Example

aws --region us-east-2 sagemaker list-apps \
        --domain-id-equals d-mxkxcy82frnd

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker list-apps \
>         --domain-id-equals d-mxkxcy82frnd
{
    "Apps": [
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "KernelGateway",
            "AppName": "datascience-1-0-ml-t3-medium-b3043d3e6163713f99726df4a911",
            "Status": "InService",
            "CreationTime": "2021-10-23T14:40:45.328000+00:00"
        },
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "JupyterServer",
            "AppName": "default",
            "Status": "InService",
            "CreationTime": "2021-10-23T14:36:16.825000+00:00"
        }
    ]
}
3. Delete each application in the list.
aws --region Region sagemaker delete-app \
    --domain-id DomainId \
    --app-name AppName \
    --app-type AppType \
    --user-profile-name UserProfileName

Example

aws --region us-east-2 sagemaker delete-app \
    --domain-id d-mxkxcy82frnd \
    --app-name default \
    --app-type JupyterServer \
    --user-profile-name debdattasagemaker

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker delete-app \
>     --domain-id d-mxkxcy82frnd \
>     --app-name default \
>     --app-type JupyterServer \
>     --user-profile-name debdattasagemaker

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker list-apps \
>         --domain-id-equals d-mxkxcy82frnd
{
    "Apps": [
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "KernelGateway",
            "AppName": "datascience-1-0-ml-t3-medium-b3043d3e6163713f99726df4a911",
            "Status": "InService",
            "CreationTime": "2021-10-23T14:40:45.328000+00:00"
        },
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "JupyterServer",
            "AppName": "default",
            "Status": "Deleted",
            "CreationTime": "2021-10-23T14:36:16.825000+00:00"
        }
    ]
}
aws --region us-east-2 sagemaker delete-app \
    --domain-id d-mxkxcy82frnd \
    --app-name datascience-1-0-ml-t3-medium-b3043d3e6163713f99726df4a911 \
    --app-type KernelGateway \
    --user-profile-name debdattasagemaker

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker list-apps         --domain-id-equals d-mxkxcy82frnd{
    "Apps": [
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "KernelGateway",
            "AppName": "datascience-1-0-ml-t3-medium-b3043d3e6163713f99726df4a911",
            "Status": "Deleted",
            "CreationTime": "2021-10-23T14:40:45.328000+00:00"
        },
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "AppType": "JupyterServer",
            "AppName": "default",
            "Status": "Deleted",
            "CreationTime": "2021-10-23T14:36:16.825000+00:00"
        }
    ]
}
4. Retrieve the list of user profiles in the domain.
aws --region Region sagemaker list-user-profiles \
    --domain-id-equals DomainId

Example

aws --region us-east-2 sagemaker list-user-profiles \
    --domain-id-equals d-mxkxcy82frnd

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker list-user-profiles \
>     --domain-id-equals d-mxkxcy82frnd
{
    "UserProfiles": [
        {
            "DomainId": "d-mxkxcy82frnd",
            "UserProfileName": "debdattasagemaker",
            "Status": "InService",
            "CreationTime": "2021-10-23T14:35:46.247000+00:00",
            "LastModifiedTime": "2021-10-23T14:35:50.802000+00:00"
        }
    ]
}
5. Delete each user profile in the list.
aws --region Region sagemaker delete-user-profile \
    --domain-id DomainId \
    --user-profile-name UserProfileName

Example

aws --region us-east-2 sagemaker delete-user-profile \
    --domain-id d-mxkxcy82frnd \
    --user-profile-name 

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker delete-user-profile \
>    --domain-id d-mxkxcy82frnd \
>    --user-profile-name debdattasagemaker
6. Delete the domain. To also delete the Amazon EFS volume, specify HomeEfsFileSystem=Delete.
aws --region Region sagemaker delete-domain \
    --domain-id DomainId \
    --retention-policy HomeEfsFileSystem=Retain

Example

aws --region us-east-2 sagemaker delete-domain \
    --domain-id d-mxkxcy82frnd \
    --retention-policy HomeEfsFileSystem=Delete

Output

[cloudshell-user@ip-10-0-137-51 ~]$ aws --region us-east-2 sagemaker delete-domain \
>     --domain-id d-mxkxcy82frnd \
>     --retention-policy HomeEfsFileSystem=Delete

⛏️ Skills Applied

Python Pandas NumPy scikit-learn AWS Jupyter TensorFlow Keras

© Copyright 2021 - Debdatta Sarkar

LinkedIn Profile

About

SageMaker Practice on AWS

License:MIT License


Languages

Language:Jupyter Notebook 100.0%