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

v24.1.2 #584

Merged
merged 55 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
708a6c2
Read in dcc config as json instead of csv. Move template menu config …
afwillia Oct 26, 2023
7b19f59
Refactor asset view dropdown to be consistent with new config in glob…
afwillia Oct 26, 2023
759bc13
WIP: first pass at refactoring server code to handle the new dcc conf…
afwillia Oct 26, 2023
9788024
update logo location for new config structure
afwillia Oct 26, 2023
0576e86
Fix color on initial waiter screen after selecting asset view.
afwillia Oct 26, 2023
4bc9b3b
Create a variable for the root directory of the config file
afwillia Oct 27, 2023
9356ecb
Combine config root dir and config filepath to read files.
afwillia Oct 27, 2023
7076dec
Merge branch 'FDS-1185-info-box' into rc.23.11.1
afwillia Nov 2, 2023
0295863
Add functions to generate template config
afwillia Nov 2, 2023
1787935
add httr to imports
afwillia Nov 2, 2023
14188c8
add dplyr and jsonlite to imports
afwillia Nov 2, 2023
afe0217
use df not argument
afwillia Nov 2, 2023
db1827a
add pretty and flatten argument to write json
afwillia Nov 2, 2023
2c97e9f
use autounbox to write config
afwillia Nov 2, 2023
c903aed
put graph_by_edge_type in schematic rest api file
afwillia Nov 7, 2023
11c164d
Clarify function names
afwillia Nov 7, 2023
9da3090
export write_dca_template_config
afwillia Nov 7, 2023
0c76c2a
export write_dca_template_config
afwillia Nov 7, 2023
59c714b
export write_dca_template_config for real
afwillia Nov 7, 2023
b285343
fix function name in write_dca_template_config
afwillia Nov 7, 2023
05dc657
fix function name in write_dca_template_config again
afwillia Nov 7, 2023
d583b95
remove dca and schematic version from footer
afwillia Nov 7, 2023
403e10c
display dcc and portal help links if set
afwillia Nov 7, 2023
6549cda
Use nested structure for dca_config and only reference primary_col in…
afwillia Nov 7, 2023
fe1e76a
When determining which components are file- or record-based, filter t…
afwillia Nov 9, 2023
0a7cc6c
Add options to include or exclude schemas from template config
afwillia Nov 9, 2023
491f6d9
default include_schemas and exclude_schemas to NULL. Check if values …
afwillia Nov 9, 2023
c0e749e
set include_schemas and exclude_schemas to NULL
afwillia Nov 9, 2023
e4bbc21
use base pipe operator
afwillia Nov 9, 2023
ebe4ed3
remove empty argument from filter
afwillia Nov 9, 2023
7627904
Merge develop
afwillia Nov 10, 2023
c3bcd04
Merge config functions from rc23.11.1
afwillia Nov 10, 2023
18db322
Update info panel for json config
afwillia Nov 10, 2023
fe42403
Merge branch 'develop' into FDS-1215-refactor-config
afwillia Nov 14, 2023
2cd381a
WIP: add project_scope to validation endpoint
afwillia Nov 15, 2023
a9f25f0
WIP: add asset view as project scope to validation endpoint
afwillia Nov 15, 2023
e715daa
Merge branch 'develop' into FDS-1215-refactor-config
afwillia Nov 15, 2023
38ed6dd
remove config dir from urls in config files
afwillia Nov 17, 2023
9552104
Merge pull request #575 from Sage-Bionetworks/FDS-1215-refactor-config
afwillia Nov 28, 2023
c84f1c9
Merge branch 'develop' of https://github.com/Sage-Bionetworks/data_cu…
afwillia Nov 28, 2023
83a46ff
Merge branch 'develop' into FDS-1301-cross-manifest-validation
afwillia Nov 28, 2023
aef9d0b
WIP: add ability to pass multiple project_scope to manifest_validate
afwillia Nov 28, 2023
e9a4aec
Add asset view to manifest_validate
afwillia Nov 28, 2023
99854d0
Remove node uninstall/install from Dockerfile.
afwillia Dec 5, 2023
ae3c103
Merge pull request #582 from Sage-Bionetworks/FDS-1273-node-update
afwillia Dec 13, 2023
4f0e69b
remove browser statement
afwillia Nov 28, 2023
cab25a0
Merge branch 'FDS-1301-cross-manifest-validation' of https://github.c…
afwillia Dec 14, 2023
1c86261
fix argument assignment operator in manifest_validation function call
afwillia Dec 14, 2023
7042e23
WIP: check the template config for project scope. If no project scope…
afwillia Dec 14, 2023
c81a450
Merge branch 'develop' into FDS-1301-cross-manifest-validation
afwillia Dec 20, 2023
c397b7a
Remove two obsolete statements.
afwillia Jan 2, 2024
c5d066c
Merge branch 'FDS-1301-cross-manifest-validation' of https://github.c…
afwillia Jan 2, 2024
a5532ba
Merge pull request #581 from Sage-Bionetworks/FDS-1301-cross-manifest…
afwillia Jan 2, 2024
c28db5a
Read the project scope into a vector from the template config file.
afwillia Jan 2, 2024
94bd899
Merge pull request #583 from Sage-Bionetworks/FDS-1301-cross-manifest…
afwillia Jan 3, 2024
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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Authors: Rongrong Chai, Xengie Doan, Milen Nikolov, Sujay Patil, Robert Allaway,
License: file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Imports: httr, dplyr, jsonlite
Suggests:
covr
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ RUN apt-get install -y libxml2 libglpk-dev libicu-dev libicu70 curl
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
RUN chmod 777 /etc/shiny-server/shiny-server.conf

