简体   繁体   English

从 azure 应用服务中的 juypter notebook kernel 获取日志

[英]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.我是 juypter 笔记本的新手,但我相信这更多的是 web 应用程序部署的问题。

Main question - How can I see logs for kernel connections to the juypter notebook?主要问题 - 如何查看 kernel 连接到 juypter 笔记本的日志?

Main issue - I am having juyper notebook connection issues and I want to get logs to see why this could be.主要问题 - 我遇到了 juyper 笔记本连接问题,我想获取日志以了解原因。 Its not a tornado issue as I am using 4.5.3.它不是龙卷风问题,因为我使用的是 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).详细信息 - 我得知一所大学正在使用旧的 juypter 笔记本,该笔记本具有用 python 2.7 (UGH) 编写的 ML 模型。 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. 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.我决定尝试使用我的 windows 10 笔记本电脑和 python 2.7 测试让数据模型应用程序再次工作。 I got it to work, so I decided to try and containerize the app and push the app to azure.我让它工作了,所以我决定尝试将应用程序容器化并将应用程序推送到 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.我让容器工作,并且能够将应用程序部署到 azure,但是当我在 azure 中运行笔记本时,尝试连接到 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:这是我用来将我的应用程序部署到 azure 的 ​​dockerfile:

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.这是我在部署到 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这同样适用于 docker 容器,但不适用于网站

在此处输入图像描述

I found the answer to my main question.我找到了我的主要问题的答案。 You want to add this flag when you run your notebook: "--log-level=DEBUG"您想在运行笔记本时添加此标志:“--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. 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.由于一切正常,我认为这是一个端口问题,因为 App 服务只能公开 1 个端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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