Title: | Resource Resolver |
---|---|
Description: | A resource represents some data or a computation unit. It is described by a URL and credentials. This package proposes a Resource model with "resolver" and "client" classes to facilitate the access and the usage of the resources. |
Authors: | Yannick Marcon [aut, cre] |
Maintainer: | Yannick Marcon <[email protected]> |
License: | LGPL (>= 2.1) |
Version: | 1.5.0 |
Built: | 2025-02-14 03:11:03 UTC |
Source: | https://github.com/obiba/resourcer |
Attempt to coerce a resource object to a data.frame: find a ResourceResolver and get the ResourceClient that will connect to the described dataset and make a data.frame of it.
## S3 method for class 'resource' as.data.frame(x, ...)
## S3 method for class 'resource' as.data.frame(x, ...)
x |
a resource object. |
... |
additional parameters, that may be used (or ignored) by the resource client. |
a data.frame (or a tibble)
Attempt to coerce a resource object to a data.frame: find a ResourceResolver and get the ResourceClient that will connect to the described dataset and make a data.frame of it.
## S3 method for class 'ResourceClient' as.data.frame(x, ...)
## S3 method for class 'ResourceClient' as.data.frame(x, ...)
x |
a ResourceClient object |
... |
additional parameters, that may be used (or ignored) by the resource client. |
a data.frame (or a tibble)
Coerce a ResourceClient object to a data.frame.
as.resource.data.frame(x, strict = FALSE, ...)
as.resource.data.frame(x, strict = FALSE, ...)
x |
The ResourceClient object to coerce to a data.frame. |
strict |
logical whether the resulting object must be strictly of class data.frame or if it can be a tibble. |
... |
Additional parameters, that may be used (or ignored) by the resource client. |
a data.frame (or a tibble)
Coerce a ResourceClient object to internal data object: depending on the implementation of the ResourceClient, it can be a data connection object (like a DBI connection to a SQL database), or the actual data structure (when a resource is a R object extracted from a R data file for instance).
as.resource.object(x, ...)
as.resource.object(x, ...)
x |
The ResourceClient object to coerce to a data.frame. |
... |
Additional parameters, that may be used (or ignored) by the resource client. |
the internal data object.
Coerce a ResourceClient object to a dplyr's tbl.
as.resource.tbl(x, ...)
as.resource.tbl(x, ...)
x |
The ResourceClient object to coerce to a data.frame |
... |
Additional parameters, that may be used (or ignored) by the resource client. |
a dplyr's tbl
Command resource client
Command resource client
A R6 object of class CommandResourceClient
Base class for resource clients issuing commands and get a result with the status of the execution, the output and the error messages.
resourcer::ResourceClient
-> CommandResourceClient
new()
Creates a new CommandResourceClient instance
CommandResourceClient$new(resource)
resource
A valid resource object.
A CommandResourceClient object.
clone()
The objects of this class are cloneable with this method.
CommandResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
DBI resource connector
DBI resource connector
A R6 object of class DBIResourceConnector
Makes a DBI connection from a resource description, used in SQLResourceClient that is based on DBI.
new()
Creates a new DBIResourceConnector instance
DBIResourceConnector$new()
A DBIResourceConnector object.
isFor()
Check that the provided parameter is of class "resource".
DBIResourceConnector$isFor(resource)
resource
The resource object to validate.
A logical.
createDBIConnection()
Stub function which subclasses will implement to create a DBI connection object from a resource.
DBIResourceConnector$createDBIConnection(resource)
resource
A valid resource object.
getTableName()
Get the SQL table name from the resource URL.
DBIResourceConnector$getTableName(resource)
resource
A valid resource object.
The SQL table name.
readDBTable()
Read a table as a vanilla tibble using DBI connection object.
DBIResourceConnector$readDBTable(conn, resource)
conn
A DBI connection object.
resource
A valid resource object.
A vanilla tibble.
readDBTibble()
Read a table as a SQL tibble using DBI connection object.
DBIResourceConnector$readDBTibble(conn, resource)
conn
A DBI connection object.
resource
A valid resource object.
A SQL tibble.
closeDBIConnection()
Disconnect the DBI connection.
DBIResourceConnector$closeDBIConnection(conn)
conn
A DBI connection object.
clone()
The objects of this class are cloneable with this method.
DBIResourceConnector$clone(deep = FALSE)
deep
Whether to make a deep clone.
File resource client
File resource client
A R6 object of class FileResourceClient
Base class that connects to a file using a FileResourceGetter.
resourcer::ResourceClient
-> FileResourceClient
new()
Creates a new FileResourceClient instance.
FileResourceClient$new(resource, file.getter = NULL)
resource
A valid resource object.
file.getter
A FileResourceGetter object, optional. If not provided, it will be looked up in the FileResourceGetters registry. The operation will fail if none can be found.
A FileResourceClient object.
downloadFile()
Performs the file download, if it does not already exists locally.
FileResourceClient$downloadFile()
The local path to the downloaded file.
close()
Removes the file if it was downloaded. A local file resource will remain untouched.
FileResourceClient$close()
clone()
The objects of this class are cloneable with this method.
FileResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
File resource getter
File resource getter
A R6 object of class FileResourceGetter
Helper base class for getting the file described by the resource object. ResourceClient class implementations can use this utility to retrieve files from any locations before processing them according to the declared data format.
new()
Creates a new FileResourceGetter instance.
FileResourceGetter$new()
A FileResourceGetter object.
isFor()
Check that the provided parameter is of class "resource" and has a format defined.
FileResourceGetter$isFor(resource)
resource
The resource object to validate.
A logical.
downloadFile()
Stub function which subclasses will implement to make a "resource.file" object from a resource.
FileResourceGetter$downloadFile(resource, ...)
resource
A valid resource object.
...
Additional parameters that may be relevant for FileResourceGetter subclasses.
A "resource.file" object.
extractFileName()
Utility to get the base name from the file path.
FileResourceGetter$extractFileName(resource)
resource
A valid resource object.
The file base name.
makeDownloadDir()
Creates a directory where to download file in the R session's temporary directory. This directory will be flushed when the R session ends.
FileResourceGetter$makeDownloadDir()
The path to the download directory.
clone()
The objects of this class are cloneable with this method.
FileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
Find the DBI resource connector that will download the DBI from the provided resource object.
findDBIResourceConnector(x)
findDBIResourceConnector(x)
x |
The resource object which corresponding DBI connector is to be found. |
The corresponding DBIResourceConnector object or NULL if none applies.
Find the file resource getter that will download the file from the provided resource object.
findFileResourceGetter(x)
findFileResourceGetter(x)
x |
The resource object which corresponding file getter is to be found. |
The corresponding FileResourceGetter object or NULL if none applies.
Get the DBIResourceConnector
s registry, create it if it does not exist.
getDBIResourceConnectors()
getDBIResourceConnectors()
Get the FileResourceGetter
s registry, create it if it does not exist.
getFileResourceGetters()
getFileResourceGetters()
Get the resource resolvers registry, create it if it does not exist.
getResourceResolvers()
getResourceResolvers()
{ resourcer::getResourceResolvers() }
{ resourcer::getResourceResolvers() }
GridFS file resource getter
GridFS file resource getter
A R6 object of class GridFsFileResourceGetter
Access a file that is in the MongoDB file store (GridFS). Credentials may apply.
resourcer::FileResourceGetter
-> GridFsFileResourceGetter
new()
Creates a new GridFsFileResourceGetter instance.
GridFsFileResourceGetter$new()
A GridFsFileResourceGetter object.
isFor()
Check that the provided resource has a URL that locates a GridFS object: either the URL scheme is "gridfs" or it is "mongodb"/"mongodb+srv" with a query parameter "prefix=fs" (that identifies GridFS collection names).
GridFsFileResourceGetter$isFor(resource)
resource
The resource object to validate.
A logical.
downloadFile()
Download the file from the MongoDB file store in a temporary location.
GridFsFileResourceGetter$downloadFile(resource, ...)
resource
A valid resource object.
...
Unused additional parameters.
The "resource.file" object.
clone()
The objects of this class are cloneable with this method.
GridFsFileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
HTTP file resource getter
HTTP file resource getter
A R6 object of class HttpFileResourceGetter
Access a file that is stored at a HTTP(S) address. Use Basic authentication header if both resource's identity and secret are defined.
resourcer::FileResourceGetter
-> HttpFileResourceGetter
new()
Creates a new HttpFileResourceGetter instance.
HttpFileResourceGetter$new()
A HttpFileResourceGetter object.
isFor()
Check that the provided resource has a URL that locates a file accessible through "http" or "https".
HttpFileResourceGetter$isFor(resource)
resource
The resource object to validate.
A logical.
downloadFile()
Download the file from the remote address in a temporary location. Applies Basic authentication if credentials are provided in the resource.
HttpFileResourceGetter$downloadFile(resource, ...)
resource
A valid resource object.
...
Unused additional parameters.
The "resource.file" object.
clone()
The objects of this class are cloneable with this method.
HttpFileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
Local file resource getter
Local file resource getter
A R6 object of class LocalFileResourceGetter
Access a file that is stored in the local file system. No credentials apply.
resourcer::FileResourceGetter
-> LocalFileResourceGetter
new()
Creates a new LocalFileResourceGetter instance.
LocalFileResourceGetter$new()
A LocalFileResourceGetter object.
isFor()
Check that the provided resource has a URL that locates a file stored in the local file system.
LocalFileResourceGetter$isFor(resource)
resource
The resource object to validate.
A logical.
downloadFile()
Make a "resource.file" object from a local file resource.
LocalFileResourceGetter$downloadFile(resource, ...)
resource
A valid resource object.
...
Unused additional parameters.
The "resource.file" object.
clone()
The objects of this class are cloneable with this method.
LocalFileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
MariaDB DBI resource connector
MariaDB DBI resource connector
A R6 object of class MariaDBResourceConnector
Makes a MariaDB/MySQL DBI connection from a resource description.
resourcer::DBIResourceConnector
-> MariaDBResourceConnector
new()
Creates a new MariaDBResourceConnector instance.
MariaDBResourceConnector$new()
A MariaDBResourceConnector object.
isFor()
Check that the provided resource has a URL that locates a MySQL or MariaDB object: the URL scheme must be "mysql" or "mariadb".
MariaDBResourceConnector$isFor(resource)
resource
The resource object to validate.
A logical.
createDBIConnection()
Creates a DBI connection object from a resource.
MariaDBResourceConnector$createDBIConnection(resource)
resource
A valid resource object.
A DBI connection object.
clone()
The objects of this class are cloneable with this method.
MariaDBResourceConnector$clone(deep = FALSE)
deep
Whether to make a deep clone.
Creates a new Resource structure.
newResource(name = "", url, identity = NULL, secret = NULL, format = NULL)
newResource(name = "", url, identity = NULL, secret = NULL, format = NULL)
name |
Otpional human friendly name that identifies the resource. |
url |
URL to access the resource whether it is data or computation capability. |
identity |
User name or account ID (if credentials are applicable). |
secret |
User password or token (if credentials are applicable). |
format |
Data format, to help resource resolver identification and coercing to other formats, optional. |
{ # make a SPSS file resource res <- resourcer::newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) }
{ # make a SPSS file resource res <- resourcer::newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) }
From a resource object, find the corresponding resolver in the resolver registry and create a new resource client.
newResourceClient(x)
newResourceClient(x)
x |
The resource object which corresponding resolver is to be found. |
The corresponding ResourceClient object or NULL if none applies.
library(resourcer) res <- newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) client <- newResourceClient(res)
library(resourcer) res <- newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) client <- newResourceClient(res)
NoSQL database resource client
NoSQL database resource client
A R6 object of class NoSQLResourceClient
Resource client that connects to a NoSQL database supported by nodbi.
resourcer::ResourceClient
-> NoSQLResourceClient
new()
Creates a new NoSQLResourceClient instance.
NoSQLResourceClient$new(resource)
resource
A valid resource object.
A NoSQLResourceClient object.
getConnection()
Creates the nodbi connection object if it does not exist.
NoSQLResourceClient$getConnection()
The nodbi connection object.
asDataFrame()
Makes a data.frame from the remote database table.
NoSQLResourceClient$asDataFrame()
A tibble.
getDatabaseName()
Extract the database name from the resource URL.
NoSQLResourceClient$getDatabaseName()
The database name.
getTableName()
Extract the database table name from the resource URL.
NoSQLResourceClient$getTableName()
The database table name.
close()
Close the nodbi connection.
NoSQLResourceClient$close()
clone()
The objects of this class are cloneable with this method.
NoSQLResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
NoSQL Database Resource resolver
NoSQL Database Resource resolver
A R6 object of class NoSQLResourceResolver
The resource is NoSQL database such as mongodb (elasticsearch, redis, couchdb, sqlite are not supported yet).
resourcer::ResourceResolver
-> NoSQLResourceResolver
isFor()
Check that the provided resource has a URL that locates a nodbi object: the URL scheme must be one of "mongodb", "mongodb+srv". Other NoSQL databases "elasticsearch", "redis", "couchdb", "sqlite" are not supported yet.
NoSQLResourceResolver$isFor(x)
x
The resource object to validate.
A logical.
newClient()
Creates a NoSQLResourceClient instance from provided resource.
NoSQLResourceResolver$newClient(x)
x
A valid resource object.
A NoSQLResourceClient object.
clone()
The objects of this class are cloneable with this method.
NoSQLResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
Opal file resource getter
Opal file resource getter
A R6 object of class OpalFileResourceGetter
Access a file that is stored in a Opal server. Use Basic authentication header if both resource's identity and secret are defined, token authentication if secret only is defined.
resourcer::FileResourceGetter
-> OpalFileResourceGetter
new()
Creates a new OpalFileResourceGetter instance.
OpalFileResourceGetter$new()
A OpalFileResourceGetter object.
isFor()
Check that the provided resource has a URL that locates a Opal file: the URL scheme must be "opal+http" or "opal+https" and the path must designate a file web service entry point (i.e. starts with "ws/files/").
OpalFileResourceGetter$isFor(resource)
resource
The resource object to validate.
A logical.
downloadFile()
Download the file from the Opal file system in a temporary location.
OpalFileResourceGetter$downloadFile(resource, ...)
resource
A valid resource object.
...
Unused additional parameters.
The "resource.file" object.
clone()
The objects of this class are cloneable with this method.
OpalFileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
Postgres DBI resource connector
Postgres DBI resource connector
A R6 object of class PostgresResourceConnector
Makes a Postgres DBI connection from a resource description.
resourcer::DBIResourceConnector
-> PostgresResourceConnector
new()
Creates a new PostgresResourceConnector instance.
PostgresResourceConnector$new()
A PostgresResourceConnector object.
isFor()
Check that the provided resource has a URL that locates a Postgres object: the URL scheme must be "postgres" or "postgresql".
PostgresResourceConnector$isFor(resource)
resource
The resource object to validate.
A logical.
createDBIConnection()
Creates a DBI connection object from a resource.
PostgresResourceConnector$createDBIConnection(resource)
resource
A valid resource object.
A DBI connection object.
clone()
The objects of this class are cloneable with this method.
PostgresResourceConnector$clone(deep = FALSE)
deep
Whether to make a deep clone.
Presto DBI resource connector
Presto DBI resource connector
A R6 object of class PrestoResourceConnector
Makes a Presto DBI connection from a resource description.
resourcer::DBIResourceConnector
-> PrestoResourceConnector
new()
Creates a new PrestoResourceConnector instance.
PrestoResourceConnector$new()
A PrestoResourceConnector object.
isFor()
Check that the provided resource has a URL that locates a Presto object: the URL scheme must be "presto", "presto+http" or "presto+https".
PrestoResourceConnector$isFor(resource)
resource
The resource object to validate.
A logical.
createDBIConnection()
Creates a DBI connection object from a resource.
PrestoResourceConnector$createDBIConnection(resource)
resource
A valid resource object.
A DBI connection object.
clone()
The objects of this class are cloneable with this method.
PrestoResourceConnector$clone(deep = FALSE)
deep
Whether to make a deep clone.
R data file resource client
R data file resource client
A R6 object of class RDSFileResourceClient
Connects to a R data file and loads it in a controlled environment.
resourcer::ResourceClient
-> resourcer::FileResourceClient
-> RDataFileResourceClient
new()
Creates a new RDataFileResourceClient instance.
RDataFileResourceClient$new(resource)
resource
A valid resource object.
A RDataFileResourceClient object.
asDataFrame()
Coerce the resource value extracted from the R data file to a data.frame.
RDataFileResourceClient$asDataFrame(...)
...
Additional parameters to as.data.frame (not used yet).
A data.frame.
getValue()
Get the resource value extracted from the R data file.
RDataFileResourceClient$getValue(...)
...
Additional parameters to get the value object (not used yet).
The resource value.
clone()
The objects of this class are cloneable with this method.
RDataFileResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
R data file Resource resolver
R data file Resource resolver
A R6 object of class RDataFileResourceResolver
The resource is a R data file and data format is the class of the symbol that will be loaded.
resourcer::ResourceResolver
-> RDataFileResourceResolver
isFor()
Check that the provided resource has a URL that locates a R data file: the resource can be accessed as a file and the resource URL path ends with ".rda" or ".rdata" (case ignored), or the resource format is prefixed with "r:" or "rda:" (a kind of namespace to qualify the R object class).
RDataFileResourceResolver$isFor(x)
x
The resource object to validate.
A logical.
newClient()
Creates a RDataFileResourceClient instance from provided resource.
RDataFileResourceResolver$newClient(x)
x
A valid resource object.
A RDataFileResourceClient object.
clone()
The objects of this class are cloneable with this method.
RDataFileResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
R object file resource client
R object file resource client
A R6 object of class RDSFileResourceClient
Connects to a RDS file and loads the serialized object. Similar to the R data file resource, except that the RDS format stores a single R object.
resourcer::ResourceClient
-> resourcer::FileResourceClient
-> RDSFileResourceClient
new()
Creates a new RDSFileResourceClient instance.
RDSFileResourceClient$new(resource)
resource
A valid resource object.
A RDSFileResourceClient object.
asDataFrame()
Coerce the resource value extracted from the R object file to a data.frame.
RDSFileResourceClient$asDataFrame(...)
...
Additional parameters to as.data.frame (not used yet).
A data.frame.
getValue()
Get the resource value extracted from the R object file.
RDSFileResourceClient$getValue(...)
...
Additional parameters to get the value object (not used yet).
The resource value.
clone()
The objects of this class are cloneable with this method.
RDSFileResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
R object file Resource resolver
R object file Resource resolver
A R6 object of class RDSFileResourceResolver
The resource is a RDS file.
resourcer::ResourceResolver
-> RDSFileResourceResolver
isFor()
Check that the provided resource has a URL that locates a R object file: the resource can be accessed as a file and the resource URL path ends with ".rds" (case ignored), or the resource format is prefixed with "rds:" (a kind of namespace to qualify the R object class).
RDSFileResourceResolver$isFor(x)
x
The resource object to validate.
A logical.
newClient()
Creates a RDSFileResourceClient instance from provided resource.
RDSFileResourceResolver$newClient(x)
x
A valid resource object.
A RDSFileResourceClient object.
clone()
The objects of this class are cloneable with this method.
RDSFileResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
Maintain an list of DBIResourceConnector
s that will be called when a new
DBI resource connector is to be found.
registerDBIResourceConnector(x)
registerDBIResourceConnector(x)
x |
The DBI resource connector object to register. |
Maintain an list of FileResourceGetter
s that will be called when a new
file resource getter is to be found.
registerFileResourceGetter(x)
registerFileResourceGetter(x)
x |
The file resource getter object to register. |
Maintain an list of resource resolvers that will be called when a new resource is to be resolved.
registerResourceResolver(x)
registerResourceResolver(x)
x |
The resource resolver object to register. |
## Not run: resourcer::registerResourceResolver(MyFileFormatResourceResolver$new()) ## End(Not run)
## Not run: resourcer::registerResourceResolver(MyFileFormatResourceResolver$new()) ## End(Not run)
Find the resolver that will make a client from the provided resource object.
resolveResource(x)
resolveResource(x)
x |
The resource object which corresponding resolver is to be found. |
The corresponding ResourceResolver object or NULL if none applies.
library(resourcer) res <- newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) resolver <- resolveResource(res)
library(resourcer) res <- newResource( name = "CNSIM1", url = "file:///data/CNSIM1.sav", format = "spss" ) resolver <- resolveResource(res)
Resource client
Resource client
A R6 object of class ResourceClient
Helper class for connecting to a resource data store or a computation unit.
new()
Creates a ResourceClient instance.
ResourceClient$new(resource)
resource
The resource object to be interprated.
A ResourceClient object.
getResource()
Get the resource object.
ResourceClient$getResource()
The resource object.
getConnection()
Get the implementation-specific object that connects to the resource
ResourceClient$getConnection()
The connection object.
downloadFile()
Stub function to be implemented by subclasses if relevant. Get the resource as a local file.
ResourceClient$downloadFile(...)
...
Additional parameters.
The path to the local file.
asDataFrame()
Stub function to be implemented by subclasses if relevant. Coerce the resource as a data.frame.
ResourceClient$asDataFrame(...)
...
Additional parameters.
A data.frame object (can also be a tibble).
asTbl()
Stub function to be implemented by subclasses if relevant. Coerce the resource as a dplyr's tbl.
ResourceClient$asTbl(...)
...
Additional parameters.
A dplyr's tbl object.
exec()
Stub function to be implemented by subclasses if relevant. Executes a command on a computation resource.
ResourceClient$exec(...)
...
Additional parameters that will represent the command to execute.
A command execution result object.
close()
Silently closes the connection to the resource
ResourceClient$close()
clone()
The objects of this class are cloneable with this method.
ResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
Resource resolver
Resource resolver
A R6 object of class ResourceResolver
Helper class for building a Client that implements the access to the data or the computation unit.
new()
Creates a new ResourceResolver instance.
ResourceResolver$new()
A ResourceResolver object.
isFor()
Check that the provided object is of class "resource".
ResourceResolver$isFor(x)
x
The resource object to evaluate.
A logical.
newClient()
Stub function to be implemented by subclasses. Makes an object which class inherits from ResourceClient.
ResourceResolver$newClient(x)
x
The resource object to evaluate.
The ResourceClient object that will access the provided resource.
clone()
The objects of this class are cloneable with this method.
ResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
SCP file resource getter
SCP file resource getter
A R6 object of class ScpFileResourceGetter
Access a file that is stored on a server accessible through SSH. Credentials apply.
resourcer::FileResourceGetter
-> ScpFileResourceGetter
new()
Creates a ScpFileResourceGetter instance.
ScpFileResourceGetter$new()
The ScpFileResourceGetter object.
isFor()
Check that the provided resource is a file accessible by SCP: the resource URL scheme must be "scp".
ScpFileResourceGetter$isFor(resource)
resource
The resource object to evaluate.
A logical.
downloadFile()
Download the file described by the resource over an SSH connection.
ScpFileResourceGetter$downloadFile(resource, ...)
resource
The resource that identifies the file.
...
Additional parameters (not used).
The "resource.file" object.
clone()
The objects of this class are cloneable with this method.
ScpFileResourceGetter$clone(deep = FALSE)
deep
Whether to make a deep clone.
Shell resource client
Shell resource client
A R6 object of class ShellResourceClient
Executes local system shell commands.
resourcer::ResourceClient
-> resourcer::CommandResourceClient
-> ShellResourceClient
new()
Create a ShellResourceClient instance. This client will interact wtih a computation resource using shell commands.
ShellResourceClient$new(resource)
resource
The computation resource.
The ShellResourceClient object.
getAllowedCommands()
Get the command names that can be executed.
ShellResourceClient$getAllowedCommands()
A character vector
copyFile()
Copy one or more files (wilcard * is supported in the file name (which can be a directory))
ShellResourceClient$copyFile(file, to = ".", verbose = FALSE)
file
The file to copy.
to
The copy destination.
verbose
If TRUE, details the file operations on the console output.
The path to the files having been copied.
exec()
Executes a shell command in the working directory specified in the resource's URL.
ShellResourceClient$exec(command, params = NULL, test = FALSE)
command
The command name.
params
A character vector of arguments to pass.
test
If TRUE, the command is printed but not executed (for debugging).
The command execution result object.
clone()
The objects of this class are cloneable with this method.
ShellResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
Shell Resource resolver
Shell Resource resolver
A R6 object of class ShellResourceResolver
The resource is a computation unit, accessible by issuing local system commands, i.e. which URL scheme is "sh".
resourcer::ResourceResolver
-> ShellResourceResolver
isFor()
Check that the provided resource is a computation resource accessible by shell commands. The resource URL scheme must be "sh" or "shell".
ShellResourceResolver$isFor(x)
x
The resource object.
A logical.
newClient()
Create a ShellResourceClient instance from the provided resource.
ShellResourceResolver$newClient(x)
x
A valid resource object.
A ShellResourceClient object.
clone()
The objects of this class are cloneable with this method.
ShellResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
Apache Spark DBI resource connector
Apache Spark DBI resource connector
A R6 object of class SparkResourceConnector
Makes a Apache Spark connection object, that is also a DBI connection object, from a resource description.
resourcer::DBIResourceConnector
-> SparkResourceConnector
new()
Create a SparkResourceConnector instance.
SparkResourceConnector$new()
A SparkResourceConnector object.
isFor()
Check if the provided resource applies to a Apache Spark server. The resource URL scheme must be one of "spark", "spark+http" or "spark+https".
SparkResourceConnector$isFor(resource)
resource
The resource object to validate.
A logical.
createDBIConnection()
Creates a DBI connection object from a Apache Spark resource.
SparkResourceConnector$createDBIConnection(resource)
resource
A valid resource object.
A DBI connection object.
closeDBIConnection()
Close the DBI connection to Apache Spark.
SparkResourceConnector$closeDBIConnection(conn)
conn
A DBI connection object.
clone()
The objects of this class are cloneable with this method.
SparkResourceConnector$clone(deep = FALSE)
deep
Whether to make a deep clone.
SQL database resource client
SQL database resource client
A R6 object of class SQLResourceClient
Resource client that connects to a SQL database supported by DBI.
resourcer::ResourceClient
-> SQLResourceClient
new()
Creates a SQLResourceClient from a resource.
SQLResourceClient$new(resource, dbi.connector = NULL)
resource
The resource object.
dbi.connector
An optional DBIResourceConnector object. If not provided, it will be looked up in the DBIResourceConnector registry.
The SQLResourceClient object.
getConnection()
Get or create the DBI connection object that will access the resource.
SQLResourceClient$getConnection()
The DBI connection object.
asDataFrame()
Coerce the SQL table to a data.frame.
SQLResourceClient$asDataFrame(...)
...
Additional parameters (not used).
A data.frame (more specifically a tibble).
asTbl()
Get the SQL table as a dplyr's tbl.
SQLResourceClient$asTbl()
A dplyr's tbl object.
close()
Silently close the DBI connection.
SQLResourceClient$close()
clone()
The objects of this class are cloneable with this method.
SQLResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
SQL Database Resource resolver
SQL Database Resource resolver
A R6 object of class SQLResourceResolver
The resource is SQL database.
resourcer::ResourceResolver
-> SQLResourceResolver
isFor()
Check that the provided resource has a registered DBIResourceConnector.
SQLResourceResolver$isFor(x)
x
The resource object to evaluate.
A logical.
newClient()
Creates a SQLResourceClient instance from provided resource.
SQLResourceResolver$newClient(x)
x
A valid resource object.
A SQLResourceClient object.
clone()
The objects of this class are cloneable with this method.
SQLResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
SSH resource client
SSH resource client
A R6 object of class SshResourceClient
Connects to a SSH server.
resourcer::ResourceClient
-> resourcer::CommandResourceClient
-> SshResourceClient
new()
Create a SshResourceClient instance. This client will interact wtih a computation resource using ssh commands.
SshResourceClient$new(resource)
resource
The computation resource.
The SshResourceClient object.
getAllowedCommands()
Get the command names that can be executed.
SshResourceClient$getAllowedCommands()
A character vector
getConnection()
Get or create the SSH connection object, for raw interaction.
SshResourceClient$getConnection()
The SSH connection object.
downloadFile()
Download one or more files (wilcard * is supported in the file name (which can be a directory))
SshResourceClient$downloadFile(file, to = ".", verbose = FALSE)
file
The file path(s) to download, either absolute or relative to the working directory.
to
The download destination.
verbose
If TRUE, details the file operations on the console output.
The paths of the files having been downloaded.
uploadFile()
Upload one or more files
SshResourceClient$uploadFile(file, to = ".", verbose = FALSE)
file
The file or vector of files to upload.
to
The upload destination, either absolute or relative to working directory.
verbose
If TRUE, details the file operations on the console output.
The paths of the files having been uploaded.
tempDir()
Get connection's temporary directory in the remote server, create it if it does not exists.
SshResourceClient$tempDir()
The path to the temporary directory.
removeTempDir()
Remove the connection's temporary directory from the remote server, if it was defined.
SshResourceClient$removeTempDir()
exec()
Executes a ssh command.
SshResourceClient$exec(command, params = NULL, test = FALSE)
command
The command name.
params
A character vector of arguments to pass.
test
If TRUE, the command is printed but not executed (for debugging).
The command execution result object.
close()
Close the SSH connection.
SshResourceClient$close()
clone()
The objects of this class are cloneable with this method.
SshResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
SSH Resource resolver
SSH Resource resolver
A R6 object of class SshResourceResolver
The resource is a computation unit, accessible through SSH, i.e. which URL scheme is "ssh".
resourcer::ResourceResolver
-> SshResourceResolver
isFor()
Check that the provided resource is a computation resource accessible by ssh commands. The resource URL scheme is expected to be "ssh".
SshResourceResolver$isFor(x)
x
The resource object.
A logical.
newClient()
Create a SshResourceClient instance from the provided resource.
SshResourceResolver$newClient(x)
x
A valid resource object.
A SshResourceClient object.
clone()
The objects of this class are cloneable with this method.
SshResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
Tidy file resource client
Tidy file resource client
A R6 object of class TidyFileResourceClient
Connects to a file and use one of the tidyverse reader.
resourcer::ResourceClient
-> resourcer::FileResourceClient
-> TidyFileResourceClient
new()
Create a TidyFileResourceClient instance.
TidyFileResourceClient$new(resource)
resource
A valid resource object.
A TidyFileResourceClient object.
asDataFrame()
Coerce the resource value extracted from the file in tidy format to a data.frame.
TidyFileResourceClient$asDataFrame(...)
...
Additional parameters to as.data.frame (not used yet).
A data.frame (more specifically a tibble).
clone()
The objects of this class are cloneable with this method.
TidyFileResourceClient$clone(deep = FALSE)
deep
Whether to make a deep clone.
Tidy file Resource resolver
Tidy file Resource resolver
A R6 object of class TidyFileResourceResolver
The resource is a file and data format is handled by a reader from tidyverse. The data format is one of: csv (comma delimiter), csv2 (semicolon delimiter), tsv (tab delimiter), ssv (space delimiter), delim (delim parameter to be specified in the URL, default is space char), spss, sav, por, stata, dta, sas, xpt, excel, xls, xlsx.
$new()
Create new TidyFileResourceResolver instance.
$isFor(x)
Get a logical that indicates that the resolver is applicable to the provided resource object.
$newClient()
Make a client for the provided resource.
resourcer::ResourceResolver
-> TidyFileResourceResolver
isFor()
Check that the provided resource has a URL that locates a tidy data file: the resource can be accessed as a file and the resource format is one of "csv", "csv2", "tsv", "delim", "ssv", "spss", "sav", "por", "stata", "dta", "sas", "xpt", "excel", "xls" or "xlsx" (case is ignored).
TidyFileResourceResolver$isFor(x)
x
The resource object to validate.
A logical.
newClient()
Creates a TidyFileResourceClient instance from provided resource.
TidyFileResourceResolver$newClient(x)
x
A valid resource object.
A TidyFileResourceClient object.
clone()
The objects of this class are cloneable with this method.
TidyFileResourceResolver$clone(deep = FALSE)
deep
Whether to make a deep clone.
Remove any DBI resource connectors with the provided class name.
unregisterDBIResourceConnector(x)
unregisterDBIResourceConnector(x)
x |
The DBI resource connector class name to unregister. |
Remove any file resource getters with the provided class name.
unregisterFileResourceGetter(x)
unregisterFileResourceGetter(x)
x |
The file resource getter class name to unregister. |
Remove any resolvers with the provided class name.
unregisterResourceResolver(x)
unregisterResourceResolver(x)
x |
The resource resolver class name to unregister. |
## Not run: resourcer::unregisterResourceResolver("MyFileFormatResourceResolver") ## End(Not run)
## Not run: resourcer::unregisterResourceResolver("MyFileFormatResourceResolver") ## End(Not run)