Jupyter SAS kernel failing inside Docker container

279 Views Asked by At

For some reason I'm unable to run SAS notebooks inside a Jupyter Docker container. I can run SAS code inside Python notebooks via saspy, but the SAS kernel keeps throwing errors on me.

I'm using the image jupyter/pyspark-notebook:notebook-6.4.2 as the base, and connecting to a remote server via IOM. If I run a Python notebook, eg with

import saspy
%reload_ext saspy.sas_magic
ss = saspy.SASsession(cfgname="xxx")

then the connection works fine. Sometimes it times out, but that's probably a server issue.

However if I run a SAS notebook, when I try to submit a code chunk I get an error result:

[<class 'TypeError'>, TypeError("Frame 0 ({'shell': [b'f8fd30a1-60bc-4f25-...) does not support the buffer interface."), <traceback object at 0x7fad01e41100>]

There are also a bunch of error messages in the terminal window running the container:

notebook_1  | [I 17:14:56.181 NotebookApp] Kernel started: 58182c39-9df4-4922-b068-1d6bde76c31a, name: sas
notebook_1  | [IPKernelApp] ERROR | Exception in message handler:
notebook_1  | Traceback (most recent call last):
notebook_1  |   File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 352, in dispatch_shell
notebook_1  |     await result
notebook_1  |   File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelbase.py", line 642, in execute_request
notebook_1  |     reply_content = self.do_execute(
notebook_1  |   File "/opt/conda/lib/python3.9/site-packages/metakernel/_metakernel.py", line 397, in do_execute
notebook_1  |     retval = self.do_execute_direct(code)
notebook_1  |   File "/opt/conda/lib/python3.9/site-packages/sas_kernel/kernel.py", line 213, in do_execute_direct
notebook_1  |     res = self.mva.submit(code, prompt=self.promptDict)
notebook_1  | AttributeError: 'NoneType' object has no attribute 'submit'

The dockerfile is intended for use behind a corp firewall so contains some confidential entries, making it hard to give a reproducible example. But the gist of it is:

FROM jupyter/pyspark-notebook:notebook-6.4.2

RUN mamba install -c conda-forge -y nodejs && \
    conda clean --all -f -y && \
    fix-permissions $CONDA_DIR && \
    fix-permissions /home/$NB_USER

RUN pip install jupyterlab_templates &&\
    jupyter labextension install jupyterlab_templates && \
    jupyter serverextension enable --py jupyterlab_templates

RUN pip install pytest sas_kernel

# Adding SAS config
ADD saspy/*.jar /opt/conda/lib/python3.9/site-packages/saspy/java/
ADD saspy/sascfg_personal.py /opt/conda/lib/python3.9/site-packages/saspy/

Some specific versions:

Python 3.9.6

jupyter core     : 4.7.1
jupyter-notebook : 6.4.2
qtconsole        : not installed
ipython          : 7.26.0
ipykernel        : 6.0.3
jupyter client   : 6.1.12
jupyter lab      : 3.1.4
nbconvert        : 6.1.0
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

sas-kernel                2.4.11
saspy                     3.7.5  

How can I fix this?

0

There are 0 best solutions below