Skip to content

Commit

Permalink
Merge pull request #207 from Sage-Bionetworks/dev
Browse files Browse the repository at this point in the history
Dev to staging v23.06.1
  • Loading branch information
lakikowolfe authored Jun 20, 2023
2 parents 8059ab1 + da1c15a commit 48fcffb
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 34 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/shinyapps_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
runs-on: ubuntu-latest
container: rocker/rstudio:4.1.2
env:
SCHEMATIC_URL_DEV: https://schematic-dev.api.sagebionetworks.org
SCHEMATIC_URL_STAGING: https://schematic-staging.api.sagebionetworks.org
SCHEMATIC_URL_PROD: https://schematic.api.sagebionetworks.org
# This should not be necessary for installing from public repo's however remotes::install_github() fails without it.
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -30,17 +33,15 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y pip libcurl4-openssl-dev libpng-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libtiff-dev libxml2-dev
# this action checks out the $GITHUB_WORKSPACE repository so that the workflow can access it
# this action checks out the $GITHUB_WORKSPACE repository so that the workflow can access it
- uses: actions/checkout@v3
# this action sets up pandoc

# this action sets up pandoc
- uses: r-lib/actions/setup-pandoc@v2
# this action activates renv

# this action activates renv
- uses: r-lib/actions/setup-renv@v2
# Write synapse config (not sure if I even need this??)
- name: Set Configurations
shell: bash
run: |
echo "${{ secrets.SCHEMATIC_SYNAPSE_CONFIG }}" > .synapseConfig
# deploy app using rsconnect
- name: Authorize and deploy app
run: |
Expand All @@ -51,19 +52,29 @@ jobs:
repo <- Sys.getenv("GITHUB_REPOSITORY")
appName <- strsplit(repo, "/")[[1]][2]
# if tag is v*.*.*, deploy to prod, if main to staging, otherwise to test
# if tag is v*.*.*, deploy to prod
# if main to staging
# otherwise to test
if (grepl("v[0-9]+.[0-9]+.[0-9]+", refName)) {
message("Deploying release version of app")
message("Deploying release version of app using schematic API production instance")
renviron <- "DFA_SCHEMATIC_API_URL = '${{ env.SCHEMATIC_URL_PROD }}'"
} else if (refName == "main") {
appName <- paste(appName, "staging", sep = "-")
message("Deploying staging version of app")
renviron <- "DFA_SCHEMATIC_API_URL = '${{ env.SCHEMATIC_URL_STAGING }}'"
message("Deploying staging version of app using schematic API staging instance")
} else {
appName <- paste(appName, "testing", sep = "-")
message("Deploying testing version of app")
renviron <- "DFA_SCHEMATIC_API_URL = '${{ env.SCHEMATIC_URL_DEV }}'"
message("Deploying testing version of app using schematic API dev instance")
}
# write .Renviron
writeLines(renviron, ".Renviron")
# deploy
message(sprintf("Deploying to %s instance.", appName))
# assign secrets to variables
rsConnectUser <-"${{ secrets.RSCONNECT_USER }}"
rsConnectToken <- "${{ secrets.RSCONNECT_TOKEN }}"
rsConnectSecret <- "${{ secrets.RSCONNECT_SECRET }}"
Expand All @@ -74,15 +85,17 @@ jobs:
appUrl<- sprintf("https://%s.shinyapps.io/%s", rsConnectUser, appName)
config <- c(config, sprintf("app_url: %s", appUrl))

# write config file
configFileConn<-file("oauth_config.yml")
tryCatch(
writeLines(config, configFileConn),
finally=close(configFileConn)
)
# FIXME ADD size parameter

# set account info
rsconnect::setAccountInfo(rsConnectUser, rsConnectToken, rsConnectSecret)

