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

[SYNR-1527] synapser release for version 2.1.0 #337

Merged
merged 16 commits into from
Aug 14, 2024
20 changes: 15 additions & 5 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 @@ -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 Down
10 changes: 6 additions & 4 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("Bruce", "Hoff", role = c("aut"), email = "[email protected]"),
danlu1 marked this conversation as resolved.
Show resolved Hide resolved
person("Sage Bionetworks", role = c("cph"))
)
Maintainer: Bruce Hoff <bruce.hoff@sageabse.org>
Maintainer: Dan Lu <dan.lu@sageabse.org>
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
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## synapser 2.1.0

### Improvements

* Upgraded to the synapsePythonClient v4.4.0.
* 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.
* `rememberMe` has been deprecated in `synLogin`.
danlu1 marked this conversation as resolved.
Show resolved Hide resolved
* 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
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
4 changes: 3 additions & 1 deletion auto-man/synCreateExternalS3FileHandle.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ Arguments:
storage_location_id: Explicit storage location id to create the file handle in, mutually exclusive
with parent
mimetype: Mimetype of the file, if known
md5: MD5 of the file, if known

Raises:
ValueError: If neither parent nor storage_location_id is specified, or if both are specified.
}
\usage{
synCreateExternalS3FileHandle(bucket_name, s3_file_key, file_path, parent=NULL, storage_location_id=NULL, mimetype=NULL)
synCreateExternalS3FileHandle(bucket_name, s3_file_key, file_path, parent=NULL, storage_location_id=NULL, mimetype=NULL, md5=NULL)
}
\arguments{
\item{bucket_name}{}
Expand All @@ -37,6 +38,7 @@ synCreateExternalS3FileHandle(bucket_name, s3_file_key, file_path, parent=NULL,
\item{parent}{}
\item{storage_location_id}{}
\item{mimetype}{}
\item{md5}{}
}
\value{

Expand Down
39 changes: 39 additions & 0 deletions auto-man/synCreateTeam.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
%
% Auto-generated file, do not modify.
% Instead, copy this file to the man/ folder, remove this warning, and edit freely.
% Use Git to identify changes in this file which suggest where to change your edited copy.
%
\name{synCreateTeam}
\alias{synCreateTeam}
\docType{methods}
\title{
synCreateTeam
}
\description{
Creates a new team.

Arguments:
name: The name of the team to create.
description: A description of the team.
icon: The FileHandleID of the icon to be used for the team.
canPublicJoin: Whether the team can be joined by anyone. Defaults to False.
canRequestMembership: Whether the team can request membership. Defaults to True.

Returns:
An object of type [synapseclient.team.Team][]
}
\usage{
synCreateTeam(name, description=NULL, icon=NULL, can_public_join=FALSE, can_request_membership=TRUE)
}
\arguments{
\item{name}{}
\item{description}{}
\item{icon}{}
\item{can_public_join}{}
\item{can_request_membership}{}
}
\value{

}


Loading
Loading