Skip to content

Commit

Permalink
[SYNR-1527] synapser release for version 2.1.0 (#337)
Browse files Browse the repository at this point in the history
* upgraded synapseclient version to v4.4.0
* updated R version and package dependencies
* added/extended reference documents for both new and modified functions
* updated Github action to reflect most recent compatible R versions
* resolved infinite recursion issues and package building failures on Ubuntu and Windows
* update package description and changelog
  • Loading branch information
danlu1 authored Aug 14, 2024
1 parent a58916a commit d093605
Show file tree
Hide file tree
Showing 181 changed files with 2,454 additions and 722 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# build and test synapser. Additionally deploys to S3 RAN server on GitHub release.

name: build
Expand Down Expand Up @@ -28,14 +29,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
r: [4.1.3, 4.2.3, 4.3.1]
r: [4.1.3, 4.2.3, 4.3.1, 4.4.1]

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

- name: Set up Python Version
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down Expand Up @@ -137,6 +138,10 @@ jobs:
- name: linux-build-package
if: ${{runner.os == 'linux'}}
run: |
Rscript -e "install.packages('remotes'); remotes::install_version('reticulate', version = '1.28')"
Rscript -e "reticulate::install_miniconda()"
echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
Rscript -e "reticulate::conda_create('r-reticulate', packages = c('python==3.10'))"
R CMD build ./
R CMD INSTALL ./ --library=$R_LIBS_USER --no-test-load
Expand All @@ -145,7 +150,7 @@ jobs:
- name: mac-build-package
if: ${{runner.os == 'macOS'}}
run: |
Rscript -e "install.packages(c('remotes', 'reticulate'))"
Rscript -e "install.packages('remotes'); remotes::install_version('reticulate', version = '1.28')"
Rscript -e "reticulate::install_miniconda()"
echo "options(reticulate.conda_binary = reticulate:::miniconda_conda())" >> .Rprofile
Rscript -e "reticulate::conda_create('r-reticulate', packages = c('python==3.10'))"
Expand All @@ -158,6 +163,11 @@ jobs:
if: ${{runner.os == 'Windows'}}
shell: bash
run: |
echo "options(repos = c(CRAN = 'https://cloud.r-project.org'))" >> .Rprofile
Rscript -e "install.packages('remotes'); remotes::install_version('reticulate', version = '1.28')"
Rscript -e "reticulate::install_python(version = '3.10.11')"
Rscript -e "reticulate::virtualenv_create(envname='r-reticulate',version = '3.10.11')"
Rscript -e "reticulate::use_virtualenv('r-reticulate')"
R CMD build ./
R CMD INSTALL --build ${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.gz --library=$R_LIBS_USER --no-test-load --no-multiarch
Expand Down Expand Up @@ -193,7 +203,7 @@ jobs:
echo "UPLOAD_NAME=$UPLOAD_NAME" >> $GITHUB_ENV
- name: upload-artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{env.UPLOAD_NAME}}
path: ${{env.ARTIFACT_NAME}}
Expand Down Expand Up @@ -236,7 +246,7 @@ jobs:
echo "deploy_target=$DEPLOY_TARGET" >> $GITHUB_OUTPUT
- name: download-artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
if: ${{steps.check-deployment-target.outputs.deploy_target != ''}}
with:
path: deploy_artifacts
Expand Down Expand Up @@ -278,7 +288,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-13]
r: [4.1.3, 4.2.3, 4.3.1]
r: [4.1.3, 4.2.3, 4.3.1, 4.4.1]

runs-on: ${{ matrix.os }}

Expand All @@ -290,7 +300,14 @@ jobs:
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r }}


- name: setup-r-dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache: true
cache-version: 2
architecture: 'x64'

- name: check-install
shell: bash
run: |
Expand All @@ -299,8 +316,9 @@ jobs:
PACKAGE="synapser"
echo "if (available.packages(repos='$RAN')['$PACKAGE','Version'] != '$VERSION_TO_CHECK') { quit(save = 'no', status = 1) }" > test.R
echo "try(remove.packages('$PACKAGE'), silent=T)" >> test.R
echo "install.packages('reticulate', repos=c('https://cloud.r-project.org/'))" >> test.R
echo "reticulate::virtualenv_create('r-reticulate')" >> test.R
echo "install.packages('remotes', repos = 'https://cloud.r-project.org'); remotes::install_version('reticulate', version = '1.28', repos = 'https://cloud.r-project.org')" >> test.R
echo "reticulate::install_python(version = '3.10.11')" >> test.R
echo "reticulate::virtualenv_create(envname='r-reticulate',version = '3.10.11')" >> test.R
echo "reticulate::use_virtualenv('r-reticulate')" >> test.R
echo "install.packages('$PACKAGE', repos=c('$RAN', 'https://cloud.r-project.org/'))" >> test.R
echo "library('$PACKAGE')" >> test.R
Expand Down
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
Package: synapser
Type: Package
Title: R Language Bindings for Synapse API
Version: 2.0.0
Date: 2022-01-18
Version: 2.1.0
Date: 2024-07-31
Authors@R: c(
person("Tom", "Yu", role = c("cre"), email = "[email protected]"),
person("Dan", "Lu", role = c("aut", "cre"), email = "[email protected]"),
person("Tom", "Yu", role = c("aut"), email = "[email protected]"),
person("Bruce", "Hoff", role = c("aut"), email = "[email protected]"),
person("Sage Bionetworks", role = c("cph"))
)
Maintainer: Bruce Hoff <[email protected]>
BugReports: https://github.com/Sage-Bionetworks/synapser/issues
Description: Provides R language bindings for Synapse RESTful web services.
Encoding: UTF-8
License: Apache License 2.0
Imports:
reticulate(>= 1.25),
reticulate(<= 1.28),
methods,
rjson,
stats,
utils
Depends:
R(>= 4.0)
R(>= 4.1.3),
R(< 4.5)
Remotes:
[email protected]
Suggests: pack, R6, testthat, knitr, rmarkdown
Expand Down
26 changes: 26 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
## synapser 2.1.0

