Skip to content

Commit

Permalink
Merge pull request #580 from Sage-Bionetworks/develop
Browse files Browse the repository at this point in the history
Release 23.11.1
  • Loading branch information
afwillia authored Nov 15, 2023
2 parents 3df07a8 + 10286e8 commit 366007f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
23 changes: 10 additions & 13 deletions R/schematic_rest_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ check_success <- function(x){
manifest_download <- function(url = "http://localhost:3001/v1/manifest/download", access_token, asset_view, dataset_id, as_json=TRUE, new_manifest_name=NULL) {
request <- httr::GET(
url = url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query = list(
access_token = access_token,
asset_view = asset_view,
dataset_id = dataset_id,
as_json = as_json,
Expand Down Expand Up @@ -61,6 +61,7 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate",
strict_validation = FALSE) {

req <- httr::GET(url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query = list(
schema_url=schema_url,
title=title,
Expand All @@ -69,7 +70,6 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate",
dataset_id=dataset_id,
asset_view=asset_view,
output_format=output_format,
access_token = access_token,
strict_validation = strict_validation
))

Expand Down Expand Up @@ -161,12 +161,11 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit",
use_schema_label=TRUE, manifest_record_type="table_and_file", file_name,
table_manipulation="replace", hide_blanks=FALSE) {
req <- httr::POST(url,
#add_headers(Authorization=paste0("Bearer ", pat)),
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=list(
schema_url=schema_url,
data_type=data_type,
dataset_id=dataset_id,
access_token=access_token,
restrict_rules=restrict_rules,
json_str=json_str,
asset_view=asset_view,
Expand Down Expand Up @@ -230,11 +229,10 @@ storage_project_datasets <- function(url="http://localhost:3001/v1/storage/proje
access_token) {

req <- httr::GET(url,
#add_headers(Authorization=paste0("Bearer ", pat)),
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=list(
asset_view=asset_view,
project_id=project_id,
access_token=access_token)
project_id=project_id)
)

check_success(req)
Expand All @@ -254,9 +252,9 @@ storage_projects <- function(url="http://localhost:3001/v1/storage/projects",
access_token) {

req <- httr::GET(url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query = list(
asset_view=asset_view,
access_token=access_token
asset_view=asset_view
))

check_success(req)
Expand All @@ -280,13 +278,12 @@ storage_dataset_files <- function(url="http://localhost:3001/v1/storage/dataset/
full_path=FALSE, access_token) {

req <- httr::GET(url,
#add_headers(Authorization=paste0("Bearer ", pat)),
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=list(
asset_view=asset_view,
dataset_id=dataset_id,
file_names=file_names,
full_path=full_path,
access_token=access_token))
full_path=full_path))
check_success(req)
httr::content(req)

Expand All @@ -302,9 +299,9 @@ get_asset_view_table <- function(url="http://localhost:3001/v1/storage/assets/ta
access_token, asset_view, return_type="json") {

req <- httr::GET(url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=list(
asset_view=asset_view,
access_token=access_token,
return_type=return_type))

check_success(req)
Expand Down
2 changes: 2 additions & 0 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ncores <- availableCores()
message(sprintf("Available cores: %s", ncores))
plan(multicore, workers = ncores)

options(shiny.maxRequestSize=32*1024^2)

# import R files
source_files <- list.files(c("functions", "modules"), pattern = "*\\.R$", recursive = TRUE, full.names = TRUE)
sapply(source_files, FUN = source)
Expand Down
21 changes: 19 additions & 2 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ shinyServer(function(input, output, session) {
######## session global variables ########
# read config in
if (grepl("dev", dcc_config_file)) {
def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev/demo/dca-template-config.json")
def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev-old/demo/dca-template-config.json")
} else if (grepl("staging", dcc_config_file)) {
def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/staging/demo/dca-template-config.json")
} else def_config <- fromJSON("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/main/demo/dca-template-config.json")
Expand Down Expand Up @@ -235,7 +235,7 @@ shinyServer(function(input, output, session) {
if (!file.exists(conf_file())){
if (grepl("dev", dcc_config_file)) {
conf_file(
file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev",
file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/dev-old",
conf_file()
)
)
Expand Down Expand Up @@ -323,6 +323,21 @@ shinyServer(function(input, output, session) {
shinyjs::enable("btn_template_select")
})

observeEvent(input$info_box, {

nx_report_info(
title = sprintf("DCA for %s", dcc_config_react()$project_name),
tags$ul(
if (!is.na(dcc_config_react()$dca_help_link)) tags$li(tags$a(href = dcc_config_react()$dca_help_link, "DCA Help Docs", target = "_blank")),
if (!is.na(dcc_config_react()$portal_help_link)) tags$li(tags$a(href = dcc_config_react()$portal_help_link, "Portal Help Docs", target = "_blank")),
if (!is.na(dcc_config_react()$data_model_info)) tags$li(tags$a(href = dcc_config_react()$data_model_info, "Data Model Info", target = "_blank")),
tags$li(tags$a(href = paste0("https://www.synapse.org/#!Synapse:", selected$master_asset_view()), paste("Asset View:", selected$master_asset_view()), target = "_blank")),
tags$li("DCA version: ", dca_version),
tags$li("Schematic version: ", schematic_version),
)
)
})

# Goal of this observer is to get all of the folders within the selected
# project.
observeEvent(input$btn_project, {
Expand Down Expand Up @@ -631,6 +646,7 @@ shinyServer(function(input, output, session) {
p("Try again or contact the DCC for help"),
p("For debugging: ", manifest_data())
))
hide(selector = "#NXReportButton") # hide OK button so users can't continue
shinyjs::enable("btn_template_select")
updateTabsetPanel(session, "tab_template_select")
} else {
Expand Down Expand Up @@ -980,6 +996,7 @@ shinyServer(function(input, output, session) {
p("For debugging: ", manifest_id())
)
)
hide(selector = "#NXReportButton") # hide OK button so users can't continue
} else {
manifest_path <- tags$a(href = paste0("https://www.synapse.org/#!Synapse:", manifest_id()), manifest_id(), target = "_blank")

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_schematic_rest_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ context("test schematic rest api wrappers")
### schematic server URL https://github.com/Sage-Bionetworks/schematic/tree/develop/api
### If not available, skip these tests.

schematic_url <- "https://schematic.api.sagebionetworks.org"
schematic_url <- "https://schematic-dev.api.sagebionetworks.org"
ping <- try(httr::GET(schematic_url), silent = TRUE)
skip_it <- function(skip=ping) {
if (inherits(ping, "try-error")) skip(sprintf("schematic server URL unavailable (%s). Is it running locally?", schematic_url)) #nolint
Expand All @@ -20,7 +20,7 @@ test_that("manifest_generate returns a URL if sucessful", {
skip_it()

url <- manifest_generate(url=file.path(schematic_url, "v1/manifest/generate"),
schema_url = schema_url, input_token = Sys.getenv("SNYAPSE_PAT"),
schema_url = schema_url, access_token = Sys.getenv("SNYAPSE_PAT"),
title="Test biospecimen", data_type="Biospecimen",
use_annotations = FALSE,
dataset_id="syn33715357", asset_view="syn33715412",
Expand Down
13 changes: 7 additions & 6 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ ui <- shinydashboardPlus::dashboardPage(
# add sidebar footer here
tags$a(
id = "sidebar_footer", `data-toggle` = "tab",
tags$footer(HTML(' Powered by <i class="far fa-heart"></i> and Sage Bionetworks'))
tags$footer(
actionButton("info_box", "About Data Curator", icon("circle-info"), class="btn-primary-color"),
HTML('&#12288 Powered by <i class="far fa-heart"></i> and Sage Bionetworks')
)
)
)
)
)
),
dashboardBody(
Expand All @@ -120,7 +123,8 @@ ui <- shinydashboardPlus::dashboardPage(
),
uiOutput("sass"),
# load dependencies
use_notiflix_report(width = "400px"),
use_notiflix_report(width = "500px", messageMaxLength = 10000,
titleMaxLength = 100),
use_waiter(),
tabItems(
# second tab content
Expand Down Expand Up @@ -294,9 +298,6 @@ ui <- shinydashboardPlus::dashboardPage(
),
# waiter loading screen
dcWaiter("show", landing = TRUE)
),
footer = dashboardFooter(
left = sprintf("DCA %s - Schematic %s", dca_version, schematic_version)
)
)

Expand Down

0 comments on commit 366007f

Please sign in to comment.