简体   繁体   中英

Get logs from juypter notebook kernel in azure app service

I am new to juypter notebooks but I belive this is more of an issue with web app deployment.

Main question - How can I see logs for kernel connections to the juypter notebook?

Main issue - I am having juyper notebook connection issues and I want to get logs to see why this could be. Its not a tornado issue as I am using 4.5.3.

Details - I was informed of a college that was using an old juypter notebook that had ML models written in python 2.7 (UGH). No one who created the code is around to change it to python 3. Everything was fine until there computer upgraded from windows 7 to windows 10. WHen that happened, the python upgraded from 2 to 3 and that caused the juypter notebook to not work. I decided I was going to try to test getting there datamodel app to work again using my windows 10 laptop and python 2.7. I got it to work, so I decided to try and containerize the app and push the app to azure. I got the container to work and I was able to deploy the app to azure, but when I run the notebook in azure it has issues trying to connect to the kernel. This is why I want to find the logs so I can see why it can't connect.

Here is my dockerfile that I use to deploy my app to azure:

FROM python:2.7.18
LABEL name="model"


COPY ./requirements.txt /app/requirements.txt

WORKDIR /app

RUN apt-get update \
  && pip install --upgrade pip  \
  && pip install -r requirements.txt \
  && rm -rf /var/cache/apk/*

COPY "/" /app



CMD ["python", "-m", "notebook", "--port=80", "--ip=0.0.0.0", "--allow-root", "--no-browser", "--NotebookApp.token=''"]

Here is my requirements file that I use with my deployment to azure.

attrs==21.4.0
backports-abc==0.5
backports.functools-lru-cache==1.6.4
backports.shutil-get-terminal-size==1.0.0
bleach==3.3.1
certifi==2021.10.8
colorama==0.4.5
configparser==4.0.2
contextlib2==0.6.0.post1
cycler==0.10.0
decorator==4.4.2
defusedxml==0.7.1
entrypoints==0.3
enum34==1.1.10
functools32==3.2.3.post2
futures==3.3.0
importlib-metadata==2.1.3
ipykernel==4.10.1
ipython==5.10.0
ipython-genutils==0.2.0
Jinja2==2.11.3
jsonschema==3.2.0
jupyter-client==5.3.5
jupyter-core==4.6.3
kiwisolver==1.1.0
MarkupSafe==1.1.1
matplotlib==2.2.5
mistune==0.8.4
nbconvert==5.6.1
nbformat==4.4.0
notebook==5.2.0
numpy==1.16.6
packaging==20.9
pandas==0.24.2
pandocfilters==1.5.0
pathlib2==2.3.7.post1
pickleshare==0.7.5
prompt-toolkit==1.0.18
Pygments==2.5.2
pyparsing==2.4.7
pyrsistent==0.16.1
python-dateutil==2.8.2
pytz==2022.1
pyzmq==19.0.2
scandir==1.10.0
scikit-learn==0.20.4
scipy==1.2.3
seaborn==0.9.1
simplegeneric==0.8.1
singledispatch==3.7.0
six==1.16.0
testpath==0.4.4
tornado==4.5.3
traitlets==4.3.3
treeinterpreter==0.2.3
typing==3.10.0.0
wcwidth==0.2.5
webencodings==0.5.1
win-unicode-console==0.5
zipp==1.2.0

Again this works in the docker container but not in the website

在此处输入图像描述

I found the answer to my main question. You want to add this flag when you run your notebook: "--log-level=DEBUG"

I put that into my dockerfile and then redeployed my app to azure and I was able to see way more output in the logs streams related to the kernel. Since everything looked right, I think it was a port issue as App services can only expose 1 port.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM