Run linters in parallel and sort all results.

        Args:
            targets (list): List of files and folders to lint.
357296
def lint(self, targets):
        
        LinterRunner.targets = targets
        linters = self._config.get_linter_classes()
        with Pool() as pool:
            out_err_none = pool.map(LinterRunner.run, linters)
        out_err = [item for item in out_err_none if item is not None]
        stdout, stderr = zip(*out_err)
        return sorted(chain.from_iterable(stdout)), chain.from_iterable(stderr)
872305
def build(self, targets: Iterable[str]) -> Iterable[str]:
        
        return generate_source_directories(
            targets, build=self._build, prompt=self._prompt
        )
440236
def compute_targets_to_build(self, targets: Iterable[str]) -> Iterable[BuildTarget]:
        
        normalized_targets = set()
        for target in targets:
            normalized_targets.update(self._normalize_target(target))

        targets_to_parse = deque(normalized_targets)
        targets_seen = set(normalized_targets)
        targets_not_found = []
        build_targets = set()

        while targets_to_parse:
            next_target_string = targets_to_parse.popleft()
            next_target = self._parse_target(next_target_string)
            build_file = self.parser.parse_file(next_target.build_file_directory)
            if next_target.name not in build_file.targets:
                targets_not_found.append(next_target_string)
                continue
            target_to_build = build_file.targets[next_target.name]
            build_targets.add(target_to_build)

            new_targets = [
                dependency
                for dependency in target_to_build.dependencies
                if dependency not in targets_seen
            ]
            targets_to_parse.extend(new_targets)
            targets_seen.update(new_targets)

        if targets_not_found and self.fail_on_unbuilt_target:
            raise BuilderException(
                "Target(s) could not be built: {}".format(", ".join(targets_not_found)),
                targets=targets_not_found,
            )
        return build_targets
463305
private static void printTargetPathList(FileStatus[] targetTmpFiles)
    {
        StringBuilder builder = new StringBuilder();
        builder.append("Preprocess target files:");
        String lineSeparator = System.getProperty("line.separator");

        for (FileStatus targetFile : targetTmpFiles)
        {
            builder.append(targetFile.getPath() + lineSeparator);
        }

        logger.info(builder.toString());
    }
287334
def run(self, files, working_area):
        

        # Ensure that dictionary is ordered by check declaration order (via self.check_names)
        # NOTE: Requires CPython 3.6. If we need to support older versions of Python, replace with OrderedDict.
        results = {name: None for name in self.check_names}
        checks_root = working_area.parent
        with futures.ProcessPoolExecutor() as executor:

            # Start all checks that have no dependencies
            not_done = set(executor.submit(run_check(name, self.checks_spec, checks_root))
                           for name, _ in self.child_map[None])
            not_passed = []

            while not_done:
                done, not_done = futures.wait(not_done, return_when=futures.FIRST_COMPLETED)
                for future in done:
                    # Get result from completed check
                    result, state = future.result()
                    results[result.name] = result
                    if result.passed:
                        # Dispatch dependent checks
                        for child_name, _ in self.child_map[result.name]:
                            not_done.add(executor.submit(
                                run_check(child_name, self.checks_spec, checks_root, state)))
                    else:
                        not_passed.append(result.name)

        for name in not_passed:
            self._skip_children(name, results)

        return results.values()
234405
def Run(self, args):
    """"""
    try:
      directory = vfs.VFSOpen(args.pathspec, progress_callback=self.Progress)
    except (IOError, OSError) as e:
      self.SetStatus(rdf_flows.GrrStatus.ReturnedStatus.IOERROR, e)
      return

    files = list(directory.ListFiles())
    files.sort(key=lambda x: x.pathspec.path)

    for response in files:
      self.SendReply(response)
179845
def compute_writer_results(results):
    
    if not results:
        return

    sources, targets, delayeds = split_results(results)

    # one or more writers have targets that we need to close in the future
    if targets:
        delayeds.append(da.store(sources, targets, compute=False))

    if delayeds:
        da.compute(delayeds)

    if targets:
        for target in targets:
            if hasattr(target, 'close'):
                target.close()
