Skip to content

Commit

Permalink
Merge branch 'submit-error-popup' into v23.10.1-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
afwillia committed Sep 27, 2023
2 parents 79dda58 + b69ab93 commit 6f98472
Showing 1 changed file with 73 additions and 57 deletions.
130 changes: 73 additions & 57 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -902,26 +902,28 @@ shinyServer(function(input, output, session) {

# associates metadata with data and returns manifest id
promises::future_promise({
switch(dca_schematic_api,
reticulate = model_submit_py(schema_generator,
tmp_file_path,
.folder,
"table",
FALSE),
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
schema_url = .data_model,
data_type = NULL, # NULL to bypass validation
dataset_id = .folder,
access_token = access_token,
restrict_rules = .restrict_rules,
file_name = tmp_file_path,
asset_view = .asset_view,
use_schema_label=.submit_use_schema_labels,
manifest_record_type=.submit_manifest_record_type,
table_manipulation=.table_manipulation,
hide_blanks=.hide_blanks),
"synXXXX - No data uploaded"
)
try({
switch(dca_schematic_api,
reticulate = model_submit_py(schema_generator,
tmp_file_path,
.folder,
"table",
FALSE),
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
schema_url = .data_model,
data_type = NULL, # NULL to bypass validation
dataset_id = .folder,
access_token = access_token,
restrict_rules = .restrict_rules,
file_name = tmp_file_path,
asset_view = .asset_view,
use_schema_label=.submit_use_schema_labels,
manifest_record_type=.submit_manifest_record_type,
table_manipulation=.table_manipulation,
hide_blanks=.hide_blanks),
"synXXXX - No data uploaded"
)
}, silent = TRUE)
}) %...>% manifest_id()

} else {
Expand All @@ -944,26 +946,28 @@ shinyServer(function(input, output, session) {
.hide_blanks <- dcc_config_react()$submit_hide_blanks
# associates metadata with data and returns manifest id
promises::future_promise({
switch(dca_schematic_api,
reticulate = model_submit_py(schema_generator,
tmp_file_path,
.folder,
"table",
FALSE),
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
schema_url = .data_model,
data_type = NULL, # NULL to bypass validation
dataset_id = .folder,
access_token = access_token,
restrict_rules = .restrict_rules,
file_name = tmp_file_path,
asset_view = .asset_view,
use_schema_label=.submit_use_schema_labels,
manifest_record_type=.submit_manifest_record_type,
table_manipulation=.table_manipulation,
hide_blanks=.hide_blanks),
"synXXXX - No data uploaded"
)
try({
switch(dca_schematic_api,
reticulate = model_submit_py(schema_generator,
tmp_file_path,
.folder,
"table",
FALSE),
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
schema_url = .data_model,
data_type = NULL, # NULL to bypass validation
dataset_id = .folder,
access_token = access_token,
restrict_rules = .restrict_rules,
file_name = tmp_file_path,
asset_view = .asset_view,
use_schema_label=.submit_use_schema_labels,
manifest_record_type=.submit_manifest_record_type,
table_manipulation=.table_manipulation,
hide_blanks=.hide_blanks),
"synXXXX - No data uploaded"
)
}, silent = TRUE)
}) %...>% manifest_id()

}
Expand All @@ -973,27 +977,39 @@ shinyServer(function(input, output, session) {
observeEvent(manifest_id(), {

req(!is.null(manifest_id()))
manifest_path <- tags$a(href = paste0("https://www.synapse.org/#!Synapse:", manifest_id()), manifest_id(), target = "_blank")

# add log message
message(paste0("Manifest :", sQuote(manifest_id()), " has been successfully uploaded"))

# if no error
if (startsWith(manifest_id(), "syn") == TRUE) {
if (inherits(manifes_id(), "try-error")) {
dcWaiter("hide")
nx_report_success("Success!", HTML(paste0("Manifest submitted to: ", manifest_path)))

# clean up old inputs/results
sapply(clean_tags, FUN = hide)
reset("inputFile-file")
DTableServer("tbl_preview", data.frame(NULL))
nx_report_error(title = "Error submitting manifest",
message = tagList(
p("Refresh the app to try again or contact the DCC for help."),
p("For debugging: ", manifest_id())
)
)
} else {
dcWaiter("update", msg = HTML(paste0(
"Uh oh, looks like something went wrong!",
manifest_id,
" is not a valid Synapse ID. Try again?"
)), sleep = 0)
manifest_path <- tags$a(href = paste0("https://www.synapse.org/#!Synapse:", manifest_id()), manifest_id(), target = "_blank")

# add log message
message(paste0("Manifest :", sQuote(manifest_id()), " has been successfully uploaded"))

# if no error
if (startsWith(manifest_id(), "syn") == TRUE) {
dcWaiter("hide")
nx_report_success("Success!", HTML(paste0("Manifest submitted to: ", manifest_path)))

# clean up old inputs/results
sapply(clean_tags, FUN = hide)
reset("inputFile-file")
DTableServer("tbl_preview", data.frame(NULL))
} else {
dcWaiter("update", msg = HTML(paste0(
"Uh oh, looks like something went wrong!",
manifest_id,
" is not a valid Synapse ID. Try again?"
)), sleep = 0)
}
}

manifest_id(NULL)
})
})

0 comments on commit 6f98472

Please sign in to comment.