### Improvements

* Upgraded to the synapsePythonClient v4.4.0.
* Now support R 4.4.1.
* The data upload and download algorithm in synapsePythonClient have been revamped for enhanced stability, reliability, and performance.
* Updated reference documents and code examples for both new and modified functions.

#### New Functions
* `synCreateTeam` and `synDeleteTeam` have been added to manage team.
* `synRestGetAsync`, `synRestDeleteAsync`, `synRestPostAsync` and `synRestPutAsync` have been added to allow interaction with Synapse server utilizing [asynchronous](https://python-docs.synapse.org/reference/oop/models_async/) models.

#### Minor behavior changes:
* Credentials passed by command line argument will now be evaluated before credentials stored in the `~/.synapseConfig` file.
* Using syn123.version notation is now supported with `synGet` and `synSetProvenance`.
* File entities will no longer have their version incremented during no-op changes. Only when file content, or fields on the file has been updated will a version number be incremented.
* New parameters have been added to allow more features:
+ Defining the project alias used in project url is now supported in `Project`.
+ Setting the annotations on the entity is now supported in `synStore`.
+ The MD5 of the file can now be used when creating S3 file handle in `synCreateExternalS3FileHandle`.


For more changes, please view the [Release Notes](https://python-docs.synapse.org/news/) on the Python client documentation.

## synapser 2.0.0

### Improvements

* Python synapsePythonClient dependency updated to 4.0.0
* You can only login via a Synapse Personal Access token now. All other forms of authentication have been disabled for security purposes.
* `rememberMe` has been deprecated in `synLogin`.
* `synSetAnnotations` removed as it is not working as expected due to implementation in the Python API.
* For more changes, please view the 3.2.0 and 4.0.0 changes on the [Python client documentation](https://python-docs.synapse.org/news/).

Expand Down
6 changes: 3 additions & 3 deletions R/table.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
df <- data.frame(
Map(.convertToRType, list = df, synapseType = types),
stringsAsFactors = F)

# The Map function mangles column names (which are in the Schema), so let's fix them
colnames(df) <- .extractColumnNames(columnSchema)
df
Expand All @@ -137,7 +137,7 @@
df <- data.frame(
Map(.convertToSynapseType, list = df, synapseType = types),
stringsAsFactors = F)

# The Map function mangles column names (which are in the Schema), so let's fix them
colnames(df) <- .extractColumnNames(columnSchema)
df
Expand Down Expand Up @@ -181,4 +181,4 @@
} else {
.saveToCsv(values, file)
}
}
}
59 changes: 30 additions & 29 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
# Ideally we would source tools/installPythonClient.R to not
# have to duplicate the synapseclient install code
# system2(paste("Rscript ", getwd(), "/tools/installPythonClient.R ", getwd(), sep=""))
PYTHON_CLIENT_VERSION <- '4.0.0'
PYTHON_CLIENT_VERSION <- '4.4.0'
# reticulate::virtualenv_create('r-reticulate')
# reticulate::use_virtualenv('r-reticulate')
reticulate::py_install(c("requests<3", "pandas~=2.0.0", "pysftp", "jinja2", "markupsafe"))
reticulate::py_install(c("pandas>=1.5,<=2.0.3", "jinja2", "markupsafe","numpy<=1.24.4"))
reticulate::py_install(c(paste("synapseclient==", PYTHON_CLIENT_VERSION, sep="")), pip=T)
reticulate::py_run_string("import synapseclient")
}
)

reticulate::py_run_string(sprintf("synapserVersion = 'synapser/%s' ", utils::packageVersion("synapser")))
reticulate::py_run_string("synapseclient.USER_AGENT['User-Agent'] = synapserVersion + ' '+ synapseclient.USER_AGENT['User-Agent']")
reticulate::py_run_string("synapseclient.core.config.single_threaded = True")
reticulate::py_run_string("syn=synapseclient.Synapse(skip_checks=True)")
reticulate::py_run_string("syn=synapseclient.Synapse(skip_checks=True, debug=False)")
# make syn available in the global environment
syn <<- reticulate::py_eval("syn")

