Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fds 395 add data model version #626

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ suppressPackageStartupMessages({
library(shinydashboardPlus)
library(promises)
library(future)
library(httr2)
# dashboard
library(purrr)
library(data.table)
Expand Down
36 changes: 36 additions & 0 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,10 @@ shinyServer(function(input, output, session) {
# reads file csv again
submit_data <- csvInfileServer("inputFile", colsAsCharacters = TRUE, keepBlank = TRUE, trimEmptyRows = TRUE)$data()

# If enabled, create a column in the manifest to store the data model URL
if (isTRUE(dcc_config_react()$dcc$data_model_version_as_column)) {
submit_data$DataModelURL <- data_model()
}
# If a file-based component selected (define file-based components) note for future
# the type to filter (eg file-based) on could probably also be a config choice
display_names <- config_schema()$manifest_schemas$display_name[config_schema()$manifest_schemas$type == "file"]
Expand Down Expand Up @@ -1132,6 +1136,38 @@ shinyServer(function(input, output, session) {

# if no error
if (startsWith(manifest_id(), "syn") == TRUE) {
# If enabled, annotate the file and folder with the data model
if (isTRUE(dcc_config_react()$dcc$data_model_version_as_annotation)) {
lapply(c(manifest_id()), function(id) { # add selected$folder() if annotating folder.
# Get existing annotations
annotations <- request(sprintf("https://repo-prod.prod.sagebase.org/repo/v1/entity/%s/annotations2", id)) |>
req_auth_bearer_token(access_token) |>
req_perform() |>
resp_body_json()
annotations_upload <- annotations$annotations
if (!"DataModelURL" %in% names(annotations_upload)) {
annotations_upload$DataModelURL <- list(
type="STRING", value=list(data_model())
)
}
add_annotation <- request(
sprintf(
"https://repo-prod.prod.sagebase.org/repo/v1/entity/%s/annotations2",
id
)) |>
req_method("PUT") |>
req_auth_bearer_token(access_token) |>
req_body_json(
list(
id = id,
etag = annotations$etag,
annotations = annotations_upload
)
) |>
req_error(is_error = function(x) FALSE) |>
req_perform()
})
}
dcWaiter("hide")
nx_report_success("Success!", HTML(paste0("Manifest submitted to: ", manifest_path)))

Expand Down
Loading