400242
def run(self):
        '''  '''

        # find hosts that match the pattern
        hosts = self.inventory.list_hosts(self.pattern)
        if len(hosts) == 0:
            self.callbacks.on_no_hosts()
            return dict(contacted={}, dark={})

        global multiprocessing_runner
        multiprocessing_runner = self
        results = None

        # Check if this is an action plugin. Some of them are designed
        # to be ran once per group of hosts. Example module: pause,
        # run once per hostgroup, rather than pausing once per each
        # host.
        p = utils.plugins.action_loader.get(self.module_name, self)
        if p and getattr(p, 'BYPASS_HOST_LOOP', None):
            # Expose the current hostgroup to the bypassing plugins
            self.host_set = hosts
            # We aren't iterating over all the hosts in this
            # group. So, just pick the first host in our group to
            # construct the conn object with.
            result_data = self._executor(hosts[0]).result
            # Create a ResultData item for each host in this group
            # using the returned result. If we didn't do this we would
            # get false reports of dark hosts.
            results = [ ReturnData(host=h, result=result_data, comm_ok=True) \
                           for h in hosts ]
            del self.host_set
        elif self.forks > 1:
            try:
                results = self._parallel_exec(hosts)
            except IOError, ie:
                print ie.errno
                if ie.errno == 32:
                    # broken pipe from Ctrl+C
                    raise errors.AnsibleError("interupted")
                raise
        else:
            results = [ self._executor(h) for h in hosts ]
        return self._partition_results(results)
699804
def run(self, target, args=()):
        
        run_event = threading.Event()
        run_event.set()
        thread = threading.Thread(target=target, args=args + (run_event, ))
        self.thread_pool.append(thread)
        self.run_events.append(run_event)
        thread.start()
942203
def invoke(self, dirname, filenames=set(), linter_configs=set()):
        
        retval = defaultdict(lambda: defaultdict(list))
        if len(filenames):
            extensions = [e.lstrip('.') for e in self.get_file_extensions()]
            filenames = [f for f in filenames if f.split('.')[-1] in extensions]

            if not filenames:
                # There were a specified set of files, but none were the right
                # extension. Different from the else-case below.
                return {}

            to_find = ' -o '.join(['-samefile "%s"' % f for f in filenames])
        else:
            to_find = ' -o '.join(['-name "*%s"' % ext
                                   for ext in self.get_file_extensions()])

        cmd = 'find %s -path "*/%s" | xargs %s' % (
            dirname, to_find, self.get_command(
                dirname,
                linter_configs=linter_configs))
        result = self.executor(cmd)
        for line in result.split('\n'):
            output = self.process_line(dirname, line)
            if output is not None:
                filename, lineno, messages = output
                if filename.startswith(dirname):
                    filename = filename[len(dirname) + 1:]
                retval[filename][lineno].append(messages)
        return retval
760776
def collect_cached_objects(self, versioned_target):
    
    return ObjectFiles(versioned_target.results_dir, os.listdir(versioned_target.results_dir))
467267
static Set<PathMatcher> createPathMatcherSet(final String[] targets) {
        return Arrays.stream(targets)
                .map(inclusion -> FileSystems.getDefault().getPathMatcher("glob:" + inclusion))
                .collect(Collectors.toSet());
    }
253871
def _parallel_exec(self, hosts):
        '''  '''
        if not hosts:
            return
        p = multiprocessing.Pool(self.forks)
        results = []
        #results = p.map(multiprocessing_runner, hosts) # can't handle keyboard interrupt
        results = p.map_async(multiprocessing_runner, hosts).get(9999999)
        p.close()
        p.join()
        return results
171856
def get_for_targets(self, targets):
    
    products = OrderedSet()
    for target in targets:
      products.update(self._products_by_target[target])
    return products
123803
def run_all():
    
    DATA_DIR = "/home/annaho/TheCannon/code/apogee_lamost/xcalib_4labels"
    dates = os.listdir("/home/share/LAMOST/DR2/DR2_release")
    dates = np.array(dates)
    dates = np.delete(dates, np.where(dates=='.directory')[0][0])
    dates = np.delete(dates, np.where(dates=='all_folders.list')[0][0])
    dates = np.delete(dates, np.where(dates=='dr2.lis')[0][0])

    for date in dates:
        if glob.glob("*%s*.txt" %date):
            print("%s done" %date)
        else:
            print("running %s" %date)
            run_one_date(date)
1078617
public static void sort(final List<Artifact> targets) {
        int n = targets.size();
        while(n != 0){
            int newn = 0;

            for(int i = 1 ; i <= n-1 ; i++){
                if (targets.get(i-1).toString().compareTo(targets.get(i).toString()) > 0){
                    Collections.swap(targets, i - 1, i);
                    newn = i;
                }
            }

            n = newn;
        }
    }
721278
def all(self, paths, access=None, recursion=False):
        
        self.__init__()
        self.access = access
        self.filetype = 'all'
        self.paths = paths
        self.recursion = recursion

        return _sorter(self._generator_other())