Git Product home page Git Product logo

sagemaker-studio-auto-shutdown-extension's Introduction

Sagemaker-Studio-Autoshutdown-Extension

This JupyterLab extension automatically shuts down Kernels, Terminals and Apps in Sagemaker Studio when they are idle for a stipulated period of time. You will be able to configure an idle time limit using the user interface this extension provides. Installation instructions are listed below.

This extension is composed of a Python package named sagemaker_studio_autoshutdown for the server extension and a NPM package named sagemaker-studio-autoshutdown for the frontend extension.

Requirements

  • Please ensure your JupyterLab version is >= v1.2.18 and < 2.0. You can check the version by opening a terminal window in SageMaker Studio (File > New -> Terminal) and running the following command: 'jupyter lab --version'

Limitations

The extension currently checks Kernels only and cannot detect idle terminals. Those Apps which has no kernels but has active image terminals will not be terminated.

Installation Steps

There are two options, outlined below, for installing this extension. We also provide a way for mointoring user profiles to ensure extension is installed.

Option #1: Automatic Installation on JupyterLab start-up

Use this option if you have IAM authentication (not SSO) for all users in your SageMaker Studio domain. This option will be ideal if you are administering large number of users. Follow the README in the auto-installer folder.

Option #2: Manual Installation

Use this option if you have fewer users and can administer manually.

  1. Open a Terminal session in your Sagemaker Studio's Jupyter Server. (You can do this by clicking File > New > Terminal)

  2. Download/Clone the current repository by running:

git clone https://github.com/aws-samples/sagemaker-studio-auto-shutdown-extension.git
  1. Change directory to sagemaker-studio-auto-shutdown-extension:
cd sagemaker-studio-auto-shutdown-extension
  1. Run the following script. This step will take about 3 minutes.
./install_tarball.sh
  1. Refresh your IDE to see the extension on the sidebar as shown in the screen shot below:

Monitoring the installation across all users

You can periodically monitor to check if the extension is installed and running across all users, and get notified if it is not. Checkout the folder extension-checker for more information. This feature is only supported in IAM mode, and is not supported in SSO mode.

Idle Time Limit Setting

Idle time limit (in minutes) - This parameter is to set an idle time after which the idle kernels and Apps with no active notebook sessions will be terminated. By default the idle time limit is set to 120 mins. Idle state is decided based on JupyterServer’s implementation of execution_state and last_activity metadata of the kernels. Read this for more information - When is a kernel considered idle? (jupyter/notebook#4634)

Shutting down image terminals

By turning off the "Keep terminals" checkbox on the configuration panel, the extension will terminate all Image Terminals which belongs to applications not having any running kernel session. In this case, the application will be shut down as well. If the "Keep terminals" checkbox is enabled and there is an image terminal is running, the App never will be terminated, even when it has no running kernel session at all.

Handling Apps without kernel and terminal sessions

Studio users have an option to terminate kernels and terminals under an App, but leave the App itself up and running. This can be used to reuse the existing Application later, hence keep the Kernel start-up time low. If the extension is installed, the extension will terminate these "empty" applications after the idle time set, but no earlier than 5 minutes.

Limitations

  1. You will need to reinstall this extension and configure the idle time limit, each time you delete your user's JupyterServer "app" and recreate it. See the auto-installer for an example of how to centrally automate installation.

Troubleshooting

#1 Delete JupyterServer and recreate it. You can do this by selecting the User and going into User Details screen in SageMaker Studio console. It is a two step process: 1/ delete JupyterServer app. 2/ Click on "Open Studio", which will recreate JupterServer with the latest version.

#2 If you are seeing the frontend extension but it is not working, check that the server extension is enabled:

jupyter serverextension list

#3 If the server extension is installed and enabled but you are not seeing the frontend, check the frontend is installed:

jupyter labextension list

If it is not installed, try:

bash install_server_extension.sh
bash install_frontend_extension.sh

Uninstall

pip uninstall sagemaker_studio_autoshutdown
jupyter labextension uninstall sagemaker-studio-autoshutdown

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

sagemaker-studio-auto-shutdown-extension's People

Contributors

amazon-auto avatar athewsey avatar garzoand avatar mikegchambers avatar pavankumar2203 avatar rags1357 avatar rthamman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.