# Get app names. If app exists, configure then deploy. Otherwise
# get app names. If app exists, configure then deploy. Otherwise
# deploy then configure.
apps <- rsconnect::applications()$name
if (appName %in% apps) {
Expand All @@ -92,4 +105,4 @@ jobs:
rsconnect::deployApp(appName = appName)
rsconnect::configureApp(appName = appName, size = "xxxlarge", logLevel = "verbose")
}
shell: Rscript {0}
shell: Rscript {0}
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dataflow
Title: Data Flow App Demo
Version: 0.0.0.9000
Version: 23.06.1
Authors@R: person('L', 'Wolfe', email = '[email protected]', role = c('cre', 'aut'))
Description: A data flow package.
License: MIT + file LICENSE
Expand Down
17 changes: 6 additions & 11 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
app_server <- function( input, output, session ) {
# Your application server logic
options(shiny.reactlog = TRUE)



# AUTHENTICATION
params <- parseQueryString(isolate(session$clientData$url_search))
if (!has_auth_code(params)) {
Expand All @@ -35,10 +34,6 @@ app_server <- function( input, output, session ) {
access_token <- token_response$access_token

session$userData$access_token <- access_token
# DEV STUFF ###########################################################################

# read in configs
global_config <- jsonlite::read_json("inst/global.json")

# generate dashboard configuration from dataFlow schema
dash_config <- dfamodules::generate_dashboard_config(schema_url = global_config$schema_url,
Expand All @@ -58,13 +53,13 @@ app_server <- function( input, output, session ) {
release_scheduled = "Not Scheduled",
embargo = "No Embargo",
dataset = "No Manifest"),
base_url = global_config$api_base_url)
base_url = schematic_api_url)

# download data flow status manifest
manifest_obj <- dfamodules::dataset_manifest_download(asset_view = global_config$asset_view,
dataset_id = global_config$manifest_dataset_id,
access_token = access_token,
base_url = global_config$api_base_url)
base_url = schematic_api_url)

manifest_dfa <- dfamodules::prep_manifest_dfa(manifest = manifest_obj$content,
config = dash_config)
Expand Down Expand Up @@ -246,15 +241,15 @@ app_server <- function( input, output, session ) {
select_storage_project_out <- dfamodules::mod_select_storage_project_server(id = "select_storage_project_1",
asset_view = global_config$asset_view,
access_token = access_token,
base_url = global_config$api_base_url)
base_url = schematic_api_url)

# DATASET SELECTION

dataset_selection <- dfamodules::mod_dataset_selection_server(id = "dataset_selection_1",
storage_project_df = select_storage_project_out,
asset_view = global_config$asset_view,
access_token = access_token,
base_url = global_config$api_base_url)
base_url = schematic_api_url)

# UPDATE DATA FLOW STATUS SELECTIONS
updated_data_flow_status <- dfamodules::mod_update_data_flow_status_server("update_data_flow_status_1")
Expand Down Expand Up @@ -320,7 +315,7 @@ app_server <- function( input, output, session ) {
dataset_id = global_config$manifest_dataset_id,
manifest_dir = "./manifest",
access_token = access_token,
base_url = global_config$api_base_url,
base_url = schematic_api_url,
schema_url = global_config$schema_url)

}
20 changes: 19 additions & 1 deletion R/global.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
library(yaml)
# READ IN CONFIG
global_config <- jsonlite::read_json("inst/global.json")

# GET SCHEMATIC API URL
# If there is a config file, use that
# Else use environment variables
if ("schematic_api_url" %in% names(global_config)) {
schematic_api_url <- global_config$schematic_api_url
} else {
schematic_api_url <- Sys.getenv("DFA_SCHEMATIC_API_URL")
}

# check that all variables are present
if (is.null(schematic_api_url) || nchar(schematic_api_url) == 0) stop("missing DFA_SCHEMATIC_API_URL environmental variable")
if (is.null(global_config$asset_view) || nchar(global_config$asset_view) == 0) stop("asset_view is missing from global.json")
if (is.null(global_config$manifest_dataset_id) || nchar(global_config$manifest_dataset_id) == 0) stop("manifest_dataset_id is missing from global.json")
if (is.null(global_config$schema_url) || nchar(global_config$schema_url) == 0) stop("schema_url is missing from global.json")

message("DFA is using ", schematic_api_url)

