Internal R6 Object Only for Setting up Inheritance
BaseEx.Rd
A R6 object that provides a common set of methods to 1) store the metadata of data in the db, and 2) export parquet files for python to import. Not meant to be called manually.
Public fields
hash
(
character()
)
hash of the object byrlang::hash()
.pin_name
(
character()
)
pin_name of the file in the project folder.df
(
data.frame()
)
the df for the hyper param grid or the transformed df.con
(
DBI::dbConnect()
)
aDBI::dbConnect()
object, generated byrpwf_connect_db()
.export_query
(
glue::glue_sql()
)
SQL query to upload metadata of the data into the db.queried_pin_name
(
glue::glue_sql()
)
Queried pin_name of the object.board
(
character()
)
a{pins}
board object.dbname
name of the database.
seed
random seed.
Methods
Method new()
This class is the parent of RGrid and TrainDf R6 object, not meant to be called.
Usage
BaseEx$new(db_con)
Arguments
db_con
(
DbCon
)
aDbCon
object, generated byrpwf_connect_db()
.
Method exec_query()
Run the query that check if the object exists in the db by checking the hash of the object in the db. Either find one unique row or no row.
Arguments
query
(
glue::glue_sql()
)
SQL query for either the hyper parameter grid or the transformed df.
Method set_pin_name()
Change the pin_name where the object is stored. Is NA only when no grid is provided. Have to provide a train data.
Arguments
val
(
character()
)
Path to store the object on disk.
Method find_pin_name_in_db()
Store the results of the query from the db in a data.frame. Query have to
return a df (so nrow()
works) with 0 <= nrow()
< 2.
Arguments
val
(
data.frame()
)
New data frame generated byself$exec_query
.
Method set_export_query()
Change the SQL query to export metadata to database.
Arguments
val
(
glue::glue_sql()
)
New SQL query to export metadata.
Method set_df()
If the hash of the new object is not found in the database, then new
data is prepared. If the data is found in the metadata but not in the
indicated pin_name then new data is also prepared. Otherwise, self$df
is
NULL and will be skipped by the BaseEx::self$export_parquet()
method.
Arguments
val
(
data.frame()
)
Either arecipes::juice()
object or a data.frame of the hyper param grid.
Method export_prep()
If the db query found no existing metadata, then an export pin_name is made. If the metadata is found but the associated data is not found, then an export pin_name is also made. Else get the pin_name from the metadata in the db.
Arguments
new_pin_name
(
character()
)
Path to the object.new_export_query
(
glue::glue_sql()
)
SQL query to export the obj metadata to the db.
Method export_db()
If the self$export_query
is generated because metadata is not found in
the database, then export the metadata to the db using this query.
Otherwise return NULL.
Method export_parquet()
If the file specified by self$pin_name
is not found, then export the file
as a parquet file to the location specified in the metadata.