Spaces:
Build error
Build error
narugo1992
commited on
Upload directory 'repo', on 2024-06-10 10:41:35 UTC
Browse files- .bashrc +3 -0
- .ipynb_checkpoints/README-checkpoint.md +12 -0
- Dockerfile +43 -0
- README.md +2 -1
- how_to_use_github_action_runner.md +43 -0
- requirements.txt +4 -0
- rich_print_help.py +10 -0
- run.sh +15 -0
.bashrc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export PATH=$HOME/.local/bin:$PATH
|
| 2 |
+
|
| 3 |
+
python $HOME/app/rich_print_help.py
|
.ipynb_checkpoints/README-checkpoint.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Jupyter Github Action Runner
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
app_port: 7860
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
Dockerfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.8.1
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
|
| 7 |
+
RUN apt-get update && \
|
| 8 |
+
apt-get install -y sudo tmux wget curl htop make tree nano vim cloc && \
|
| 9 |
+
apt-get install -y graphviz pandoc && \
|
| 10 |
+
apt-get install -y iputils-ping telnet && \
|
| 11 |
+
apt-get install -y git git-lfs
|
| 12 |
+
|
| 13 |
+
RUN --mount=type=secret,id=PASSWORD,mode=0444,required=true \
|
| 14 |
+
useradd -m -u 1000 user && \
|
| 15 |
+
echo "user:$(cat /run/secrets/PASSWORD)" | chpasswd && \
|
| 16 |
+
adduser user sudo
|
| 17 |
+
|
| 18 |
+
RUN pip install -U pip pysocks
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 20 |
+
|
| 21 |
+
USER user
|
| 22 |
+
ENV HOME=/home/user
|
| 23 |
+
ENV PATH=$HOME/.local/bin:$PATH
|
| 24 |
+
ENV SHELL=/bin/bash
|
| 25 |
+
|
| 26 |
+
WORKDIR $HOME
|
| 27 |
+
|
| 28 |
+
RUN mkdir -p $HOME/runner && \
|
| 29 |
+
cd $HOME/runner && \
|
| 30 |
+
curl -o actions-runner-linux-x64-2.317.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.317.0/actions-runner-linux-x64-2.317.0.tar.gz && \
|
| 31 |
+
echo "9e883d210df8c6028aff475475a457d380353f9d01877d51cc01a17b2a91161d actions-runner-linux-x64-2.317.0.tar.gz" | shasum -a 256 -c && \
|
| 32 |
+
tar xzf ./actions-runner-linux-x64-2.317.0.tar.gz
|
| 33 |
+
|
| 34 |
+
COPY --chown=user . $HOME/app
|
| 35 |
+
|
| 36 |
+
RUN cp $HOME/app/how_to_use_github_action_runner.md $HOME/how_to_use_github_action_runner.md
|
| 37 |
+
COPY .bashrc $HOME/.bashrc_append
|
| 38 |
+
RUN cat $HOME/.bashrc_append >> $HOME/.bashrc && \
|
| 39 |
+
rm $HOME/.bashrc_append
|
| 40 |
+
|
| 41 |
+
EXPOSE 7860
|
| 42 |
+
ENTRYPOINT []
|
| 43 |
+
CMD ["/bin/bash", "./app/run.sh"]
|
README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
---
|
| 2 |
title: Jupyter Github Action Runner
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: Jupyter Github Action Runner
|
| 3 |
+
emoji: π
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
+
app_port: 7860
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
how_to_use_github_action_runner.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Guide for Github Action Runner
|
| 2 |
+
|
| 3 |
+
## Configure
|
| 4 |
+
|
| 5 |
+
The runner toolkits are installed at `~/runner`.
|
| 6 |
+
|
| 7 |
+
We have to configure it at the first time, after that you can start this runner.
|
| 8 |
+
|
| 9 |
+
```shell
|
| 10 |
+
cd ~/runner
|
| 11 |
+
|
| 12 |
+
export GH_REPO=your/github_repository
|
| 13 |
+
export TOKEN=your_github_action_token
|
| 14 |
+
./config.sh --url $GH_REPO --token $TOKEN
|
| 15 |
+
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
## Start Runner
|
| 19 |
+
|
| 20 |
+
```shell
|
| 21 |
+
cd ~/runner
|
| 22 |
+
./run.sh
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
## Delete Runner
|
| 26 |
+
|
| 27 |
+
```shell
|
| 28 |
+
cd ~/runner
|
| 29 |
+
|
| 30 |
+
export TOKEN=your_github_action_token
|
| 31 |
+
./config.sh remove --token $TOKEN
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## Attention
|
| 35 |
+
|
| 36 |
+
* Pros of HFSpace-hosted runner
|
| 37 |
+
* **Larger free disk space** (github action: 14G, hfspace: 50G)
|
| 38 |
+
* Highly-customizable running environment.
|
| 39 |
+
* Cons of HFSpace-hosted runner
|
| 40 |
+
* **Much slower CPU speed** (time cost approx x2.5 of github action when running model inference)
|
| 41 |
+
* Many actions on github action market not compatible with non-github-action environments.
|
| 42 |
+
* You have to customize your own running environment manually, by editing `Dockerfile` and rebuilding space.
|
| 43 |
+
* **You don't have the root permission on hfspace runtime.** You have to install all the root-required dependencies (e.g. `apt/yum install xxx`) at docker build stage. The other dependencies (e.g. `pip install xxx`) can be installed at runtime.
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jupyterlab==3.6.1
|
| 2 |
+
jupyter-server==2.3.0
|
| 3 |
+
tornado==6.2
|
| 4 |
+
rich
|
rich_print_help.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
from rich.console import Console
|
| 4 |
+
from rich.markdown import Markdown
|
| 5 |
+
|
| 6 |
+
console = Console()
|
| 7 |
+
|
| 8 |
+
with open(os.path.expanduser('~/how_to_use_github_action_runner.md')) as f:
|
| 9 |
+
md = Markdown(f.read())
|
| 10 |
+
console.print(md)
|
run.sh
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
PASSWORD="${PASSWORD:=huggingface}"
|
| 4 |
+
echo "Starting Jupyter Lab with token $PASSWORD"
|
| 5 |
+
|
| 6 |
+
jupyter lab \
|
| 7 |
+
--ip=0.0.0.0 \
|
| 8 |
+
--port=7860 \
|
| 9 |
+
--no-browser \
|
| 10 |
+
--allow-root \
|
| 11 |
+
--NotebookApp.token=$PASSWORD \
|
| 12 |
+
--NotebookApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
|
| 13 |
+
--NotebookApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 14 |
+
--NotebookApp.disable_check_xsrf=True
|
| 15 |
+
|