Skip to content
Snippets Groups Projects
Commit 382d5e48 authored by Julian Rasch's avatar Julian Rasch
Browse files

Merge branch 'dev' into 'dev'

first running version of dash inside of jupyterlab via proxy

See merge request !1
parents 01b677b3 c8968342
No related branches found
No related tags found
2 merge requests!6Finalized Jupyterlab for the sprint,!1first running version of dash inside of jupyterlab via proxy
Pipeline #182346 passed
*env/
.env
FROM jupyter/datascience-notebook:hub-3.1.1 FROM jupyter/datascience-notebook:hub-3.1.1
# Install from APT repository
USER root USER root
RUN apt-get update -y
RUN apt-get install -y git
# Install basics COPY requirements.txt environment.yml /tmp/
USER jovyan RUN conda env update -q -f /tmp/environment.yml && \
RUN pip3 install --upgrade pip /opt/conda/bin/pip install -r /tmp/requirements.txt && \
conda clean -y --all && \
conda env export -n "root" && \
jupyter lab build
# RUN pip3 install --upgrade pip COPY jupyter_notebook_config.py ${HOME}/.jupyter/
RUN pip install jupyter-server-proxy==4.0.0
RUN pip install jupyterlab-git==0.42.0
RUN pip install jupyterlab-gitlab==3.0.0
# Install jupyterlab-dash # copy dash app
RUN jupyter labextension install jupyterlab-dash COPY app ${HOME}/app/
RUN chown -R jovyan ${HOME}/app/
# Set environment variable for node memory limit
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Build JupyterLab
RUN jupyter lab build
# Copy and install additional Python packages
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# bücker # A Jupyterlab for LLM
import sys
sys.path.append("/home/jovyan")
import argparse
import logging
from dash import Dash
from layout import layout
from callbacks import register_callbacks
logging.basicConfig(level=logging.INFO)
# get the correct port from proxy
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int)
args = parser.parse_args()
port: int = args.port
if not port:
raise ValueError(f"Port of proxy server for Dash not found in {args}.")
else:
logging.debug(f"Dash app running on port {port}.")
# define Dash app
app = Dash(
name=__name__,
requests_pathname_prefix="/dash/"
)
# define layout
app.layout = layout
# register all callback functions
register_callbacks(app=app)
# Run Dash app in the notebook
app.run(
jupyter_mode="jupyterlab",
port=port,
host="localhost",
debug=True
)
from dash import (
html,
Dash
)
from dash.dependencies import (
Input,
Output,
State
)
def register_callbacks(app: Dash):
@app.callback(
Output("output-container", "children"),
[Input("send-button", "n_clicks")],
[State("input-text", "value")]
)
def generate_response(n_clicks, input_text):
if n_clicks > 0:
response = "You said: " + input_text
return html.Div(response)
else:
return ""
from dash import (
html,
dcc
)
layout = html.Div(
className="container",
children=[
html.H1("GPT Chat", className="mt-5 mb-4"),
dcc.Textarea(id="input-text", placeholder="Enter your message:", className="form-control mb-3"),
html.Button("Send", id="send-button", n_clicks=0, className="btn btn-primary mb-3"),
html.Div(id="output-container")
]
)
name: "base"
channels:
- defaults
# dependencies:
# - add packages here
# - one per line
prefix: "/opt/conda"
# Configuration file for jupyter-notebook.
c.ServerProxy.servers = {
'dash': {
'command': [
'python',
'app/app.py',
'--port',
'{port}'
],
'absolute_url': False,
'new_browser_tab': False
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment