Skip to content

Commit

Permalink
Joywa/sagemakerlc (aws#58)
Browse files Browse the repository at this point in the history
* Create README.md

How to launch graph-notebook using lifecycle configurations

* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Create Notebook Step

* Delete Create-Notebook-Instance.png

* Create Notebook with Lifecycle

* Update README.md

* Delete install-graph-notebook-lc.sh

* Lifecycle config script
  • Loading branch information
joywa authored Jan 15, 2021
1 parent bdd88d7 commit 0e08b65
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
8 changes: 8 additions & 0 deletions additional-databases/sagemaker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Launching graph-notebook using Amazon SageMaker
You can easily launch instances of graph-notebook on Amazon SageMaker by using a lifecycle configuration. To learn more about lifecycle configurations and how to create one, see [documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/notebook-lifecycle-config.html).

Use the sample lifecycle configuration in this folder, [`install-graph-notebook-lc.sh`](install-graph-notebook-lc.sh) or create your own shell script.

After you create a lifecycle configuration on SageMaker, you can create new notebook instances by specifying a saved lifecycle configuration:

![create-a-notebook](/././images/Create-Notebook-Instance.png)
68 changes: 68 additions & 0 deletions additional-databases/sagemaker/install-graph-notebook-lc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

sudo -u ec2-user -i <<'EOF'
echo "export GRAPH_NOTEBOOK_AUTH_MODE=DEFAULT" >> ~/.bashrc # set to IAM instead of DEFAULT if cluster is IAM enabled
echo "export GRAPH_NOTEBOOK_HOST=CHANGE-ME" >> ~/.bashrc
echo "export GRAPH_NOTEBOOK_PORT=8182" >> ~/.bashrc
echo "export NEPTUNE_LOAD_FROM_S3_ROLE_ARN=" >> ~/.bashrc
echo "export AWS_REGION=us-west-2" >> ~/.bashrc
source activate JupyterSystemEnv
echo "installing Python 3 kernel"
python3 -m ipykernel install --sys-prefix --name python3 --display-name "Python 3"
echo "installing python dependencies..."
pip uninstall NeptuneGraphNotebook -y # legacy uninstall when we used to install from source in s3
pip install --upgrade graph-notebook
echo "installing nbextensions..."
python -m graph_notebook.nbextensions.install
echo "installing static resources..."
python -m graph_notebook.static_resources.install
echo "enabling visualization..."
jupyter nbextension install --py --sys-prefix graph_notebook.widgets
jupyter nbextension enable --py --sys-prefix graph_notebook.widgets
mkdir -p ~/SageMaker/Neptune
cd ~/SageMaker/Neptune || exit
python -m graph_notebook.notebooks.install
chmod -R a+rw ~/SageMaker/Neptune/*
source ~/.bashrc || exit
HOST=${GRAPH_NOTEBOOK_HOST}
PORT=${GRAPH_NOTEBOOK_PORT}
AUTH_MODE=${GRAPH_NOTEBOOK_AUTH_MODE}
SSL=${GRAPH_NOTEBOOK_SSL}
IAM_CREDENTIALS_PROVIDER=${GRAPH_NOTEBOOK_IAM_PROVIDER}
LOAD_FROM_S3_ARN=${NEPTUNE_LOAD_FROM_S3_ROLE_ARN}
if [[ ${SSL} -eq "" ]]; then
SSL="True"
fi
echo "Creating config with
HOST: ${HOST}
PORT: ${PORT}
AUTH_MODE: ${AUTH_MODE}
SSL: ${SSL}
IAM_CREDENTIALS_PROVIDER: ${IAM_CREDENTIALS_PROVIDER}
AWS_REGION: ${AWS_REGION}"
/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/python -m graph_notebook.configuration.generate_config \
--host "${HOST}" \
--port "${PORT}" \
--auth_mode "${AUTH_MODE}" \
--ssl "${SSL}" \
--iam_credentials_provider "${IAM_CREDENTIALS_PROVIDER}" \
--load_from_s3_arn "${LOAD_FROM_S3_ARN}" \
--aws_region "${AWS_REGION}"
source /home/ec2-user/anaconda3/bin/deactivate
echo "done."
EOF
Binary file added images/Create-Notebook-Instance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e08b65

Please sign in to comment.