.addPythonAndFoldersToSysPath(system.file(package = "synapser"))
.defineRPackageFunctions()
# .defineOverloadFunctions() must come AFTER .defineRPackageFunctions()
# because it redefines selected generic functions
.defineOverloadFunctions()

# mute Python warnings
reticulate::py_run_string("import warnings")
reticulate::py_run_string("warnings.filterwarnings('ignore')")
Expand All @@ -57,7 +57,6 @@
assignEnumCallback = .assignEnumCallback,
functionFilter = .synapseClassFunctionFilter,
functionPrefix = "syn",
transformReturnObject = .objectDefinitionHelper,
pySingletonName = "syn")
# exposing all supporting classes except for Synapse itself and some selected classes.
generateRWrappers(pyPkg = "synapseclient",
Expand All @@ -73,23 +72,25 @@
assignEnumCallback = .assignEnumCallback,
functionFilter = .cherryPickTableFunctionFilter,
classFilter = .removeAllClassesClassFilter,
functionPrefix = "syn",
transformReturnObject = .objectDefinitionHelper)
functionPrefix = "syn")
}

.objectDefinitionHelper <- function(object) {
if (methods::is(object, "CsvFileTable")) {
# reading from csv
# Removed due to Error in unlockBinding("asDataFrame", object) : no binding for "asDataFrame"
# unlockBinding("asDataFrame", object)
object$asDataFrame <- function() {
.readCsvBasedOnSchema(object)
}
# Removed due to Error in lockBinding("asDataFrame", object) : no binding for "asDataFrame"
# lockBinding("asDataFrame", object)
}
object
}
# TODO: This section is removed since it causes the infinite recursion
# issue when reading downloaded entity to a dataframe. Revisit this
# when deprecating PythonEmbedInR code
# .objectDefinitionHelper <- function(object) {
# if (methods::is(object, "CsvFileTable")) {
# # reading from csv
# # Removed due to Error in unlockBinding("asDataFrame", object) : no binding for "asDataFrame"
# # unlockBinding("asDataFrame", object)
# object$asDataFrame <- function() {
# .readCsvBasedOnSchema(object)
# }
# # Removed due to Error in lockBinding("asDataFrame", object) : no binding for "asDataFrame"
# # lockBinding("asDataFrame", object)
# }
# object
# }

.onAttach <- function(libname, pkgname) {
tou <- "\nTERMS OF USE NOTICE:
Expand All @@ -98,7 +99,7 @@
2) Not discriminate, identify, or recontact individuals or groups represented by the data.
3) Use and contribute only data de-identified to HIPAA standards.
4) Redistribute data only under these same terms of use.\n"

.checkForUpdate()
packageStartupMessage(tou)
}
Expand Down Expand Up @@ -128,7 +129,7 @@
Table(schema, file)
}
)

methods::setMethod(
f = "synBuildTable",
signature = c("ANY", "ANY", "data.frame"),
Expand All @@ -144,10 +145,10 @@
f = "as.data.frame",
signature = c(x = "CsvFileTable"),
definition = function(x) {
x$asDataFrame()
.readCsvBasedOnSchema(x)
}
)

methods::setClass("GeneratorWrapper")
methods::setMethod(
f = "as.list",
Expand All @@ -156,19 +157,19 @@
x$asList()
}
)

methods::setGeneric(
name = "nextElem",
def = function(x) {
standardGeneric("nextElem")
}
)

methods::setMethod(
f = "nextElem",
signature = c(x = "GeneratorWrapper"),
definition = function(x) {
x$nextElem()
}
)
}
}
3 changes: 2 additions & 1 deletion auto-man/Project-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ Projects in Synapse must be uniquely named. Trying to create a project with a na
Attributes:
name: The name of the project
alias: The project alias for use in friendly project urls.
properties: A map of Synapse properties
annotations: A map of user defined annotations
local_state: Internal use only
}
\section{Methods}{
\itemize{
\item \code{Project(name=NULL, properties=NULL, annotations=NULL, local_state=NULL)}: Constructor for \code{\link{Project}}
\item \code{Project(name=NULL, properties=NULL, annotations=NULL, local_state=NULL, alias=NULL)}: Constructor for \code{\link{Project}}
\item \code{local_state(state=NULL)}: Set or get the object's internal state, excluding properties, or annotations.\cr
\cr
Arguments:\cr
Expand Down
4 changes: 3 additions & 1 deletion auto-man/Project.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ Projects in Synapse must be uniquely named. Trying to create a project with a na
Attributes:
name: The name of the project
alias: The project alias for use in friendly project urls.
properties: A map of Synapse properties
annotations: A map of user defined annotations
local_state: Internal use only
}
\usage{
Project(name=NULL, properties=NULL, annotations=NULL, local_state=NULL)
Project(name=NULL, properties=NULL, annotations=NULL, local_state=NULL, alias=NULL)
}
\arguments{
\item{name}{}
\item{properties}{}
\item{annotations}{}
\item{local_state}{}
\item{alias}{}
}
\value{
An object of type Project
Expand Down
Loading

0 comments on commit d093605

Please sign in to comment.