'Run the import task.'

def run(self):

    self.logger.info(u'import    started    {0}', time.asctime())
    self.set_config(config['import'])
    if (self.query is None):
        stages = [read_tasks(self)]
    else:
        stages = [query_tasks(self)]
    if self.config['pretend']:
        stages += [log_files(self)]
    else:
        if (self.config['group_albums'] and (not self.config['singletons'])):
            stages += [group_albums(self)]
        if self.config['autotag']:
            stages += [lookup_candidates(self), user_query(self)]
        else:
            stages += [import_asis(self)]
        for stage_func in plugins.import_stages():
            stages.append(plugin_stage(self, stage_func))
        stages += [manipulate_files(self)]
    pl = pipeline.Pipeline(stages)
    plugins.send('import_begin', session=self)
    try:
        if config['threaded']:
            pl.run_parallel(QUEUE_SIZE)
        else:
            pl.run_sequential()
    except ImportAbort:
        pass
