Spaces:
Sleeping
Sleeping
jrosell
commited on
Commit
·
f11cb19
0
Parent(s):
My changes
Browse files- .gitattributes +35 -0
- .gitignore +3 -0
- Dockerfile +56 -0
- README.md +81 -0
- app.R +31 -0
- deploy_docker.sh +4 -0
- deploy_hf.sh +4 -0
.gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
.Renviron
|
2 |
+
*.sqlite
|
3 |
+
build.log
|
Dockerfile
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ARG GITHUB_PAT
|
2 |
+
|
3 |
+
FROM rocker/r2u:22.04
|
4 |
+
|
5 |
+
ENV RUSTUP_HOME=/usr/local/rustup \
|
6 |
+
CARGO_HOME=/usr/local/cargo \
|
7 |
+
PATH=/usr/local/cargo/bin:$PATH
|
8 |
+
|
9 |
+
# Install system packages
|
10 |
+
RUN set -eux; \
|
11 |
+
apt-get update; \
|
12 |
+
apt-get install -y --no-install-recommends \
|
13 |
+
git \
|
14 |
+
sudo \
|
15 |
+
sqlite3 \
|
16 |
+
ca-certificates \
|
17 |
+
gcc \
|
18 |
+
libc6-dev \
|
19 |
+
wget \
|
20 |
+
&& sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers \
|
21 |
+
&& sed -i -e '/^suppressMessages(bspm::enable())$/i options(bspm.sudo=TRUE)' /etc/R/Rprofile.site \
|
22 |
+
; \
|
23 |
+
\
|
24 |
+
url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \
|
25 |
+
wget "$url"; \
|
26 |
+
chmod +x rustup-init; \
|
27 |
+
./rustup-init -y --no-modify-path --default-toolchain beta --default-host x86_64-unknown-linux-gnu; \
|
28 |
+
rm rustup-init; \
|
29 |
+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
|
30 |
+
rustup --version; \
|
31 |
+
cargo --version; \
|
32 |
+
rustc --version; \
|
33 |
+
\
|
34 |
+
apt-get remove -y --auto-remove \
|
35 |
+
wget \
|
36 |
+
; \
|
37 |
+
rm -rf /var/lib/apt/lists/*;
|
38 |
+
|
39 |
+
# Install R packages
|
40 |
+
RUN install2.r --error -s --deps TRUE htmltools tibble dplyr purrr rlang glue this.path DBI pool RSQLite remotes promises assertthat log here zeallot dbplyr stringr tidyverse
|
41 |
+
RUN Rscript -e "install.packages('b64', repos = c('https://extendr.r-universe.dev', getOption('repos')))"
|
42 |
+
RUN Rscript -e "install.packages('uwu', repos = c('https://josiahparry.r-universe.dev', getOption('repos')))"
|
43 |
+
RUN --mount=type=secret,id=GITHUB_PAT GITHUB_PAT=$(cat /run/secrets/GITHUB_PAT) \
|
44 |
+
installGithub.r devOpifex/ambiorix devOpifex/scilis devOpifex/signaculum
|
45 |
+
RUN --mount=type=secret,id=GITHUB_PAT GITHUB_PAT=$(cat /run/secrets/GITHUB_PAT) \
|
46 |
+
installGithub.r jrosell/ambhtmx
|
47 |
+
|
48 |
+
# Prepare the user
|
49 |
+
ENV HOME=/workspace \
|
50 |
+
PATH=/workspace/.local/bin:$PATH
|
51 |
+
WORKDIR /workspace
|
52 |
+
COPY . .
|
53 |
+
|
54 |
+
# Entry
|
55 |
+
EXPOSE 7860
|
56 |
+
CMD R -e "print(nchar(Sys.getenv('GITHUB_PAT'))); source('app.R'); "
|
README.md
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: ambhtmx.plotly
|
3 |
+
emoji: 🏃
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: pink
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
---
|
9 |
+
|
10 |
+
<!-- badges: start -->
|
11 |
+
|
12 |
+
[![Lifecycle:
|
13 |
+
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
|
14 |
+
|
15 |
+
<!-- badges: end -->
|
16 |
+
|
17 |
+
**THIS IS A WORK IN PROGRESS, DO NOT USE**
|
18 |
+
|
19 |
+
|
20 |
+
## Deployment options
|
21 |
+
|
22 |
+
|
23 |
+
### Hugging Face Spaces
|
24 |
+
|
25 |
+
When you pushing a repository to a Hugging Face Spaces with the option to deploy Dockerfile and include a Dockerfile, Hugging Face will start building and running your app in the Space.
|
26 |
+
|
27 |
+
Try the demo here:
|
28 |
+
|
29 |
+
* Direct URL to the deployed app: https://jrosell-ambhtmx-plotly.hf.space/
|
30 |
+
* Space URL: https://huggingface.co/spaces/jrosell/ambhtmx.plotly
|
31 |
+
|
32 |
+
|
33 |
+
If you have a repo with git enabled with a github hf remote configured, you can run:
|
34 |
+
|
35 |
+
```
|
36 |
+
bash deploy_hf.sh
|
37 |
+
```
|
38 |
+
|
39 |
+
For example, you can adapt this for your gh and hf repos:
|
40 |
+
|
41 |
+
```
|
42 |
+
git init
|
43 |
+
git add -A
|
44 |
+
git status
|
45 |
+
git commit -m "My changes"
|
46 |
+
git remote add origin [email protected]:jrosell/ambhtmx.plotly.git
|
47 |
+
git remote add gh [email protected]:jrosell/ambhtmx.plotly.git
|
48 |
+
git remote add hf [email protected]:spaces/jrosell/ambhtmx.plotly
|
49 |
+
git push --set-upstream gh main
|
50 |
+
git push --set-upstream hf main
|
51 |
+
```
|
52 |
+
|
53 |
+
|
54 |
+
### Runing the example in Docker
|
55 |
+
|
56 |
+
All in one command:
|
57 |
+
|
58 |
+
```
|
59 |
+
bash deploy_docker.sh
|
60 |
+
```
|
61 |
+
|
62 |
+
It will run:
|
63 |
+
|
64 |
+
```
|
65 |
+
(docker container rm -f ambhtmx-plotly-container || true)\
|
66 |
+
&& (docker rmi $(docker images --format '{{.Repository}}:{{.ID}}'| egrep 'ambhtmx-plotly' | cut -d':' -f2 | uniq) --force || true) \
|
67 |
+
&& docker build -f Dockerfile -t ambhtmx-plotly-image . \
|
68 |
+
&& docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-plotly-container --rm ambhtmx-plotly-image
|
69 |
+
```
|
70 |
+
|
71 |
+
|
72 |
+
## Troubleshooting
|
73 |
+
|
74 |
+
If you want to see the logs:
|
75 |
+
|
76 |
+
```
|
77 |
+
docker build -f Dockerfile --no-cache --progress=plain -t ambhtmx-plotly-image . 2>&1 | tee build.log
|
78 |
+
```
|
79 |
+
|
80 |
+
Check the [known issues](https://github.com/jrosell/ambhtmx/issues), and if you have another issue? Please, [let me know](https://github.com/jrosell/ambhtmx/issues).
|
81 |
+
|
app.R
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# remotes::install_github("jrosell/ambhtmx", force = TRUE)
|
2 |
+
library(ambhtmx)
|
3 |
+
# devtools::load_all()
|
4 |
+
|
5 |
+
card_3d_demo <- \() {
|
6 |
+
card <- "card"
|
7 |
+
tryCatch({
|
8 |
+
# Original python code credit: https://fastht.ml/
|
9 |
+
# Design credit: https://codepen.io/markmiro/pen/wbqMPa
|
10 |
+
bgurl <- "https://ucarecdn.com/35a0e8a7-fcc5-48af-8a3f-70bb96ff5c48/-/preview/750x1000/"
|
11 |
+
card_styles <- "font-family: 'Arial Black', 'Arial Bold', Gadget, sans-serif; perspective: 1500px;"
|
12 |
+
card_3d <- \(text, bgurl, amt, left_align) {
|
13 |
+
align <- ifelse(left_align, 'left', 'right')
|
14 |
+
scr <- script_from_js_tpl('card3d.js', amt = amt)
|
15 |
+
sty <- style_from_css_tpl(
|
16 |
+
'card3d.css', bgurl = glue('url({bgurl})'), align = align
|
17 |
+
)
|
18 |
+
div(text, div(), scr, sty, align = align)
|
19 |
+
}
|
20 |
+
card <- card_3d("Mouseover me", bgurl, amt = 1.5, left_align = T)
|
21 |
+
},
|
22 |
+
error = \(e) print(e)
|
23 |
+
)
|
24 |
+
div(card, style = card_styles)
|
25 |
+
}
|
26 |
+
|
27 |
+
ambhtmx(host = "0.0.0.0", port = "7860", protocol ="http")$app$
|
28 |
+
get("/", \(req, res) {
|
29 |
+
card_3d_demo() |> send_page(res)
|
30 |
+
})$
|
31 |
+
start()
|
deploy_docker.sh
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(docker container rm -f ambhtmx-plotly-container || true)\
|
2 |
+
&& (docker rmi $(docker images --format '{{.Repository}}:{{.ID}}'| egrep 'ambhtmx-plotly-image' | cut -d':' -f2 | uniq) --force || true) \
|
3 |
+
&& docker build -f Dockerfile -t ambhtmx-plotly-image . \
|
4 |
+
&& docker run --env-file=.Renviron -p 7860:7860 --name ambhtmx-plotly-container --rm ambhtmx-plotly-image
|
deploy_hf.sh
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
echo `date` > last_depoy.txt
|
2 |
+
git add last_depoy.txt
|
3 |
+
git commit -m "deploy"
|
4 |
+
git push --set-upstream hf main
|