diff --git a/Dockerfile b/Dockerfile index 595ec0ea5d628815cbfbe6f0e00a0695648276d8..273811c9f2646757d1fa0280050acab30641049b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,10 @@ RUN conda env update -q -f /tmp/environment.yml && \ conda env export -n "root" && \ jupyter lab build -COPY jupyter_notebook_config.py ${HOME}/.jupyter/ +COPY dash_proxy.py setup.py /tmp/dash_proxy/ +RUN pip3 install --upgrade pip +RUN pip install /tmp/dash_proxy/ # copy dash app COPY app ${HOME}/app/ RUN chown -R jovyan ${HOME}/app/ - -COPY client.py ${HOME}/ -RUN chown -R jovyan ${HOME}/client.py - diff --git a/README.md b/README.md index 2c4caf34528c968637670e22188145e8ffa26cf0..ef4faa61b32056f2b8678950612ad916b456bf0e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # A Jupyterlab for LLM -AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, OPENAI_API_VERSION need to be stored in a config.txt file in the home directory. +In order to run Dash or use the client, AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, OPENAI_API_VERSION need to be stored in a config.txt file in the home directory. diff --git a/app/app.py b/app/app.py index 4975d674ba0a1f11b0bc9f79d0ec5f40b9855e3b..449201124aa13717bd499ec6ea0a55b431c101e9 100644 --- a/app/app.py +++ b/app/app.py @@ -1,5 +1,6 @@ +import os import sys -sys.path.append("/home/jovyan") +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import argparse import logging @@ -26,7 +27,7 @@ else: # define Dash app app = Dash( name=__name__, - requests_pathname_prefix="/dash/" + requests_pathname_prefix="/Dash/" ) # define layout diff --git a/client.py b/app/client.py similarity index 100% rename from client.py rename to app/client.py diff --git a/dash_proxy.py b/dash_proxy.py new file mode 100644 index 0000000000000000000000000000000000000000..b7add298fdc2cd47baa0d17dd2cd052dc3f85b0d --- /dev/null +++ b/dash_proxy.py @@ -0,0 +1,25 @@ +import os +import logging + +logger = logging.getLogger(__name__) +logger.setLevel('INFO') + +HERE = os.path.dirname(os.path.abspath(__file__)) + + +def setup_dash_proxy(): + command = [ + 'python', + 'app/app.py', + '--port', + '{port}' + ] + + return { + "command": command, + "new_browser_tab": False, + "launcher_entry": { + "enabled": True, + 'title': 'Dash' + } + } diff --git a/jupyter_notebook_config.py b/jupyter_notebook_config.py deleted file mode 100644 index 22208d38066f4dd7b1271c4df093530370bf3943..0000000000000000000000000000000000000000 --- a/jupyter_notebook_config.py +++ /dev/null @@ -1,13 +0,0 @@ -# Configuration file for jupyter-notebook. -c.ServerProxy.servers = { - 'dash': { - 'command': [ - 'python', - 'app/app.py', - '--port', - '{port}' - ], - 'absolute_url': False, - 'new_browser_tab': False - } -} diff --git a/setup.py b/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..ccd874ca87acf8f35bea40e0eb6e883150528e3f --- /dev/null +++ b/setup.py @@ -0,0 +1,16 @@ +import setuptools + +setuptools.setup( + author="Julian Rasch", + author_email="julian.rasch@fh-muenster.de", + description="A small module to run Dash inside a dockerized Jupyterlab.", + name="jupyter-dash-proxy", + py_modules=["dash_proxy"], + entry_points={ + "jupyter_serverproxy_servers": [ + # name = packagename:function_name + "Dash = dash_proxy:setup_dash_proxy", + ] + }, + install_requires=["jupyter-server-proxy==4.0.0"], +)