Skip to content

Commit

Permalink
Downclimb in develop (#180)
Browse files Browse the repository at this point in the history
* Revert "change people functions to synapser (#168)"

This reverts commit 4320d35.

* Update README
  • Loading branch information
anngvu authored Jul 17, 2024
1 parent 4320d35 commit 7a31fba
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-13, r: 'release'}
- {os: windows-2022, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
Expand All @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -40,18 +40,9 @@ jobs:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
id: install-deps
continue-on-error: true
with:
extra-packages: any::rcmdcheck
needs: check

- name: If source build fails on macOS or Windows, fall back to typical install
if: steps.install-deps.outcome == 'failure'
shell: Rscript {0}
run: |
reticulate::install_miniconda()
install.packages("synapser", repos="http://ran.synapse.org")

- uses: r-lib/actions/check-r-package@v2
with:
Expand Down
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ Imports:
emoji,
plyr,
readxl,
yaml,
synapser (>= 1.0.0)
yaml
URL: https://github.com/nf-osi/nfportalutils
BugReports: https://github.com/nf-osi/nfportalutils/issues
Suggests:
Expand All @@ -51,5 +50,3 @@ Suggests:
withr
Config/testthat/edition: 2
VignetteBuilder: knitr
Remotes:
github::Sage-Bionetworks/synapser
16 changes: 16 additions & 0 deletions R/add_publication_from_unpaywall.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,20 @@ add_publication_from_unpaywall <- function(publication_table_id,
}
}}

#' Adds a row to a table.
#' @param schema A synapse table Schema object.
#' @param new_row A data frame of one or more rows that match the provided schema.
#' @export
.store_rows <- function(schema, new_row){

table <- .syn$store(synapseclient$Table(schema, new_row))

}

# .pluck_column_type_and_name <- function(column){
# coltype <- purrr::pluck(column, "columnType")
# name <- purrr::pluck(column, "name")
#
# c(coltype, name)
# }

18 changes: 0 additions & 18 deletions R/basic_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,3 @@ walk <- function(syn_id, as_list = TRUE) {

}


#' Adds a row to a table.
#' @param schema A synapse table Schema object.
#' @param new_row A data frame of one or more rows that match the provided schema.
#' @export
.store_rows <- function(schema, new_row){

table <- synapser::synStore(synapser::Table(schema, new_row))

}

# .pluck_column_type_and_name <- function(column){
# coltype <- purrr::pluck(column, "columnType")
# name <- purrr::pluck(column, "name")
#
# c(coltype, name)
# }

10 changes: 6 additions & 4 deletions R/login.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Logs into Synapse.
#'
#'
#' Wrapper around https://python-docs.synapse.org/build/html/index.html#synapseclient.Synapse.login
#' Username and password authentication is not supported.
#' Recommendation is to store `SYNAPSE_AUTH_TOKEN` in environment, so login can be used simply as `syn_login()`.
#'
#'
#' @param authtoken Uses `SYNAPSE_AUTH_TOKEN` environmental variable, or a personal access token (PAT) can be provided.
#' @examples
#' \dontrun{
Expand All @@ -22,7 +22,9 @@ syn_login <- function(authtoken = Sys.getenv("SYNAPSE_AUTH_TOKEN")){
#' @returns A message.
#' @keywords internal
.check_login <- function(){
if(!exists(".syn") & !exists("syn")){
stop('Please run `nfportalutils::syn_login()` or `synapser::synLogin()` prior to running functions that require a connection to Synapse. (Alternatively, the Python `synapseclient` is unavailable.)')
if(!exists(".syn")){
stop('Please run `nfportalutils::syn_login()` prior to running functions that require a connection to Synapse. (Alternatively, the Python `synapseclient` is unavailable.)')
}else if(capture.output(.syn) == "<pointer: 0x0>"){
stop('Please run `nfportalutils::syn_login()` prior to running functions that require a connection to Synapse. (Alternatively, the Python `synapseclient` is unavailable.)')
}
}
12 changes: 5 additions & 7 deletions R/update_people_table.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Update the People table from a source Table or View column
#'
#'
#' @param people_table_id The synapse id of the table used for referencing people.
#' @param people_column Column name within the people table that contains the relevant people values.
#' @param people_column Column name within the people table that contains the relevant people values.
#' @param source_table_id The synapse id of the source table.
#' @param source_column Column name within the source table that contains the relevant source values.
#' @inheritParams update_study_annotations
Expand All @@ -15,17 +15,15 @@ add_people_from_table <- function(people_table_id, people_column, source_table_i
#get current people ids
old_people_query <- glue::glue("select {people_column} from {people_table_id}")

old_people <- synapser::synTableQuery(old_people_query, includeRowIdAndRowVersion = F)$asDataFrame() %>%
tibble::as_tibble() %>%
old_people <- .syn$tableQuery(old_people_query)$asDataFrame() %>%
dplyr::distinct()

old_ids <- old_people[[{{people_column}}]]

#get ids from new source table
new_people_query <- glue::glue("select {source_column} from {source_table_id}")

new_people <- synapser::synTableQuery(new_people_query, includeRowIdAndRowVersion = F)$asDataFrame() %>%
tibble::as_tibble() %>%
new_people <- .syn$tableQuery(new_people_query)$asDataFrame() %>%
dplyr::distinct() %>%
dplyr::filter(!(!!rlang::sym(source_column)) %in% old_ids) %>% #filter out existing ids
purrr::pluck(source_column)
Expand All @@ -34,7 +32,7 @@ add_people_from_table <- function(people_table_id, people_column, source_table_i

new_rows <- tibble::tibble(!!people_column := new_people)

schema <- synapser::synGet(people_table_id)
schema <- .syn$get(people_table_id)

if(dry_run == F){
.store_rows(schema, new_rows)
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ You can install `nfportalutils` from here:
remotes::install_github("nf-osi/nfportalutils")
```

The package interops with the [Python synapse client](https://github.com/Sage-Bionetworks/synapsePythonClient) via reticulate.
You will have to download the Python synapse client first.


## Additional Notes for Users
## For Users

- View function reference on docs site at [Reference](https://nf-osi.github.io/nfportalutils/reference/index.html).
- An alternative to viewing vignettes as Articles on the [docs site](https://nf-osi.github.io/nfportalutils/index.html) is to download them with pkg install and load with e.g. `vignette("annotate-nf-processed-data", package = "nfportalutils")` to view.

## Additional Notes for Contributors
## For Contributors

### General picture
- Again, default development happens in `develop`.
- But we have a side branch called `develop-synapser` where interop tries to transition to `synapser`.
However, current coexistence makes development a bit tricky so consult first before trying new developments there.

### Contrib workflow
- Branch of `develop` and make changes
Expand Down
2 changes: 1 addition & 1 deletion man/dot-store_rows.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a31fba

Please sign in to comment.