# Update node. https://github.com/nodesource/distributions
RUN apt-get remove nodejs
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && apt-get install -y nodejs

USER shiny

WORKDIR /srv/shiny-server/app
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(create_dca_template_config)
export(create_template_config)
export(format_edge_type)
export(get_asset_view_table)
export(get_display_names)
export(graph_by_edge_type)
export(manifest_download)
export(manifest_generate)
export(manifest_populate)
Expand All @@ -14,3 +19,6 @@ export(synapse_access)
export(synapse_get)
export(synapse_is_certified)
export(synapse_user_profile)
export(write_dca_template_config)
importFrom(httr,GET)
importFrom(httr,content)
44 changes: 41 additions & 3 deletions R/schematic_rest_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,36 @@ manifest_populate <- function(url="http://localhost:3001/v1/manifest/populate",
#' @export
manifest_validate <- function(url="http://localhost:3001/v1/model/validate",
schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #nolint
data_type, file_name, restrict_rules=FALSE) {
data_type, file_name, restrict_rules=FALSE, project_scope = NULL,
access_token, asset_view = NULL) {

flattenbody <- function(x) {
# A form/query can only have one value per name, so take
# any values that contain vectors length >1 and
# split them up
# list(x=1:2, y="a") becomes list(x=1, x=2, y="a")
if (all(lengths(x)<=1)) return(x);
do.call("c", mapply(function(name, val) {
if (length(val)==1 || any(c("form_file", "form_data") %in% class(val))) {
x <- list(val)
names(x) <- name
x
} else {
x <- as.list(val)
names(x) <- rep(name, length(val))
x
}
}, names(x), x, USE.NAMES = FALSE, SIMPLIFY = FALSE))
}

req <- httr::POST(url,
query=list(
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=flattenbody(list(
schema_url=schema_url,
data_type=data_type,
restrict_rules=restrict_rules),
restrict_rules=restrict_rules,
project_scope = project_scope,
asset_view = asset_view)),
body=list(file_name=httr::upload_file(file_name))
)

Expand Down Expand Up @@ -314,3 +338,17 @@ get_asset_view_table <- function(url="http://localhost:3001/v1/storage/assets/ta

}

#' @param url URL of schematic API endpoint
#' @param schema_url URL of data model
#' @param relationship Argument to schematic graph_by_edge_type
#' @export
#' @importFrom httr GET content
graph_by_edge_type <- function(url = "https://schematic-dev.api.sagebionetworks.org/v1/schemas/get/graph_by_edge_type",
schema_url, relationship = "requiresDependency") {
req <- httr::GET(url = url,
query = list(
schema_url = schema_url,
relationship = relationship
))
httr::content(req)
}
63 changes: 63 additions & 0 deletions R/template_config.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#' @export
format_edge_type <- function(edge_types) {
et <- dplyr::bind_rows(lapply(edge_types, function(x) data.frame(value = x[[2]], schema_name = x[[1]])))
components <- et |>
dplyr::filter(tolower(value) == "component") |>
dplyr::pull(schema_name)
et |>
dplyr::filter(value %in% c("Component", "Filename")) |>
dplyr::group_by(schema_name) |>
dplyr::summarise(file_based = "Filename" %in% value) |>
dplyr::filter(schema_name %in% components)
}

#' @export
get_display_names <- function(qlist) {
if (!"schema_url" %in% names(qlist)) stop("qlist needs element named `schema_url`")
if (!"node_list" %in% names(qlist)) stop("qlist needs at least one element named `node_list`")
httr::GET(
url = "https://schematic-dev.api.sagebionetworks.org/v1/schemas/get_nodes_display_names",
query = qlist
)
}

#' @export
create_template_config <- function(data_model, include_schemas = NULL, exclude_schemas = NULL) {
if (!is.null(include_schemas) && !is.null(exclude_schemas)) stop("include_schemas and exclude_schemas cannot both have values")
edges <- graph_by_edge_type(schema_url = data_model)
schema_names <- format_edge_type(edges)
nl <- setNames(as.list(schema_names$schema_name), rep("node_list", length(schema_names$schema_name)))
dnames <- get_display_names(c(schema_url = data_model, nl)) |> httr::content()
config <- data.frame(display_name = unlist(dnames), schema_name = unlist(nl)) |>
dplyr::left_join(schema_names, by = "schema_name") |>
dplyr::mutate(type = ifelse(file_based, "file", "record")) |>
dplyr::select(-file_based)
if (!is.null(include_schemas)) {
if (any(length(x <- setdiff(include_schemas, config$schema_name)))) stop(sprintf("%s is not a schema name in the data model", x))
config <- dplyr::filter(config, schema_name %in% include_schemas)
}
if (!is.null(exclude_schemas)) {
if (any(length(y <- setdiff(exclude_schemas, config$schema_name)))) stop(sprintf("%s is not a schema name in the data model", y))
config <- dplyr::filter(config, !schema_name %in% exclude_schemas)
}
config
}

#' @export
create_dca_template_config <- function(data_model, include_schemas = NULL, exclude_schemas = NULL) {
df <- create_template_config(data_model, include_schemas, exclude_schemas)
schematic_version <- httr::GET("https://schematic-dev.api.sagebionetworks.org/v1/version") |>
httr::content()
list(
manifest_schemas = df,
service_version = schematic_version,
schema_version = ""
)
}

#' @export
#' @description Create a DCA-specific template generation function
write_dca_template_config <- function(data_model, file, include_schemas = NULL, exclude_schemas = NULL) {
df <- create_dca_template_config(data_model, include_schemas, exclude_schemas)
jsonlite::write_json(df, file, pretty = TRUE, auto_unbox = TRUE)
}
11 changes: 4 additions & 7 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ options(shiny.maxRequestSize=32*1024^2)
source_files <- list.files(c("functions", "modules"), pattern = "*\\.R$", recursive = TRUE, full.names = TRUE)
sapply(source_files, FUN = source)

dcc_config_file <- Sys.getenv("DCA_DCC_CONFIG")
dcc_config <- read_csv(dcc_config_file, show_col_types = FALSE)
if (Sys.getenv("DCA_DCC_CONFIG") == "") stop("missing DCA_DCC_CONFIG environment variable")
dca_dcc_config <- read_json(Sys.getenv("DCA_DCC_CONFIG"), simplifyVector = TRUE)
tenants_config <- dca_dcc_config$tenants
config_dir <- dirname(Sys.getenv("DCA_DCC_CONFIG"))

## Set Up OAuth
client_id <- Sys.getenv("DCA_CLIENT_ID")
Expand Down Expand Up @@ -127,11 +129,6 @@ api <- oauth_endpoint(
# The 'openid' scope is required by the protocol for retrieving user information.
scope <- "openid view download modify"

template_config_files <- setNames(dcc_config$template_menu_config_file,
dcc_config$synapse_asset_view)
if (dca_schematic_api == "offline") template_config_files <- setNames("www/template_config/config_offline.json",
"synXXXXXX")

## Set Up Virtual Environment
# ShinyAppys has a limit of 7000 files which this app' grossly exceeds
# due to its Python dependencies. To get around the limit we zip up
Expand Down
Loading
Loading