R: Add or Remove Job Tags

Tags {batchtools} | R Documentation

## Add or Remove Job Tags

### Description

Add and remove arbitrary tags to jobs.

### Usage

    addJobTags(ids = NULL, tags, reg = getDefaultRegistry())

    removeJobTags(ids = NULL, tags, reg = getDefaultRegistry())

    getUsedJobTags(ids = NULL, reg = getDefaultRegistry())

### Arguments

`ids` | [`data.frame` or `integer`] A `data.frame` (or `data.table`) with a column named “job.id”. Alternatively, you may also pass a vector of integerish job ids. If not set, defaults to all jobs. Invalid ids are ignored.
`tags` | [`character`] Tags to add or remove as strings. Each tag may consist of letters, numbers, underscore and dots (pattern “^[[:alnum:]_.]+”).
`reg` | [`Registry`] Registry. If not explicitly passed, uses the default registry (see `setDefaultRegistry`).

### Value

[`data.table`] with job ids affected (invisible).

### Examples

    tmp = makeRegistry(file.dir = NA, make.default = FALSE)
    ids = batchMap(sqrt, x = -3:3, reg = tmp)

    # Add new tag to all ids
    addJobTags(ids, "needs.computation", reg = tmp)
    getJobTags(reg = tmp)

    # Add more tags
    addJobTags(findJobs(x < 0, reg = tmp), "x.neg", reg = tmp)
    addJobTags(findJobs(x > 0, reg = tmp), "x.pos", reg = tmp)
    getJobTags(reg = tmp)

    # Submit first 5 jobs and remove tag if successful
    ids = submitJobs(1:5, reg = tmp)
    if (waitForJobs(reg = tmp))
      removeJobTags(ids, "needs.computation", reg = tmp)
    getJobTags(reg = tmp)

    # Grep for warning message and add a tag
    addJobTags(grepLogs(pattern = "NaNs produced", reg = tmp), "div.zero", reg = tmp)
    getJobTags(reg = tmp)

    # All tags where tag x.neg is set:
    ids = findTagged("x.neg", reg = tmp)
    getUsedJobTags(ids, reg = tmp)

[Package batchtools version 0.9.11 Index]