Beispiel #1
0
    def config(self):
        """Returns the internal configuration object"""
        # Load it when asked first time
        if not self.__opu_config:
            self.__opu_config = config.load_config(self.__config_file, self._trace)
            if self.__config_override is not None:
                utils.recurse_update(self.__opu_config, self.__config_override)

        return self.__opu_config
Beispiel #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-ns", "--n-samples", type=int,
                        help="number of images", default=3000)
    parser.add_argument("-nc", "--n-components", type=int,
                        help="number of components", default=0)
    parser.add_argument("-nf", "--n-features", type=int,
                        help="number of features", default=100)
    parser.add_argument("-v", "--verbose", type=int, default=1)
    parser.add_argument("-V", "--version", action='store_true',
                        help="Print OPU and libraries version and exit")
    parser.add_argument("-l", "--linear", action="store_true")
    parser.add_argument("-dp", "--disable-pbar", action="store_true",
                        help="disable progress bar")
    args = parser.parse_args()
    if args.version:
        # Get OPU config, and extract versions in string array
        if config.host_has_opu_config():
            print(config.opu_version(config.load_config()))
        else:
            print("No OPU detected on this host")
        print(f"lightonml version {lightonml.__version__}")
        try:
            # noinspection PyUnresolvedReferences
            import lightonopu
            print(f"lightonopu version {lightonopu.__version__}")
        except ImportError:
            pass
        return

    lightonml.set_verbose_level(args.verbose)
    # These are temporary, for debugging, so meh for programming style.
    # import sys, trace

    # If there are segfaults, it's a good idea to always use stderr as it
    # always prints to the screen, so you should get as much output as
    # possible.
    # sys.stdout = sys.stderr

    # uncomment the 2 following lines trace execution:
    # tracer = trace.Trace(trace=1, count=0, ignoredirs=["/usr", sys.prefix])
    # tracer.run('main(args.nbimages)')
    transform(args.n_samples, args.n_features, args.n_components,
              args.disable_pbar, linear=args.linear)