Skip to content

Instantly share code, notes, and snippets.

@sofianhamiti
Created June 1, 2022 14:22
Show Gist options
  • Save sofianhamiti/a3dd58a24677719ca64a0f40e7e722f7 to your computer and use it in GitHub Desktop.
Save sofianhamiti/a3dd58a24677719ca64a0f40e7e722f7 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
#################################################
## INSTALL DEPENDENCIES AND PULL CONTAINER IMAGE
#################################################
echo ==INSTALLING DEPENDENCIES==
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/pip install -U jupyter-server-proxy
/usr/bin/docker pull heartexlabs/label-studio:latest
#################################################
### INTEGRATE LABEL-STUDIO WITH JUPYTER
#################################################
echo ==UPDATING JUPYTER SERVER CONFIG==
# Strip out the name of the notebook from the instance bootstrap and the region details from aws/config
INSTANCE_NAME=$(grep notebook_uri /etc/opt/ml/sagemaker-notebook-instance-config.json| sed 's/.*(\(.*\))/\1/' | awk -F'|' '{print $1}')
AWS_REGION=$(cat /home/ec2-user/.aws/config | grep region | awk '{print $NF}')
cat >>/home/ec2-user/.jupyter/jupyter_notebook_config.py <<EOC
c.ServerProxy.servers = {
'label-studio': {
'launcher_entry': {
'enabled': True,
'title': 'Label Studio',
},
'command': ['/usr/bin/docker', 'run', '-t', '-p', '{port}:8080', '-v', '/home/ec2-user/SageMaker/mydata:/label-studio/data', 'heartexlabs/label-studio:latest', 'label-studio', '--host', 'https://$INSTANCE_NAME.notebook.$AWS_REGION.sagemaker.aws/proxy/{port}'],
'absolute_url': False,
'timeout': 60
}
}
EOC
echo ==INSTALL SUCCESSFUL. RESTARTING JUPYTER==
# RESTART THE JUPYTER SERVER
systemctl restart jupyter-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment