cjerzak commited on
Commit
f67f117
·
1 Parent(s): c169203
Files changed (2) hide show
  1. R/plumber.R +13 -5
  2. README.md +6 -12
R/plumber.R CHANGED
@@ -8,8 +8,9 @@ asa_helpers_candidates <- unique(c(
8
  file.path("/app", "R", "asa_api_helpers.R"),
9
  file.path("/home/user/app", "R", "asa_api_helpers.R")
10
  ))
11
- asa_helpers_path <- asa_helpers_candidates[file.exists(asa_helpers_candidates)][1]
12
- if (!length(asa_helpers_path) || !nzchar(asa_helpers_path)) {
 
13
  stop(
14
  paste0(
15
  "Could not locate asa API helpers file. Tried: ",
@@ -22,6 +23,14 @@ if (!length(asa_helpers_path) || !nzchar(asa_helpers_path)) {
22
  }
23
  source(asa_helpers_path, local = TRUE)
24
 
 
 
 
 
 
 
 
 
25
  .asa_api_boot_error <- NULL
26
  tryCatch(
27
  asa_api_bootstrap(),
@@ -88,11 +97,10 @@ function() {
88
  #* @get /
89
  #* @serializer contentType list(type = "text/html; charset=utf-8")
90
  function() {
91
- html_path <- file.path(getwd(), "www", "index.html")
92
- if (!file.exists(html_path)) {
93
  return("<h1>asa-api</h1><p>GUI file not found.</p>")
94
  }
95
- paste(readLines(html_path, warn = FALSE, encoding = "UTF-8"), collapse = "\n")
96
  }
97
 
98
  #* Run a single ASA task
 
8
  file.path("/app", "R", "asa_api_helpers.R"),
9
  file.path("/home/user/app", "R", "asa_api_helpers.R")
10
  ))
11
+ asa_helpers_hits <- asa_helpers_candidates[file.exists(asa_helpers_candidates)]
12
+ asa_helpers_path <- if (length(asa_helpers_hits) > 0L) as.character(asa_helpers_hits[[1]]) else ""
13
+ if (!nzchar(asa_helpers_path)) {
14
  stop(
15
  paste0(
16
  "Could not locate asa API helpers file. Tried: ",
 
23
  }
24
  source(asa_helpers_path, local = TRUE)
25
 
26
+ asa_gui_candidates <- unique(c(
27
+ file.path(getwd(), "www", "index.html"),
28
+ file.path("/app", "www", "index.html"),
29
+ file.path("/home/user/app", "www", "index.html")
30
+ ))
31
+ asa_gui_hits <- asa_gui_candidates[file.exists(asa_gui_candidates)]
32
+ asa_gui_path <- if (length(asa_gui_hits) > 0L) as.character(asa_gui_hits[[1]]) else ""
33
+
34
  .asa_api_boot_error <- NULL
35
  tryCatch(
36
  asa_api_bootstrap(),
 
97
  #* @get /
98
  #* @serializer contentType list(type = "text/html; charset=utf-8")
99
  function() {
100
+ if (!nzchar(asa_gui_path)) {
 
101
  return("<h1>asa-api</h1><p>GUI file not found.</p>")
102
  }
103
+ paste(readLines(asa_gui_path, warn = FALSE, encoding = "UTF-8"), collapse = "\n")
104
  }
105
 
106
  #* Run a single ASA task
README.md CHANGED
@@ -1,15 +1,4 @@
1
- ---
2
- title: asa-api
3
- emoji: 🔎
4
- colorFrom: blue
5
- colorTo: green
6
- sdk: docker
7
- sdk_version: "latest"
8
- pinned: false
9
- ---
10
-
11
-
12
- # asa-api
13
 
14
  `asa-api` is a Docker-based API + GUI wrapper around [`asa::run_task()`](https://github.com/cjerzak/asa-software) designed for deployment as a Hugging Face Space.
15
 
@@ -175,6 +164,11 @@ The adapter is intentionally resilient to `asa` changes:
175
 
176
  The `Dockerfile` clones `asa-software` during build and installs `asa` from source.
177
 
 
 
 
 
 
178
  Build args:
179
 
180
  - `ASA_SOFTWARE_REPO` (default: `https://github.com/cjerzak/asa-software`)
 
1
+ # asa-api (Hugging Face Space)
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  `asa-api` is a Docker-based API + GUI wrapper around [`asa::run_task()`](https://github.com/cjerzak/asa-software) designed for deployment as a Hugging Face Space.
4
 
 
164
 
165
  The `Dockerfile` clones `asa-software` during build and installs `asa` from source.
166
 
167
+ R dependency strategy in this image:
168
+ - Base image is `rocker/r2u:22.04`.
169
+ - Core R runtime packages (`plumber`, `jsonlite`, `reticulate`, `remotes`) are installed as binary apt packages (`r-cran-*`), not compiled from CRAN source.
170
+ - This avoids source-compile failures such as `sodium` -> `plumber` install breaks.
171
+
172
  Build args:
173
 
174
  - `ASA_SOFTWARE_REPO` (default: `https://github.com/cjerzak/asa-software`)