Skip to content

Commit

Permalink
Merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
afwillia committed Nov 10, 2023
2 parents 9356ecb + 62a268d commit 7627904
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 30 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
45 changes: 36 additions & 9 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ 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-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")

config <- reactiveVal()
config_schema <- reactiveVal()

Expand Down Expand Up @@ -234,10 +240,28 @@ shinyServer(function(input, output, session) {
}
# Use the template dropdown config file from the appropriate branch of
# data_curator_config
conf_file <- reactiveVal(
file.path(config_dir, template_config_files[input$dropdown_asset_view])
)

conf_file <- reactiveVal(template_config_files[input$dropdown_asset_view])
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-old",
conf_file()
)
)
} else if (grepl("staging", dcc_config_file)) {
conf_file(
file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/staging",
conf_file()
)
)
} else {
conf_file(
file.path("https://raw.githubusercontent.com/Sage-Bionetworks/data_curator_config/main",
conf_file()
)
)
}
}
config_df <- jsonlite::fromJSON(conf_file())

conf_template <- setNames(config_df[[1]]$schema_name, config_df[[1]]$display_name)
Expand Down Expand Up @@ -309,13 +333,14 @@ shinyServer(function(input, output, session) {
})

observeEvent(input$info_box, {

nx_report_info(
title = "App Info",
title = sprintf("DCA for %s", dcc_config_react()$project_name),
tags$ul(
tags$li("DCA Help Docs: ", "todo"),
tags$li("Portal Help Docs: ", "todo"),
tags$li("Data model: ", data_model()),
tags$li("Asset view: ", selected$master_asset_view()),
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),
)
Expand Down Expand Up @@ -630,6 +655,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 @@ -979,6 +1005,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
9 changes: 3 additions & 6 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ ui <- shinydashboardPlus::dashboardPage(
),
# add sidebar footer here
tags$a(
id = "sidebar_footer", `data-toggle` = "tab", href = "#shiny-info_box",
id = "sidebar_footer", `data-toggle` = "tab",
tags$footer(
actionButton("info_box", "Info", icon("circle-info"), class="btn-info"),
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')
)
)
Expand All @@ -123,7 +123,7 @@ ui <- shinydashboardPlus::dashboardPage(
),
uiOutput("sass"),
# load dependencies
use_notiflix_report(width = "400px"),
use_notiflix_report(width = "500px", messageMaxLength = 10000),
use_waiter(),
tabItems(
# second tab content
Expand Down Expand Up @@ -297,9 +297,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 7627904

Please sign in to comment.