Skip to content

Commit

Permalink
Merge pull request #588 from Sage-Bionetworks/FDS-1402-schematic-disp…
Browse files Browse the repository at this point in the history
…lay-name

Fds 1402 schematic display name
  • Loading branch information
afwillia authored Feb 28, 2024
2 parents 8478a21 + a2789ab commit dac61ba
Show file tree
Hide file tree
Showing 5 changed files with 709 additions and 556 deletions.
30 changes: 0 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,6 @@ repos:
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
- id: spell-check
exclude: >
(?x)^(
.*\.[rR]|
.*\.feather|
.*\.jpeg|
.*\.pdf|
.*\.png|
.*\.py|
.*\.RData|
.*\.rds|
.*\.Rds|
.*\.Rproj|
.*\.sh|
(.*/|)\.gitignore|
(.*/|)\.gitlab-ci\.yml|
(.*/|)\.lintr|
(.*/|)\.pre-commit-.*|
(.*/|)\.Rbuildignore|
(.*/|)\.Renviron|
(.*/|)\.Rprofile|
(.*/|)\.travis\.yml|
(.*/|)appveyor\.yml|
(.*/|)NAMESPACE|
(.*/|)renv/settings\.dcf|
(.*/|)renv\.lock|
(.*/|)WORDLIST|
\.github/workflows/.*|
data/.*|
)$
- id: lintr
- id: readme-rmd-rendered
- id: parsable-R
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ License: file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Imports: httr, dplyr, jsonlite
Imports: httr, dplyr, jsonlite, shinyjs, yaml, promises, readr
Suggests:
covr
80 changes: 57 additions & 23 deletions R/schematic_rest_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ manifest_download <- function(url = "http://localhost:3001/v1/manifest/download"
#' @returns a URL to a google sheet
#' @export
manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate",
schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #nolint
title, data_type,
use_annotations="false", dataset_id=NULL,
asset_view, output_format, access_token = NULL,
strict_validation = FALSE) {
schema_url,
title,
data_type,
use_annotations="false",
dataset_id=NULL,
asset_view,
output_format,
access_token = NULL,
strict_validation = FALSE,
data_model_labels = "class_label") {

req <- httr::GET(url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
Expand All @@ -70,7 +75,8 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate",
dataset_id=dataset_id,
asset_view=asset_view,
output_format=output_format,
strict_validation = strict_validation
strict_validation = strict_validation,
data_model_labels = data_model_labels
))

check_success(req)
Expand All @@ -87,15 +93,20 @@ manifest_generate <- function(url="http://localhost:3001/v1/manifest/generate",
#' @param csv_file Filepath of csv to validate
#' @export
manifest_populate <- function(url="http://localhost:3001/v1/manifest/populate",
schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #notlint
data_type, title, return_excel=FALSE, csv_file) {
schema_url,
data_type,
title,
return_excel=FALSE,
data_model_labels = "class_label",
csv_file) {

req <- httr::POST(url,
query=list(
schema_url=schema_url,
data_type=data_type,
title=title,
return_excel=return_excel),
return_excel=return_excel,
data_model_labels=data_model_labels),
body=list(csv_file=httr::upload_file(csv_file, type = "text/csv"))
)
check_success(req)
Expand All @@ -114,9 +125,14 @@ manifest_populate <- function(url="http://localhost:3001/v1/manifest/populate",
#' @returns An empty list() if sucessfully validated. Or a list of errors.
#' @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, project_scope = NULL,
access_token, asset_view = NULL) {
schema_url,
data_type,
file_name,
restrict_rules=FALSE,
project_scope = NULL,
access_token,
asset_view = NULL,
data_model_labels = "class_label") {

flattenbody <- function(x) {
# A form/query can only have one value per name, so take
Expand Down Expand Up @@ -144,7 +160,8 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate",
data_type=data_type,
restrict_rules=restrict_rules,
project_scope = project_scope,
asset_view = asset_view)),
asset_view = asset_view,
data_model_labels = data_model_labels)),
body=list(file_name=httr::upload_file(file_name))
)

Expand Down Expand Up @@ -180,10 +197,20 @@ manifest_validate <- function(url="http://localhost:3001/v1/model/validate",
#' @returns TRUE if successful upload or validate errors if not.
#' @export
model_submit <- function(url="http://localhost:3001/v1/model/submit",
schema_url="https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld", #notlint
data_type, dataset_id, restrict_rules=FALSE, access_token, json_str=NULL, asset_view,
use_schema_label=TRUE, manifest_record_type="table_and_file", file_name,
table_manipulation="replace", hide_blanks=FALSE) {
schema_url,
data_type,
dataset_id,
restrict_rules=FALSE,
access_token,
json_str=NULL,
asset_view,
manifest_record_type="table_and_file",
file_name,
table_manipulation="replace",
hide_blanks=FALSE,
table_column_names="class_label",
annotation_keys="class_label",
data_model_labels="class_label") {
req <- httr::POST(url,
httr::add_headers(Authorization = sprintf("Bearer %s", access_token)),
query=list(
Expand All @@ -193,9 +220,10 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit",
restrict_rules=restrict_rules,
json_str=json_str,
asset_view=asset_view,
use_schema_label=use_schema_label,
manifest_record_type=manifest_record_type,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
hide_blanks=hide_blanks),
body=list(file_name=httr::upload_file(file_name))
#body=list(file_name=file_name)
Expand All @@ -215,14 +243,17 @@ model_submit <- function(url="http://localhost:3001/v1/model/submit",
#' @returns A list of required components associated with the source component.
#' @export
model_component_requirements <- function(url="http://localhost:3001/v1/model/component-requirements",
schema_url, source_component,
as_graph = FALSE) {
schema_url,
source_component,
as_graph = FALSE,
data_model_labels = "class_label") {

req <- httr::GET(url,
query = list(
schema_url = schema_url,
source_component = source_component,
as_graph = as_graph
as_graph = as_graph,
data_model_labels = data_model_labels
))

check_success(req)
Expand Down Expand Up @@ -344,11 +375,14 @@ get_asset_view_table <- function(url="http://localhost:3001/v1/storage/assets/ta
#' @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") {
schema_url,
relationship = "requiresDependency",
data_model_labels = "class_label") {
req <- httr::GET(url = url,
query = list(
schema_url = schema_url,
relationship = relationship
relationship = relationship,
data_model_labels = data_model_labels
))
httr::content(req)
}
Loading

0 comments on commit dac61ba

Please sign in to comment.