Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyterhub-ai
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Rasch
jupyterhub-ai
Commits
b21745b0
Commit
b21745b0
authored
11 months ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
include conditional MyApp proxy for dash
parent
783fe058
No related branches found
No related tags found
No related merge requests found
Pipeline
#186923
failed
11 months ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/my_app.py
+70
-0
70 additions, 0 deletions
app/my_app.py
dash_proxy/my_app_proxy.py
+16
-0
16 additions, 0 deletions
dash_proxy/my_app_proxy.py
dash_proxy/setup.py
+2
-1
2 additions, 1 deletion
dash_proxy/setup.py
with
88 additions
and
1 deletion
app/my_app.py
0 → 100644
+
70
−
0
View file @
b21745b0
import
sys
sys
.
path
.
append
(
"
/home/jovyan/
"
)
import
argparse
import
logging
from
urllib.parse
import
urlparse
,
urljoin
from
dash
import
Dash
from
jupyter_server.serverapp
import
list_running_servers
try
:
from
my_layout
import
layout
from
my_callbacks
import
register_callbacks
except
ModuleNotFoundError
:
# do not let Dash start
exit
()
logging
.
basicConfig
(
level
=
logging
.
INFO
)
# weird trick to find base_url for the jupyterlab
def
find_jupyterlab_base_url
():
servers
=
list_running_servers
()
for
server
in
servers
:
if
server
[
"
port
"
]
==
8888
:
return
server
[
'
url
'
]
return
None
# 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
}
.
"
)
base_url
=
find_jupyterlab_base_url
()
if
base_url
is
None
:
raise
ValueError
(
"
Base URL of Jupyterlab could not be detected.
"
)
logging
.
debug
(
f
"
Base URL:
{
base_url
}
"
)
proxy_base_path
=
urlparse
(
urljoin
(
base_url
+
"
/
"
,
f
"
proxy/
{
port
}
/
"
)).
path
logging
.
debug
(
f
"
Proxy base path:
{
proxy_base_path
}
"
)
# define Dash app
app
=
Dash
(
name
=
__name__
,
requests_pathname_prefix
=
proxy_base_path
)
# 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
=
"
0.0.0.0
"
,
debug
=
True
)
This diff is collapsed.
Click to expand it.
dash_proxy/my_app_proxy.py
0 → 100644
+
16
−
0
View file @
b21745b0
def
setup_my_app_proxy
():
command
=
[
'
python
'
,
'
/dash/app/my_app.py
'
,
'
--port
'
,
'
{port}
'
]
return
{
"
command
"
:
command
,
"
new_browser_tab
"
:
False
,
"
launcher_entry
"
:
{
"
enabled
"
:
True
,
'
title
'
:
'
MyApp
'
}
}
This diff is collapsed.
Click to expand it.
dash_proxy/setup.py
+
2
−
1
View file @
b21745b0
...
@@ -5,11 +5,12 @@ setuptools.setup(
...
@@ -5,11 +5,12 @@ setuptools.setup(
author_email
=
"
julian.rasch@fh-muenster.de
"
,
author_email
=
"
julian.rasch@fh-muenster.de
"
,
description
=
"
A small module to run Dash inside a dockerized Jupyterlab.
"
,
description
=
"
A small module to run Dash inside a dockerized Jupyterlab.
"
,
name
=
"
jupyter-dash-proxy
"
,
name
=
"
jupyter-dash-proxy
"
,
py_modules
=
[
"
dash_proxy
"
],
py_modules
=
[
"
dash_proxy
"
,
"
my_app_proxy
"
],
entry_points
=
{
entry_points
=
{
"
jupyter_serverproxy_servers
"
:
[
"
jupyter_serverproxy_servers
"
:
[
# name = packagename:function_name
# name = packagename:function_name
"
Dash = dash_proxy:setup_dash_proxy
"
,
"
Dash = dash_proxy:setup_dash_proxy
"
,
"
MyApp = my_app_proxy:setup_my_app_proxy
"
]
]
},
},
install_requires
=
[
"
jupyter-server-proxy==4.0.0
"
],
install_requires
=
[
"
jupyter-server-proxy==4.0.0
"
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment