main-api: Primary high-level API functions for Trackr Databases

Description Usage Arguments Details Examples

Description

These functions define the high-level, user-facing trackr API.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
record(
  object,
  db = defaultTDB(),
  resultURI = "",
  code = histry::histry_tracker(),
  force = FALSE,
  verbose = FALSE,
  symorpos = NULL,
  dryrun = FALSE
)

rmRecord(object, db = defaultTDB(), verbose = FALSE)

findRecords(
  pattern,
  db = defaultTDB(),
  fields = NULL,
  ret_type = c("doclist", "id", "backend"),
  verbose = FALSE
)

recordFiles(
  object,
  ingestfun = NULL,
  db = defaultTDB(),
  resultURI = "",
  code = histry_tracker(),
  force = FALSE,
  verbose = FALSE,
  symorpos = NULL,
  dryrun = FALSE
)

Arguments

object

ANY. An object to record. Or (for recordFiles) a vector of one or more files to record or the path of a single directory whose contents will be recorded. Or (for rmPlot) the unique ID of an object in the database to remove.

db

TrackrDB. The database

resultURI

A URI which can be used to define a grouping/hierarchy of results recorded via trackr. Currently unused by trackr itself except as additional metadata to search across. Defaults to an empty string.

code

ANY. Code/evaluation history to be associated with object

force

logical. Overwrite any existing entry matching object. (default: FALSE)

verbose

logical. Should extra informative messages be displayed ( default: FALSE)

symorpos

The symbol or position corresponding to object in code. For normal usage this will not be required.

dryrun

logical. Should a "dry run" be performed. If true, the insert_record and trackr_write steps of the record process are not run, and the result of prep_for_backend is immediately returned.

pattern

character. A regular expression to match against the text in fields

fields

character or NULL. The fiends in which to match, or NULL to include all fields.

ret_type

character. Format in which to return the response. Options are: "id" - id of matching documents (default), "list" - A list containing the matching documents represnted as R lists, and "backend" - a backend specific representation of the set of matching documents

ingestfun

function or NULL. A function which must accept only the paths argument which will take object and return an R object to be recorded and linked to the raw files indicated by object

Details

These functions allow end-users to interact with trackr databases. Each function does what its name suggests.

When more than one file is passed to recordFiles,either via a vector of paths or the path to a directory, the files will be zipped up into a single file which will be recorded.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
prevtdb = defaultTDB()
defaultTDB(listTDB(img_dir = tempdir()))
mt = datasets::mtcars
record(mt)

res = findRecords("mtcars")
stopifnot(length(res) ==1)
rmRecord(mt)

res = findRecords("mtcars")
stopifnot(length(res) == 0)

## Not run: 
f = function(paths) readLines(paths)
fil = system.file("test_docs", "knitr_test.Rmd", package = "trackr")
recordFiles(fil, ingestfun = f)

res= findRecords("test_docs")

## End(Not run)
defaultTDB(prevtdb)

trackr documentation built on May 24, 2021, 5:09 p.m.