Clarify synapser's namespace

Description

This is related to as well as this PR: https://github.com/Sage-Bionetworks/synapser/pull/147

synapser uses several functions from external packages without either importing them into the synapser namespace or referencing the package with packagename::. PythonEmbedInR is imported in the NAMESPACE file, but other functions we use like methods::setGeneric() and utils:ackageVersion() are not. In the case of setGeneric(), we modify the user's global environment to ensure the function is defined there rather than calling it from the package it originates from.

This causes R CMD check to complain, and can also cause subtle bugs downstream. Specifically, if synapser is loaded but not attached by other code, then packages in Depends will also be loaded but not attached. When a package is loaded its .onLoad() function is run, which will cause a reoccurrence of because methods will not be attached. An example can be seen by running Rscript -e "requireNamespace('synapser')". The section on Imports in the R packages book (http://r-pkgs.had.co.nz/namespace.html#Imports) has more detail on this.

I'd recommend either adding importFrom(methods, setGeneric) (etc. for all functions from we use from external packages) to NAMESPACE, or prefixing each call to an external function with packagename::. The latter is generally preferable, though has a (usually negligible) performance cost.

Environment

None

Status

Assignee

Kimyen Truong

Reporter

Kara Woo

Labels

None

Validator

Kara Woo

Release Version History

None

Fix versions

Priority

Minor
Configure