Code Integration: Operations and Scenarios
R Convenience Functions
codeObj <- Code(name, parent, localRoot)
parameters
name
parent: a Project ID
localRoot: local 'root' directory for code files. If omitted a default is used.
side effects
none
returns
new Code object
addFile(codeObj, localPath)
parameters
codeObj
localPath: path to file or directory on machine running the R session
side effects
none
returns
nothing
storeEntity(codeObj)
parameters
codeObj
side effects
zips files and pushes them to S3. The file path stored is relative to the 'localRoot' in the code object.
Creates or updates metadata in Synapse, including S3 location.
returns
nothing
downloadEntity(codeId, localRoot)
parameters
codeId: id of metadata object in Synapse
localRoot: local 'root' directory for code files. If omitted a default is used.
side effects
Downloads code files to directory(ies) under the 'local root'
returns
Code object
loadEntity(codeObj)
parameters
codeObj
side effects
If (codeId!=null)
- Get current Step.
- Adds reference to Synapse Code object into Step.
'sources' code into memory
(i.e. if 'codeObj' is just a local variable, this is a utility to source a collection of files.)
returns
codeObj
deleteEntity(codeId)
parameters
codeId: ID of the object in Synapse
side effects
Delete metadata from Synapse.
Deletes files from S3.
returns
Nothing.
Scenarios
The development cycle for preexisting code: The code is Downloaded from Synapse, and Loaded into the R session. The user repeatedly Runs, Edits and reLoads the code. When satisfied, she may Store the code back to Synapse. To help capture provenance, the Load and Store functions put the Code's ID and version into the current Step. For the provenance record to be accurate, the user must Store prior to running.
Discover, retrieve, load and run code
A user, browsing Synapse, sees a piece of code of interest (mentioned in a discussion or used in an analysis), and clicks on it. She sees:
entity.3733 <- downloadEntity(3733)
and begins by executing this in R.