epaps commited on
Commit
d87c106
·
1 Parent(s): 93c9eeb
Files changed (5) hide show
  1. Dockerfile +6 -12
  2. app.py +23 -0
  3. environment.yml +1 -0
  4. jupyter_server_config.py +0 -19
  5. start.sh +5 -4
Dockerfile CHANGED
@@ -9,21 +9,10 @@ RUN mkdir -p /var/lib/apt/lists/partial && \
9
 
10
  WORKDIR /work
11
 
12
- # env first (cache-friendly)
13
  COPY binder/environment.yml /tmp/environment.yml
14
  RUN micromamba env create -f /tmp/environment.yml && micromamba clean -a -y
15
 
16
- # copy the whole repo into /work (this is what makes notebooks appear)
17
- COPY . /work
18
-
19
- # install jupyter config
20
- RUN mkdir -p /etc/jupyter && cp /work/jupyter_server_config.py /etc/jupyter/jupyter_server_config.py
21
-
22
- RUN chmod +x /work/start.sh
23
-
24
- EXPOSE 7860
25
- CMD ["/work/start.sh"]
26
-
27
  # Build StochasticCIL
28
  RUN git clone https://github.com/epapoutsellis/Split-Skip-and-Play.git && git clone https://github.com/epapoutsellis/StochasticCIL.git && \
29
  cd StochasticCIL && \
@@ -44,3 +33,8 @@ RUN git clone https://github.com/epapoutsellis/Split-Skip-and-Play.git && git cl
44
  make -j"$(nproc)" && \
45
  make install
46
 
 
 
 
 
 
 
9
 
10
  WORKDIR /work
11
 
12
+ # Your conda env file is in binder/environment.yml inside the repo
13
  COPY binder/environment.yml /tmp/environment.yml
14
  RUN micromamba env create -f /tmp/environment.yml && micromamba clean -a -y
15
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Build StochasticCIL
17
  RUN git clone https://github.com/epapoutsellis/Split-Skip-and-Play.git && git clone https://github.com/epapoutsellis/StochasticCIL.git && \
18
  cd StochasticCIL && \
 
33
  make -j"$(nproc)" && \
34
  make install
35
 
36
+ COPY start.sh /start.sh
37
+ RUN chmod +x /start.sh
38
+
39
+ EXPOSE 7860
40
+ CMD ["/start.sh"]
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ import gradio as gr
4
+
5
+ ROOT = Path("/work")
6
+
7
+ def list_repo():
8
+ # Show a small tree of notebooks/scripts to confirm they are in the image
9
+ exts = {".ipynb", ".py"}
10
+ files = sorted([p.relative_to(ROOT) for p in ROOT.rglob("*") if p.suffix in exts])
11
+ if not files:
12
+ return "No .ipynb/.py files found under /work (did you COPY the repo into the image?)"
13
+ return "\n".join(str(p) for p in files[:300])
14
+
15
+ with gr.Blocks(title="Split-Skip-and-Play") as demo:
16
+ gr.Markdown("# Split-Skip-and-Play\nA lightweight UI (Gradio) running on Hugging Face Spaces.")
17
+ out = gr.Textbox(label="Repo notebooks/scripts (first 300)", lines=20)
18
+ gr.Button("Refresh file list").click(fn=list_repo, outputs=out)
19
+
20
+ demo.launch(
21
+ server_name="0.0.0.0",
22
+ server_port=int(os.getenv("PORT", "7860")),
23
+ )
environment.yml CHANGED
@@ -25,3 +25,4 @@ dependencies:
25
  - bm3d
26
  - xdesign
27
  - scikit-image
 
 
25
  - bm3d
26
  - xdesign
27
  - scikit-image
28
+ - gradio
jupyter_server_config.py DELETED
@@ -1,19 +0,0 @@
1
- # /etc/jupyter/jupyter_server_config.py will load this
2
- c.ServerApp.ip = "0.0.0.0"
3
- c.ServerApp.port = 7860
4
- c.ServerApp.open_browser = False
5
- c.ServerApp.allow_root = True
6
- c.ServerApp.allow_remote_access = True
7
-
8
- # Show your repo folder in the file browser
9
- c.ServerApp.root_dir = "/work"
10
-
11
- # Make "/" go straight to JupyterLab in your repo folder
12
- c.ServerApp.default_url = "/lab/tree/Split-Skip-and-Play"
13
-
14
- # IMPORTANT: allow embedding in the Space page iframe
15
- c.ServerApp.tornado_settings = {
16
- "headers": {
17
- "Content-Security-Policy": "frame-ancestors 'self' https://huggingface.co https://*.hf.space"
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
start.sh CHANGED
@@ -1,11 +1,12 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
- PORT="${PORT:-7860}"
5
  TOKEN="${JUPYTER_TOKEN:-}"
6
 
7
- # Run JupyterLab using our config. Override port at runtime if HF sets PORT.
8
  exec micromamba run -n ssp jupyter lab \
9
- --config=/etc/jupyter/jupyter_server_config.py \
10
- --ServerApp.port="${PORT}" \
 
 
 
11
  --IdentityProvider.token="${TOKEN}"
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
 
4
  TOKEN="${JUPYTER_TOKEN:-}"
5
 
 
6
  exec micromamba run -n ssp jupyter lab \
7
+ --allow-root \
8
+ --ip=0.0.0.0 --port=7860 \
9
+ --no-browser \
10
+ --ServerApp.allow_remote_access=True \
11
+ --ServerApp.root_dir=/work \
12
  --IdentityProvider.token="${TOKEN}"