Exemple #1
0
def ft_demo_v1():
    # test_data_name = "dorothea"
    # test_data_name = "coil2000"
    # test_data_name = "magic"
    # test_data_name = "digits"
    # test_data_name = "ring"
    # test_data_name = "banana"
    # test_data_name = "heart"
    # test_data_name = "liver"
    # test_data_name = "christine"
    # test_data_name = "jasmine"
    test_data_name = "madeline"
    # test_data_name = "philippine"
    # test_data_name = "sylvine"
    # test_data_name = 'newsgroups'
    # test_data_name = 'adult'
    test_time_budget = 5 * 60  # seconds TODO - this should also be in an experiment config file

    # FIXME - TEST_INPUT_DIR is not a constant! - this should be in an experiment config file
    constants.TEST_INPUT_DIR = os.path.join('..', 'data', 'phase_1')

    mgr = FixedLearnersStackingManager(constants.TEST_INPUT_DIR, constants.TEST_OUTPUT_DIR, test_data_name,
                                       test_time_budget,
                                       compute_quantum=5, plot=True,
                                       overhead_memory=constants.OVERHEAD,
                                       cgroup_soft_limit=constants.CGROUP_SOFT_LIMIT,
                                       cgroup_hard_limit=constants.CGROUP_HARD_LIMIT)
    mgr.communicate()
Exemple #2
0
def ft_demo_v1():
    # test_data_name = "dorothea"
    # test_data_name = "coil2000"
    # test_data_name = "magic"
    # test_data_name = "digits"
    # test_data_name = "ring"
    # test_data_name = "banana"
    # test_data_name = "heart"
    # test_data_name = "liver"
    # test_data_name = "christine"
    # test_data_name = "jasmine"
    test_data_name = "madeline"
    # test_data_name = "philippine"
    # test_data_name = "sylvine"
    # test_data_name = 'newsgroups'
    # test_data_name = 'adult'
    test_time_budget = 5 * 60  # seconds TODO - this should also be in an experiment config file

    # FIXME - TEST_INPUT_DIR is not a constant! - this should be in an experiment config file
    constants.TEST_INPUT_DIR = os.path.join('..', 'data', 'phase_1')

    mgr = FixedLearnersStackingManager(
        constants.TEST_INPUT_DIR,
        constants.TEST_OUTPUT_DIR,
        test_data_name,
        test_time_budget,
        compute_quantum=5,
        plot=True,
        overhead_memory=constants.OVERHEAD,
        cgroup_soft_limit=constants.CGROUP_SOFT_LIMIT,
        cgroup_hard_limit=constants.CGROUP_HARD_LIMIT)
    mgr.communicate()
Exemple #3
0
def run_experiment_file(filename, plot_override=True, separate_process=False):
    """
    This is intended to be the function that's called to initiate a series of experiments.
    """
    exp = load_experiment_details(filename=filename)
    print("BEGIN EXPERIMENT SPECIFICATIONS")
    print(exp_params_to_str(exp))
    print("END EXPERIMENT SPECIFICATIONS")

    # # Set number of processors
    p = psutil.Process()
    all_cpus = list(range(psutil.cpu_count() - 1))
    p.cpu_affinity(all_cpus)

    # Set up logging
    root_logger = logging.getLogger()
    root_logger.setLevel(logging.DEBUG)

    form = logging.Formatter("[%(levelname)s/%(processName)s] %(asctime)s %(message)s")

    # Handler for logging to stderr
    sh = logging.StreamHandler(stream=sys.stdout)
    sh.setLevel(logging.WARN)  # set level here
    # sh.addFilter(ProcessFilter())  # filter to show only logs from manager
    sh.setFormatter(form)
    root_logger.addHandler(sh)

    # Handler for logging to file
    util.move_make_file(constants.LOGFILE)
    fh = logging.handlers.RotatingFileHandler(constants.LOGFILE, maxBytes=512 * 1024 * 1024)
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(form)
    root_logger.addHandler(fh)

    # Make output dir
    util.move_make(exp["output_dir"])

    # Make score dir and learning curve
    if exp["score_dir"] is not None:
        util.move_make(exp["score_dir"])
        with open(os.path.join(exp["score_dir"], "learning_curve.csv"), "w") as score_file:
            score_file.write("Time,Score\n")

    # Record start time
    open(os.path.join(exp["output_dir"], exp["basename"] + ".firstpost"), "wb").close()

    # Plotting?
    if plot_override is not None:
        exp["plot"] = plot_override

    # Start manager
    mgr = FixedLearnersStackingManager(
        exp["input_dir"],
        exp["output_dir"],
        exp["basename"],
        exp["time_budget"],
        compute_quantum=exp["compute_quantum"],
        plot=exp["plot"],
        overhead_memory=constants.OVERHEAD,
        cgroup_soft_limit=constants.CGROUP_SOFT_LIMIT,
        cgroup_hard_limit=constants.CGROUP_HARD_LIMIT,
        exp=exp,
    )

    if separate_process:

        # Create process
        p = Process(target=agent.start_communication, kwargs=dict(agent=mgr))
        p.name = "manager"
        p.start()

        print("\nPress enter to terminate at any time.\n")
        while True:
            if not p.is_alive():
                break

            # Wait for one second to see if any keyboard input
            i, o, e = select.select([sys.stdin], [], [], 1)
            if i:
                print("\n\nTerminating")
                try:
                    ps = psutil.Process(pid=p.pid)
                    ps.send_signal(signal.SIGTERM)
                    p.join(timeout=5)
                    if p.is_alive():
                        print("Didn't respond to SIGTERM")
                        util.murder_family(pid=p.pid, killall=True, sig=signal.SIGKILL)
                except psutil.NoSuchProcess:
                    pass  # already dead
                break

    else:
        mgr.communicate()