class DatabaseRunner(Runner): """ Runner class that uses the database to discover percepts for evaluation :param algorithm: algorithm to run against each percept :type algorithm: :py:class:`~rigor.algorithm.Algorithm` :param config: configuration data :type config: :py:class:`~rigor.config.RigorConfiguration` :param str database_name: name of the database to use :param dict parameters: settings for the Runner :param file checkpoint: open :py:class:`~rigor.checkpoint.Checkpoint` file to resume from """ def __init__(self, algorithm, config, database_name, parameters=None, checkpoint=None): Runner.__init__(self, algorithm, parameters, checkpoint) self._config = config self._database = Database(database_name, config) self._perceptops = PerceptOps(config) def fetch_data(self, percept): """ Gets percept data from the repository :param percept: The percept corresponding to data to fetch :return: Percept data encapsulated in a :py:func:`~contextlib.contextmanager` """ return self._perceptops.fetch(percept)
def test_fetch(): ops = PerceptOps(kConfig) def read(locator, credentials): return (locator, credentials) ops.read = read percept = Percept() percept.locator = constants.kExampleTextFile result = ops.fetch(percept) assert result == (percept.locator, None)