Spaces:
Runtime error
Runtime error
k8s
Browse files- .github/workflows/docker-image.yml +18 -0
- .gitignore +1 -0
- Dockerfile +15 -12
- app/app.R +1 -0
- kubernetes/deployment.yaml +50 -0
- kubernetes/ingress.yaml +25 -0
- kubernetes/service.yaml +17 -0
- tests/test-llm-app.R +24 -0
- tests/test-llm.R +0 -10
.github/workflows/docker-image.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Binder Image
|
| 2 |
+
on:
|
| 3 |
+
workflow_dispatch: null
|
| 4 |
+
push: null
|
| 5 |
+
jobs:
|
| 6 |
+
build:
|
| 7 |
+
runs-on: ubuntu-latest
|
| 8 |
+
permissions: write-all
|
| 9 |
+
steps:
|
| 10 |
+
- uses: actions/checkout@v3
|
| 11 |
+
- name: Publish to GitHub Container Registry
|
| 12 |
+
uses: elgohr/Publish-Docker-Github-Action@v5
|
| 13 |
+
with:
|
| 14 |
+
name: boettiger-lab/inat-ranges
|
| 15 |
+
username: ${{ github.actor }}
|
| 16 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
| 17 |
+
registry: ghcr.io
|
| 18 |
+
|
.gitignore
CHANGED
|
@@ -55,3 +55,4 @@ rsconnect/
|
|
| 55 |
*.pmtiles
|
| 56 |
Rplots.pdf
|
| 57 |
.tmp/
|
|
|
|
|
|
| 55 |
*.pmtiles
|
| 56 |
Rplots.pdf
|
| 57 |
.tmp/
|
| 58 |
+
kubernetes/set-secrets.sh
|
Dockerfile
CHANGED
|
@@ -3,19 +3,22 @@ FROM rocker/geospatial:latest
|
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
RUN install2.r --error \
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
RUN installGithub.r cboettig/mapgl tidyverse/ellmer boettiger-lab/duckdb.agent cboettig/duckdbfs
|
| 19 |
|
| 20 |
COPY . .
|
| 21 |
|
|
|
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
RUN install2.r --error \
|
| 6 |
+
bench \
|
| 7 |
+
bsicons \
|
| 8 |
+
bslib \
|
| 9 |
+
duckdbfs \
|
| 10 |
+
fontawesome \
|
| 11 |
+
gt \
|
| 12 |
+
markdown \
|
| 13 |
+
shiny \
|
| 14 |
+
shinybusy \
|
| 15 |
+
shinychat \
|
| 16 |
+
tidyverse \
|
| 17 |
+
mapgl \
|
| 18 |
+
ellmer \
|
| 19 |
+
conflicted
|
| 20 |
+
|
| 21 |
|
|
|
|
| 22 |
|
| 23 |
COPY . .
|
| 24 |
|
app/app.R
CHANGED
|
@@ -198,6 +198,7 @@ server <- function(input, output, session) {
|
|
| 198 |
observeEvent(input$chat_user_input, {
|
| 199 |
taxa_selected <- txt_to_taxa(input$chat_user_input)
|
| 200 |
chat_append("chat", "done")
|
|
|
|
| 201 |
|
| 202 |
# optionally - store the selection as global variable for future reactions
|
| 203 |
taxa_filter(taxa_selected)
|
|
|
|
| 198 |
observeEvent(input$chat_user_input, {
|
| 199 |
taxa_selected <- txt_to_taxa(input$chat_user_input)
|
| 200 |
chat_append("chat", "done")
|
| 201 |
+
chat_clear("chat")
|
| 202 |
|
| 203 |
# optionally - store the selection as global variable for future reactions
|
| 204 |
taxa_filter(taxa_selected)
|
kubernetes/deployment.yaml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: apps/v1
|
| 2 |
+
kind: Deployment
|
| 3 |
+
metadata:
|
| 4 |
+
name: gbif
|
| 5 |
+
labels:
|
| 6 |
+
k8s-app: gbif
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: gbif
|
| 10 |
+
image: ghcr.io/boettiger-lab/gbif-explorer
|
| 11 |
+
imagePullPolicy: Always
|
| 12 |
+
env:
|
| 13 |
+
|
| 14 |
+
- name: AWS_ACCESS_KEY_ID
|
| 15 |
+
valueFrom:
|
| 16 |
+
secretKeyRef:
|
| 17 |
+
name: aws
|
| 18 |
+
key: AWS_ACCESS_KEY_ID
|
| 19 |
+
- name: AWS_SECRET_ACCESS_KEY
|
| 20 |
+
valueFrom:
|
| 21 |
+
secretKeyRef:
|
| 22 |
+
name: aws
|
| 23 |
+
key: AWS_SECRET_ACCESS_KEY
|
| 24 |
+
- name: AWS_S3_ENDPOINT
|
| 25 |
+
value: "rook-ceph-rgw-nautiluss3.rook"
|
| 26 |
+
- name: AWS_PUBLIC_ENDPOINT
|
| 27 |
+
value: "s3-west.nrp-nautilus.io"
|
| 28 |
+
- name: AWS_HTTPS
|
| 29 |
+
value: "false"
|
| 30 |
+
- name: AWS_VIRTUAL_HOSTING
|
| 31 |
+
value: "FALSE"
|
| 32 |
+
- name: NRP_API_KEY
|
| 33 |
+
valueFrom:
|
| 34 |
+
secretKeyRef:
|
| 35 |
+
name: nrp-api-key
|
| 36 |
+
key: NRP_API_KEY
|
| 37 |
+
- name: MAPTILER_API_KEY
|
| 38 |
+
valueFrom:
|
| 39 |
+
secretKeyRef:
|
| 40 |
+
name: maptiler-api-key
|
| 41 |
+
key: MAPTILER_API_KEY
|
| 42 |
+
resources:
|
| 43 |
+
requests:
|
| 44 |
+
cpu: 8
|
| 45 |
+
memory: 8Gi
|
| 46 |
+
limits:
|
| 47 |
+
cpu: 8
|
| 48 |
+
memory: 8Gi
|
| 49 |
+
|
| 50 |
+
|
kubernetes/ingress.yaml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: networking.k8s.io/v1
|
| 2 |
+
kind: Ingress
|
| 3 |
+
metadata:
|
| 4 |
+
annotations:
|
| 5 |
+
haproxy.org/timeout-server: "300s"
|
| 6 |
+
haproxy.org/timeout-client: "300s"
|
| 7 |
+
haproxy.org/timeout-connect: "30s"
|
| 8 |
+
haproxy.org/timeout-http-request: "300s"
|
| 9 |
+
name: inat-ingress
|
| 10 |
+
spec:
|
| 11 |
+
ingressClassName: haproxy
|
| 12 |
+
rules:
|
| 13 |
+
- host: gbif.nrp-nautilus.io
|
| 14 |
+
http:
|
| 15 |
+
paths:
|
| 16 |
+
- path: /
|
| 17 |
+
pathType: Prefix
|
| 18 |
+
backend:
|
| 19 |
+
service:
|
| 20 |
+
name: gbif
|
| 21 |
+
port:
|
| 22 |
+
number: 8080
|
| 23 |
+
tls:
|
| 24 |
+
- hosts:
|
| 25 |
+
- gbif.nrp-nautilus.io
|
kubernetes/service.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Service
|
| 3 |
+
metadata:
|
| 4 |
+
name: gbif
|
| 5 |
+
labels:
|
| 6 |
+
k8s-app: gbif
|
| 7 |
+
|
| 8 |
+
# ports.targetPort is the port exposed by the Docker container
|
| 9 |
+
# ports.port is the port matched to the ingress
|
| 10 |
+
spec:
|
| 11 |
+
ports:
|
| 12 |
+
- port: 8080
|
| 13 |
+
protocol: TCP
|
| 14 |
+
targetPort: 8080
|
| 15 |
+
selector:
|
| 16 |
+
k8s-app: gbif
|
| 17 |
+
type: ClusterIP
|
tests/test-llm-app.R
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# interactive()
|
| 2 |
+
library(shiny)
|
| 3 |
+
library(bslib)
|
| 4 |
+
library(shinychat)
|
| 5 |
+
|
| 6 |
+
ui <- page_fillable(
|
| 7 |
+
chat_ui("chat", fill = TRUE)
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
server <- function(input, output, session) {
|
| 11 |
+
observeEvent(input$chat_user_input, {
|
| 12 |
+
# In a real app, this would call out to a chat model or API,
|
| 13 |
+
# perhaps using the 'ellmer' package.
|
| 14 |
+
response <- paste0(
|
| 15 |
+
"You said:\n\n",
|
| 16 |
+
"<blockquote>",
|
| 17 |
+
htmltools::htmlEscape(input$chat_user_input),
|
| 18 |
+
"</blockquote>"
|
| 19 |
+
)
|
| 20 |
+
chat_append("chat", NULL)
|
| 21 |
+
})
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
shinyApp(ui, server)
|
tests/test-llm.R
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
source("llm-gbif.R")
|
| 2 |
-
|
| 3 |
-
bench::bench_time({
|
| 4 |
-
txt_to_taxa("frogs", "qwen3")
|
| 5 |
-
})
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
bench::bench_time({
|
| 9 |
-
txt_to_taxa("frogs")
|
| 10 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|