(
        rule_name, sketch_id, start_date, end_date,
        timeline_ids=None, parameters=None)
return results
Runs a task to find out if data exists in a dataset.

    Args:
        rule_name (str): A rule names to run.
        sketch_id (int): Sketch identifier.
        start_date (str): A string with an ISO formatted timestring for the
            start date of the data search.
        end_date (str): A string with an ISO formatted timestring for the
            end date of the data search.
        timeline_ids (list): An optional list of integers for the timelines
            within the the sketch to limit the data search to. If not provided
            all timelines are searched.
        parameters (dict): An optional dict with key/value pairs of parameters
            and their values, used for filling in regular expressions.

    Returns:
        A dict with the key value being the rule name used and the value
        as a tuple with two items, boolean whether data was found and a
        reason string.
Runs a task to find out if data exists in a dataset.
Runs a task to find out if data exists in a dataset .
def find_data_task(
        rule_name, sketch_id, start_date, end_date,
        timeline_ids=None, parameters=None):
    """Runs a task to find out if data exists in a dataset.

    Args:
        rule_name (str): A rule names to run.
        sketch_id (int): Sketch identifier.
        start_date (str): A string with an ISO formatted timestring for the
            start date of the data search.
        end_date (str): A string with an ISO formatted timestring for the
            end date of the data search.
        timeline_ids (list): An optional list of integers for the timelines
            within the the sketch to limit the data search to. If not provided
            all timelines are searched.
        parameters (dict): An optional dict with key/value pairs of parameters
            and their values, used for filling in regular expressions.

    Returns:
        A dict with the key value being the rule name used and the value
        as a tuple with two items, boolean whether data was found and a
        reason string.
    """
    results = {}
    data_finder_path = current_app.config.get('DATA_FINDER_PATH')
    if not data_finder_path:
        logger.error(
            'Unable to find data, missing data finder path in the '
            'configuration file.')
        return results

    if not os.path.isfile(data_finder_path):
        logger.error(
            'Unable to read data finder rules, the file does not exist, '
            'please verify that the path in DATA_FINDER_PATH variable is '
            'correct and points to a readable file.')
        return results

    data_finder_dict = {}
    with open(data_finder_path, 'r') as fh:
        try:
            data_finder_dict = yaml.safe_load(fh)
        except yaml.parser.ParserError:
            logger.error(
                'Unable to read in YAML config file', exc_info=True)
            return results

    if rule_name not in data_finder_dict:
        results[rule_name] = (False, 'Rule not defined')
        return results

    data_finder = datafinder.DataFinder()
    data_finder.set_start_date(start_date)
    data_finder.set_end_date(end_date)
    data_finder.set_parameters(parameters)
    data_finder.set_rule(data_finder_dict.get(rule_name))
    data_finder.set_timeline_ids(timeline_ids)

    sketch = Sketch.query.get(sketch_id)
    indices = set()
    for timeline in sketch.active_timelines:
        if timeline.id not in timeline_ids:
            continue
        indices.add(timeline.searchindex.index_name)

    data_finder.set_indices(list(indices))

    results[rule_name] = data_finder.find_data()
    return results
def find_data_task ( rule_name , sketch_id , start_date , end_date , timeline_ids = None , parameters = None ) : results = { } data_finder_path = current_app . config . get ( 'DATA_FINDER_PATH' ) if not data_finder_path : logger . error ( 'Unable to find data, missing data finder path in the ' 'configuration file.' ) return results if not os . path . isfile ( data_finder_path ) : logger . error ( 'Unable to read data finder rules, the file does not exist, ' 'please verify that the path in DATA_FINDER_PATH variable is ' 'correct and points to a readable file.' ) return results data_finder_dict = { } with open ( data_finder_path , 'r' ) as fh : try : data_finder_dict = yaml . safe_load ( fh ) except yaml . parser . ParserError : logger . error ( 'Unable to read in YAML config file' , exc_info = True ) return results if rule_name not in data_finder_dict : results [ rule_name ] = ( False , 'Rule not defined' ) return results data_finder = datafinder . DataFinder ( ) data_finder . set_start_date ( start_date ) data_finder . set_end_date ( end_date ) data_finder . set_parameters ( parameters ) data_finder . set_rule ( data_finder_dict . get ( rule_name ) ) data_finder . set_timeline_ids ( timeline_ids ) sketch = Sketch . query . get ( sketch_id ) indices = set ( ) for timeline in sketch . active_timelines : if timeline . id not in timeline_ids : continue indices . add ( timeline . searchindex . index_name ) data_finder . set_indices ( list ( indices ) ) results [ rule_name ] = data_finder . find_data ( ) return results