LGApplication-class: Application which serves as a backend for LuckyGuess...

Description Methods

Description

Application which serves as a backend for LuckyGuess component

Methods

checkParam(data, name, dataType, fullName)

Recursive function to check a parameter provided in JSON data. Note that this function is called for each parameter (name) separately and it tries to find that name in the provided data. It will return the data possibly with coerced values.

Parameters

  • data JSON parsed data.

  • name Name of the parameter, either a string or a vector of characters if the parameter is nested.

  • dataType String name of the R data type required.

  • fullName Arbitrary named used for global identification of the parameter.

Return Value

List with partially modified data.

getCleanData(types, cleanData)

Apply column types detected by LG to a data frame.

Parameters

  • types Data frame with contents of table with LG datatypes (this table is usually named VAI__1 in SAPI).

  • cleanData A data frame with actual data, its columns are expected to be listed as rows in the types table.

Return Value

data.frame supplied in cleanData parameter with applied data types.

getConvertedDataType(type, mode)

Convert LG type definition to an R data type.

Parameters

  • type LG data type string (integer, datetime, etc.).

  • mode LG variable mode (continuous, discrete).

Return Value

String with R data type name

initialize(args = NULL)

Constructor.

Parameters

  • args Optional name of data directory, if not supplied then it will be read from command line argument or environment KBC_DATADIR.

Return Value

Response body - either list or string in case the body cannot be parsed as JSON.

installModulePackages(packages = c())

Install and load all required libraries.

Parameters

  • packages Vector of package names.

Return Value

TRUE

run()

Main application function, this should be overriden in child class.

Return Value

NULL

saveDataFrame(dataFrame, tableName, rowNumbers = FALSE, incremental = FALSE, forcedColumnTypes)

Save a dataframe to database using bulk inserts. The table will be created to accomodate to data frame columns.

Parameters

  • dataFrame A data frame, column names of data frame must correspond to column names of table.

  • tableName Name of the table.

  • rowNumbers If true then the table will contain a column named row_num with sequential row index.

  • incremental If true then the table will not be recreated, only data will be inserted.

Return Value

TRUE

saveFileName(name, tags)

Save reference to a file.

Parameters

  • name String physical file path.

  • tags Character vector of file tags.

Return Value

TRUE

saveFiles()

Save uploaded files (move them to out directory and create manifests)

Return Value

TRUE

saveValue(name, value, grouping = 0)

Save an arbitrary simple value.

Parameters

  • key String key name.

  • value Arbitrary value.

  • grouping Optional grouping of values if they are related.

Return Value

TRUE

silence(command)

Silence all but error output from a command. Note: this function does nothing if the debugMode variable is set to TRUE.

Parameters

  • command Arbitrary command.

Return Value

Command return value.

startUp()

Start up the Application, initialize working directory and database tables.

Return Value

TRUE

validate()

Save uploaded files (move them to out directory and create manifests)

Return Value

TRUE


keboola/r-luckyguess documentation built on May 20, 2019, 8:34 a.m.