Ejemplo n.º 1
0
    def _run(self):
        """
        Run method for this module
        """

        if self.arg_options.random_output_dir:
            import scripts.yamlc as yamlc
            from core.base import System
            yamlc.TEST_RESULTS = 'test_results-{}'.format(System.rnd8)

        self.all_yamls = list()
        for path in self.others:
            if not Paths.exists(path):
                Printer.all.err('given path does not exists, ignoring path "{}"', path)
                sys.exit(3)

            # append files to all_yamls
            if Paths.is_dir(path):
                self.all_yamls.extend(Paths.walk(path, ConfigPool.yaml_filters))
            else:
                self.all_yamls.append(path)

        Printer.all.out("Found {} yaml file/s", len(self.all_yamls))
        if not self.all_yamls:
            Printer.all.wrn('No yaml files found in locations: \n  {}', '\n  '.join(self.others))
            sys.exit(0)

        self.configs = self.read_configs(self.all_yamls)
        self.configs.update(
            proc=self.arg_options.cpu,
            time_limit=self.arg_options.time_limit,
            memory_limit=self.arg_options.memory_limit,
        )

        # filter tags for includes and excludes
        self.configs.filter_tags(
            include=self.include,
            exclude=self.exclude
        )

        if self.arg_options.queue:
            Printer.all.out('Running in PBS mode')
            return self.run_pbs_mode()
        else:
            Printer.all.out('Running in LOCAL mode')
            return self.run_local_mode()
Ejemplo n.º 2
0
    def _run(self):
        """
        Run method for this module
        """

        if self.arg_options.random_output_dir:
            import scripts.yamlc as yamlc
            yamlc.TEST_RESULTS = 'test_results-{}'.format(self.arg_options.random_output_dir)

        self.all_yamls = list()
        for path in self.arg_options.args:
            if not Paths.exists(path):
                Printer.all.err('given path does not exists, path "{}"', path)
                sys.exit(3)

            # append files to all_yamls
            if Paths.is_dir(path):
                self.all_yamls.extend(Paths.walk(path, ConfigPool.yaml_filters))
            else:
                self.all_yamls.append(path)

        Printer.all.out("Found {} yaml file/s", len(self.all_yamls))
        if not self.all_yamls:
            Printer.all.wrn('No yaml files found in locations: \n  {}', '\n  '.join(self.arg_options.args))
            sys.exit(0)

        self.configs = self.read_configs(self.all_yamls)
        self.configs.update(
            proc=self.arg_options.cpu,
            time_limit=self.arg_options.time_limit,
            memory_limit=self.arg_options.memory_limit,
        )

        # filter tags for includes and excludes
        self.configs.filter_tags(
            include=self.include,
            exclude=self.exclude
        )

        if self.arg_options.queue:
            Printer.all.out('Running in PBS mode')
            return self.run_pbs_mode()
        else:
            Printer.all.out('Running in LOCAL mode')
            return self.run_local_mode()
Ejemplo n.º 3
0
    def _walk_files(self):
        # switching processing logic
        self.dir_mode = False

        # in this loop we are processing all given files/folders
        all_yamls = list()
        for path in self.arg_options.args:
            if not Paths.exists(path):
                printf.error('given path does not exists, path "{}"', path)
                sys.exit(3)

            # append files to all_yamls
            if Paths.is_dir(path):
                self.dir_mode = True
                all_yamls.extend(Paths.walk(path, ConfigPool.yaml_filters))
            else:
                all_yamls.append(path)

        return all_yamls
def do_work(parser, args=None, debug=False):
    """
    :type parser: utils.argparser.ArgParser
    """

    # parse arguments
    global arg_options, arg_others, arg_rest
    arg_options, arg_others, arg_rest = parser.parse(args)
    Paths.format = PathFormat.ABSOLUTE
    Paths.base_dir('' if not arg_options.root else arg_options.root)

    # configure printer
    Printer.batch_output = arg_options.batch
    Printer.dynamic_output = not arg_options.batch

    # we need flow123d, mpiexec and ndiff to exists in LOCAL mode
    if not arg_options.queue and not Paths.test_paths('flow123d', 'mpiexec', 'ndiff'):
        Printer.err('Missing obligatory files! Exiting')
        GlobalResult.error = "missing obligatory files"
        sys.exit(1)

    # test yaml args
    if not arg_others:
        parser.exit_usage('Error: No yaml files or folder given')
        GlobalResult.error = "no yaml files or folder given"
        sys.exit(2)

    all_yamls = list()
    for path in arg_others:
        if not Paths.exists(path):
            Printer.err('Error! given path does not exists, ignoring path "{}"', path)
            GlobalResult.error = "path does not exist"
            sys.exit(3)

        if Paths.is_dir(path):
            all_yamls.extend(Paths.walk(path, filters=[
                PathFilters.filter_type_is_file(),
                PathFilters.filter_ext('.yaml'),
                PathFilters.filter_not(PathFilters.filter_name('config.yaml'))
            ]))
        else:
            all_yamls.append(path)

    Printer.out("Found {} .yaml file/s", len(all_yamls))
    if not all_yamls:
        Printer.wrn('Warning! No yaml files found in locations: \n  {}', '\n  '.join(arg_others))
        GlobalResult.error = "no yaml files or folders given"
        sys.exit(3)

    configs = read_configs(all_yamls)
    configs.update(
        proc=arg_options.cpu,
        time_limit=arg_options.time_limit,
        memory_limit=arg_options.memory_limit,
    )

    if arg_options.queue:
        Printer.out('Running in PBS mode')
        return run_pbs_mode(configs, debug)
    else:
        Printer.out('Running in LOCAL mode')
        return run_local_mode(configs, debug)