Skip to content

Commit

Permalink
Add data_model_labels parameter to template config functions
Browse files Browse the repository at this point in the history
  • Loading branch information
afwillia committed Mar 4, 2024
1 parent 9360ea8 commit 8e79740
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions R/template_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ get_display_names <- function(qlist) {
}

#' @export
create_template_config <- function(data_model, include_schemas = NULL, exclude_schemas = NULL) {
create_template_config <- function(
data_model,
include_schemas = NULL,
exclude_schemas = NULL,
data_model_labels = "class_label") {

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)
edges <- graph_by_edge_type(schema_url = data_model, data_model_labels = data_model_labels)
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()
Expand All @@ -44,8 +49,13 @@ create_template_config <- function(data_model, include_schemas = NULL, exclude_s
}

#' @export
create_dca_template_config <- function(data_model, include_schemas = NULL, exclude_schemas = NULL) {
df <- create_template_config(data_model, include_schemas, exclude_schemas)
create_dca_template_config <- function(
data_model,
include_schemas = NULL,
exclude_schemas = NULL,
data_model_labels = "class_label") {

df <- create_template_config(data_model, include_schemas, exclude_schemas, data_model_labels)
schematic_version <- httr::GET("https://schematic-dev.api.sagebionetworks.org/v1/version") |>
httr::content()
list(
Expand All @@ -57,7 +67,13 @@ create_dca_template_config <- function(data_model, include_schemas = NULL, exclu

#' @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)
write_dca_template_config <- function(
data_model,
file,
include_schemas = NULL,
exclude_schemas = NULL,
data_model_labels = "class_label") {

df <- create_dca_template_config(data_model, include_schemas, exclude_schemas, data_model_labels)
jsonlite::write_json(df, file, pretty = TRUE, auto_unbox = TRUE)
}

0 comments on commit 8e79740

Please sign in to comment.