# SET UP OAUTH
oauth_client <- yaml::yaml.load_file("oauth_config.yml")
Expand Down
3 changes: 1 addition & 2 deletions inst/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"asset_view": "syn50896957",
"manifest_dataset_id": "syn50900267",
"schema_url": "https://raw.githubusercontent.com/Sage-Bionetworks/data_flow/main/inst/data_model/dataflow_component.jsonld",
"api_base_url": "https://schematic-staging.api.sagebionetworks.org"
"schema_url": "https://raw.githubusercontent.com/Sage-Bionetworks/data_flow/main/inst/data_model/dataflow_component.jsonld"
}
84 changes: 80 additions & 4 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@
],
"Hash": "e8a22846fff485f0be3770c2da758713"
},
"assertthat": {
"Package": "assertthat",
"Version": "0.2.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"tools"
],
"Hash": "50c838a310445e954bc13f26f26a6ecf"
},
"attempt": {
"Package": "attempt",
"Version": "0.3.1",
Expand Down Expand Up @@ -415,14 +425,14 @@
},
"dfamodules": {
"Package": "dfamodules",
"Version": "23.05.4",
"Version": "23.06.1",
"Source": "GitHub",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteUsername": "Sage-Bionetworks",
"RemoteRepo": "dfamodules",
"RemoteRef": "main",
"RemoteSha": "f752696c312c55213847b6f355e8e71a1a5ab33f",
"RemoteRef": "v23.06.1",
"RemoteSha": "b9aae411037b6c367c3147648397672b53dc8e46",
"Requirements": [
"DT",
"dplyr",
Expand All @@ -439,7 +449,7 @@
"shinyjs",
"waiter"
],
"Hash": "c731727e2e4c768b015ffe9eb465f2aa"
"Hash": "7fa1b0d1960ea992c07eed141875d46f"
},
"diffobj": {
"Package": "diffobj",
Expand Down Expand Up @@ -1064,6 +1074,13 @@
],
"Hash": "0f7cd2962e3044bb940cca4f4b5cecbe"
},
"parsedate": {
"Package": "parsedate",
"Version": "1.3.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "7f5024cc7af45eeecef657fa62beb568"
},
"patchwork": {
"Package": "patchwork",
"Version": "1.1.2",
Expand Down Expand Up @@ -1345,6 +1362,13 @@
],
"Hash": "b5047343b3825f37ad9d3b5d89aa1078"
},
"rematch": {
"Package": "rematch",
"Version": "1.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "c66b930d20bb6d858cd18e1cebcfae5c"
},
"rematch2": {
"Package": "rematch2",
"Version": "2.1.2",
Expand Down Expand Up @@ -1379,6 +1403,36 @@
],
"Hash": "4543b8cd233ae25c6aba8548be9e747e"
},
"rhub": {
"Package": "rhub",
"Version": "1.1.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R6",
"assertthat",
"callr",
"cli",
"crayon",
"desc",
"digest",
"httr",
"jsonlite",
"parsedate",
"pillar",
"prettyunits",
"processx",
"rappdirs",
"rcmdcheck",
"rematch",
"tibble",
"utils",
"uuid",
"whoami",
"withr"
],
"Hash": "e0880f6783f720d136755fb92d63c78b"
},
"rlang": {
"Package": "rlang",
"Version": "1.1.1",
Expand Down Expand Up @@ -1821,6 +1875,16 @@
],
"Hash": "1fe17157424bb09c48a8b3b550c753bc"
},
"uuid": {
"Package": "uuid",
"Version": "1.1-0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "f1cb46c157d080b729159d407be83496"
},
"vctrs": {
"Package": "vctrs",
"Version": "0.6.2",
Expand Down Expand Up @@ -1907,6 +1971,18 @@
"Repository": "CRAN",
"Hash": "c6abfa47a46d281a7d5159d0a8891e88"
},
"whoami": {
"Package": "whoami",
"Version": "1.3.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"httr",
"jsonlite",
"utils"
],
"Hash": "ef0f4d9b8f2cc2ebeccae1d725b8a023"
},
"withr": {
"Package": "withr",
"Version": "2.5.0",
Expand Down

0 comments on commit 48fcffb

Please sign in to comment.