Skip to main content

CLI to interact with SageMaker Studio

Project description

SageMaker Studio CLI

SageMaker Studio CLI is an open source command-line utility for interacting with Amazon SageMaker Unified Studio. With this CLI, you can access SageMaker Unified Studio resources and run both local and remote executions.

Table of Contents

  1. Installation
  2. Usage
    1. Setting up Credentials
      1. AWS Named Profile
    2. Commands
      1. credentials
        1. get-domain-execution-role-credential-in-space
      2. project
        1. get-project-default-environment
      3. git
        1. get-clone-url
      4. execution
        1. start
        2. get
        3. list
        4. stop

1) Installation

The SageMaker Studio CLI is built to PyPI, and the latest version of the CLI can be installed using the following command:

pip install sagemaker-studio

Supported Python Versions

SageMaker Studio CLI supports Python versions 3.9 and newer.

Licensing

SageMaker Studio CLI is licensed under the Apache 2.0 License. It is copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. The license is available at: http://aws.amazon.com/apache2.0/

2) Usage

Setting Up Credentials

If SageMaker Studio CLI is being used within SageMaker Unified Studio JupyterLab, the CLI will automatically pull your latest credentials from the environment.

If you are using the CLI elsewhere, or if you want to use different credentials within SageMaker Unified Studio JupyterLab, you will need to first retrieve your SageMaker Unified Studio credentials and make them available in the environment by storing them within an AWS named profile. If you are using a profile name other than default, you need to supply the profile name using one of the following methods:

  1. Supplying it as part of your CLI command (e.g. --profile my_profile_name)
  2. Setting the AWS profile name as an environment variable (e.g. export AWS_PROFILE="my_profile_name")
AWS Named Profile

To create an AWS named profile, you can update your AWS config file with your profile name and any other settings you would like to use:

[my_profile_name]
region = us-east-1

Your credentials file should have the credentials stored for your profile:

[my_profile_name]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
aws_session_token=IQoJb3JpZ2luX2IQoJb3JpZ2luX2IQoJb3JpZ2luX2IQoJb3JpZ2luX2IQoJb3JpZVERYLONGSTRINGEXAMPLE

Finally, you can use this profile my_profile_name through any of the three methods listed in the above section.

Commands

SageMaker Studio CLI has several commands that you can use to interact with your resources within SageMaker Unified Studio.

credentials

get-domain-execution-role-credential-in-space

The following command prints domain execution role credentials for a space.

sagemaker-studio credentials get-domain-execution-role-credential-in-space --domain-id <domain_id>

project

get-project-default-environment

The following command prints the details of the default environment within your project.

sagemaker-studio project get-project-default-environment --project-id <project_id> --domain-id <domain_id>

git

get-clone-url

The following command prints the clone URL for the project's Git repository.

sagemaker-studio git get-clone-url --project-id <project_id> --domain-id <domain_id>

execution

start

The following command starts an execution in the user's space.

sagemaker-studio execution start --execution-name <execution-name> --input-config '{ "notebook_config": { "input_path": <input_path_relative to user's home directory> } } '

To start the execution on remote compute, pass the --remote flag and other required parameters like --compute in the following command.

sagemaker-studio execution start --remote --execution-name <execution-name> --input-config '{ "notebook_config": { "input_path": <input_path_relative to user's home directory> } } ' --compute '{ "instance_type": "ml.c4.2xlarge", "image_details": { "image_name": "sagemaker-distribution-embargoed-prod", "image_version": "3.0" }}'
get

The following command gets details of an execution running in the user's space.

sagemaker-studio execution get --execution-id <execution-id>

To get the details of an execution running on remote compute, pass the --remote flag in the following command.

sagemaker-studio execution get --execution-id <execution-id> --remote
list

The following command lists executions running in the user's space.

sagemaker-studio execution list

The following optional filters are supported:

  • --name-contains <name>
  • --status valid values: ['IN_PROGRESS', 'COMPLETED', 'FAILED', 'STOPPING', 'STOPPED']
  • --sort-by valid values: ['NAME', 'STATUS', 'START_TIME', 'END_TIME']
  • --sort-order valid values: ['ASCENDING', 'DESCENDING']
  • --start-time-after <timestamp_in_millis>
  • --next-token <next_token>
  • --max-items <int>
sagemaker-studio execution list --name-contains "asdf" --status COMPLETED --sort-order ASCENDING --start-time-after 1730327776000

To list executions running on remote compute, pass the --remote flag in the following command.

sagemaker-studio execution list --remote --name-contains "asdf" --status COMPLETED --sort-order ASCENDING --start-time-after 1730327776000

The following optional filters are supported:

  • --name-contains <name>
  • --status valid values: ['IN_PROGRESS', 'COMPLETED', 'FAILED', 'STOPPING', 'STOPPED']
  • --sort-by valid values: ['NAME', 'STATUS', 'START_TIME', 'END_TIME']
  • --sort-order valid values: ['ASCENDING', 'DESCENDING']
  • --start-time-after <timestamp_in_millis>
  • --next-token <next_token>
  • --max-items <int>
  • --filter-by-tags <dict>
stop

The following command stops an execution running in the user's space.

sagemaker-studio execution stop --execution-id <execution-id>

To stop an execution running on remote compute, pass the --remote flag in the following command.

sagemaker-studio execution stop --execution-id <execution-id> --remote

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sagemaker_studio_cli-1.0.7.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sagemaker_studio_cli-1.0.7-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file sagemaker_studio_cli-1.0.7.tar.gz.

File metadata

  • Download URL: sagemaker_studio_cli-1.0.7.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for sagemaker_studio_cli-1.0.7.tar.gz
Algorithm Hash digest
SHA256 aebc58e09fe6d2a1c8573b3985ace9cc26e9a51403a3c3dc01a0a29c50cd7832
MD5 fb61b046ec74d39c638d3da650ae5ef6
BLAKE2b-256 25b7113ce82e69a982210c0bf6bad53c10cd44e417920b92208b01d75375b7bc

See more details on using hashes here.

File details

Details for the file sagemaker_studio_cli-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for sagemaker_studio_cli-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7ade8cae05aa4be998f1c9acdd5220693eea34d4c9f21df5da06ba4ba7b24c50
MD5 884114078f38a1a02652d24a028fa55d
BLAKE2b-256 059c8d8a84d42ca3039b12755fb7d66eac74d1557eb1614648beee709415fe34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page