Skip to content

Commit

Permalink
fix: revert all changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SanketD92 committed Jan 26, 2023
1 parent 2ab3a8d commit cb64b62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 780 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ update_jupyter_config() {
from notebook.services.sessions.sessionmanager import SessionManager as BaseSessionManager
from notebook.services.kernels.kernelmanager import AsyncMappingKernelManager
class CustomSessionManager(BaseSessionManager):
def __init__(self, *args, **kwargs):
"""Override default __init__() method"""
class SessionManager(BaseSessionManager):
def list_sessions(self, *args, **kwargs):
"""Override default list_sessions() method"""
self.mount_studies()
result = super(CustomSessionManager, self).__init__(*args, **kwargs)
result = super(SessionManager, self).list_sessions(*args, **kwargs)
return result
def mount_studies(self):
"""Execute mount_s3.sh if mounting hasn't been done yet"""
path = "~/studies"
isExist = os.path.exists(path)
if not isExist:
"""Execute mount_s3.sh if it hasn't already been run"""
if not hasattr(self, 'studies_mounted'):
mounting_result = subprocess.run(
"mount_s3.sh",
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
Expand All @@ -68,9 +65,8 @@ update_jupyter_config() {
for line in mounting_result.stdout.decode("utf-8").split("\n"):
if line: # Skip empty lines
self.log.info(line)
c.NotebookApp.session_manager_class = CustomSessionManager
c.NotebookApp.kernel_manager_class = AsyncMappingKernelManager
self.studies_mounted = True
c.NotebookApp.session_manager_class = SessionManager
EOF
}

Expand Down Expand Up @@ -174,10 +170,7 @@ case "$(env_type)" in
sudo yum --disablerepo=* localinstall -y *.rpm
echo "Finish installing fuse"
fi
cat "${FILES_DIR}/offline-packages/sagemaker/jupyter_notebook_config.py" > "/home/ec2-user/.jupyter/jupyter_notebook_config.py"
update_jupyter_config "/home/ec2-user/.jupyter/jupyter_notebook_config.py"
# TODO: Automate running mount_s3 script. update_jupyter_config does not seem to work on JupyterLabv3
echo "Setting up a one-time mount script."
if [ $OS_VERSION = '2' ]
then
systemctl restart jupyter-server
Expand Down
Loading

0 comments on commit cb64b62

Please sign in to comment.