Skip to content

Commit

Permalink
autodeploy
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed Dec 20, 2024
1 parent ed27e2b commit c2a1e5b
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 45 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Sync to Hugging Face hub
on:
push:
branches: [main]

# to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
sync-to-hub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Push to hub
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: git push https://cboettig:[email protected]/spaces/boettiger-lab/geo-llm-r main
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM rocker/r-base:latest

WORKDIR /code

RUN install2.r --error \
shiny \
dplyr \
ggplot2 \
readr \
ggExtra

COPY . .

CMD ["R", "--quiet", "-e", "shiny::runApp(host='0.0.0.0', port=7860)"]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# geo-llm-r
---
title: Geo Llm R
emoji: 📚
colorFrom: blue
colorTo: yellow
sdk: docker
pinned: false
license: bsd-2-clause
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
95 changes: 51 additions & 44 deletions app.R
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# https://shiny.posit.co/
#

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

# Application title
titlePanel("Old Faithful Geyser Data"),

# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),

# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
library(bslib)
library(dplyr)
library(ggplot2)

df <- readr::read_csv("penguins.csv")
# Find subset of columns that are suitable for scatter plot
df_num <- df |> select(where(is.numeric), -Year)

ui <- page_sidebar(
theme = bs_theme(bootswatch = "minty"),
title = "Penguins explorer",
sidebar = sidebar(
varSelectInput("xvar", "X variable", df_num, selected = "Bill Length (mm)"),
varSelectInput("yvar", "Y variable", df_num, selected = "Bill Depth (mm)"),
checkboxGroupInput("species", "Filter by species",
choices = unique(df$Species), selected = unique(df$Species)
),
hr(), # Add a horizontal rule
checkboxInput("by_species", "Show species", TRUE),
checkboxInput("show_margins", "Show marginal plots", TRUE),
checkboxInput("smooth", "Add smoother"),
),
plotOutput("scatter")
)

# Define server logic required to draw a histogram
server <- function(input, output) {
server <- function(input, output, session) {
subsetted <- reactive({
req(input$species)
df |> filter(Species %in% input$species)
})

output$scatter <- renderPlot(
{
p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
theme_light() +
list(
theme(legend.position = "bottom"),
if (input$by_species) aes(color = Species),
geom_point(),
if (input$smooth) geom_smooth()
)

output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
if (input$show_margins) {
margin_type <- if (input$by_species) "density" else "histogram"
p <- p |> ggExtra::ggMarginal(
type = margin_type, margins = "both",
size = 8, groupColour = input$by_species, groupFill = input$by_species
)
}

# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white',
xlab = 'Waiting time to next eruption (in mins)',
main = 'Histogram of waiting times')
})
p
},
res = 100
)
}

# Run the application
shinyApp(ui = ui, server = server)
shinyApp(ui, server)
Loading

0 comments on commit c2a1e5b

Please sign in to comment.