Skip to content

Commit d3c3841

Browse files
authored
Merge pull request #574 from Sage-Bionetworks/submit-error-popup
Add error handling to submit
2 parents 75c7b23 + dbca53d commit d3c3841

File tree

1 file changed

+73
-57
lines changed

1 file changed

+73
-57
lines changed

server.R

Lines changed: 73 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -896,26 +896,28 @@ shinyServer(function(input, output, session) {
896896

897897
# associates metadata with data and returns manifest id
898898
promises::future_promise({
899-
switch(dca_schematic_api,
900-
reticulate = model_submit_py(schema_generator,
901-
tmp_file_path,
902-
.folder,
903-
"table",
904-
FALSE),
905-
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
906-
schema_url = .data_model,
907-
data_type = NULL, # NULL to bypass validation
908-
dataset_id = .folder,
909-
access_token = access_token,
910-
restrict_rules = .restrict_rules,
911-
file_name = tmp_file_path,
912-
asset_view = .asset_view,
913-
use_schema_label=.submit_use_schema_labels,
914-
manifest_record_type=.submit_manifest_record_type,
915-
table_manipulation=.table_manipulation,
916-
hide_blanks=.hide_blanks),
917-
"synXXXX - No data uploaded"
918-
)
899+
try({
900+
switch(dca_schematic_api,
901+
reticulate = model_submit_py(schema_generator,
902+
tmp_file_path,
903+
.folder,
904+
"table",
905+
FALSE),
906+
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
907+
schema_url = .data_model,
908+
data_type = NULL, # NULL to bypass validation
909+
dataset_id = .folder,
910+
access_token = access_token,
911+
restrict_rules = .restrict_rules,
912+
file_name = tmp_file_path,
913+
asset_view = .asset_view,
914+
use_schema_label=.submit_use_schema_labels,
915+
manifest_record_type=.submit_manifest_record_type,
916+
table_manipulation=.table_manipulation,
917+
hide_blanks=.hide_blanks),
918+
"synXXXX - No data uploaded"
919+
)
920+
}, silent = TRUE)
919921
}) %...>% manifest_id()
920922

921923
} else {
@@ -938,26 +940,28 @@ shinyServer(function(input, output, session) {
938940
.hide_blanks <- dcc_config_react()$submit_hide_blanks
939941
# associates metadata with data and returns manifest id
940942
promises::future_promise({
941-
switch(dca_schematic_api,
942-
reticulate = model_submit_py(schema_generator,
943-
tmp_file_path,
944-
.folder,
945-
"table",
946-
FALSE),
947-
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
948-
schema_url = .data_model,
949-
data_type = NULL, # NULL to bypass validation
950-
dataset_id = .folder,
951-
access_token = access_token,
952-
restrict_rules = .restrict_rules,
953-
file_name = tmp_file_path,
954-
asset_view = .asset_view,
955-
use_schema_label=.submit_use_schema_labels,
956-
manifest_record_type=.submit_manifest_record_type,
957-
table_manipulation=.table_manipulation,
958-
hide_blanks=.hide_blanks),
959-
"synXXXX - No data uploaded"
960-
)
943+
try({
944+
switch(dca_schematic_api,
945+
reticulate = model_submit_py(schema_generator,
946+
tmp_file_path,
947+
.folder,
948+
"table",
949+
FALSE),
950+
rest = model_submit(url=file.path(api_uri, "v1/model/submit"),
951+
schema_url = .data_model,
952+
data_type = NULL, # NULL to bypass validation
953+
dataset_id = .folder,
954+
access_token = access_token,
955+
restrict_rules = .restrict_rules,
956+
file_name = tmp_file_path,
957+
asset_view = .asset_view,
958+
use_schema_label=.submit_use_schema_labels,
959+
manifest_record_type=.submit_manifest_record_type,
960+
table_manipulation=.table_manipulation,
961+
hide_blanks=.hide_blanks),
962+
"synXXXX - No data uploaded"
963+
)
964+
}, silent = TRUE)
961965
}) %...>% manifest_id()
962966

963967
}
@@ -967,27 +971,39 @@ shinyServer(function(input, output, session) {
967971
observeEvent(manifest_id(), {
968972

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

972-
# add log message
973-
message(paste0("Manifest :", sQuote(manifest_id()), " has been successfully uploaded"))
974-
975-
# if no error
976-
if (startsWith(manifest_id(), "syn") == TRUE) {
975+
if (inherits(manifest_id(), "try-error")) {
977976
dcWaiter("hide")
978-
nx_report_success("Success!", HTML(paste0("Manifest submitted to: ", manifest_path)))
979-
980-
# clean up old inputs/results
981-
sapply(clean_tags, FUN = hide)
982-
reset("inputFile-file")
983-
DTableServer("tbl_preview", data.frame(NULL))
977+
nx_report_error(title = "Error submitting manifest",
978+
message = tagList(
979+
p("Refresh the app to try again or contact the DCC for help."),
980+
p("For debugging: ", manifest_id())
981+
)
982+
)
984983
} else {
985-
dcWaiter("update", msg = HTML(paste0(
986-
"Uh oh, looks like something went wrong!",
987-
manifest_id,
988-
" is not a valid Synapse ID. Try again?"
989-
)), sleep = 0)
984+
manifest_path <- tags$a(href = paste0("https://www.synapse.org/#!Synapse:", manifest_id()), manifest_id(), target = "_blank")
985+
986+
# add log message
987+
message(paste0("Manifest :", sQuote(manifest_id()), " has been successfully uploaded"))
988+
989+
# if no error
990+
if (startsWith(manifest_id(), "syn") == TRUE) {
991+
dcWaiter("hide")
992+
nx_report_success("Success!", HTML(paste0("Manifest submitted to: ", manifest_path)))
993+
994+
# clean up old inputs/results
995+
sapply(clean_tags, FUN = hide)
996+
reset("inputFile-file")
997+
DTableServer("tbl_preview", data.frame(NULL))
998+
} else {
999+
dcWaiter("update", msg = HTML(paste0(
1000+
"Uh oh, looks like something went wrong!",
1001+
manifest_id,
1002+
" is not a valid Synapse ID. Try again?"
1003+
)), sleep = 0)
1004+
}
9901005
}
1006+
9911007
manifest_id(NULL)
9921008
})
9931009
})

0 commit comments

Comments
 (0)