Ejemplo n.º 1
0
def create_experiment(experiment_settings):
    logger.debug("create_experiment")
    logger.info("ATTEMPT: get names and lists from experiment_settings")

    sim_name = experiment_settings.sim_name
    exp_name = experiment_settings.exp_name
    agent_list = experiment_settings.agent_list
    sim_list = experiment_settings.sim_list
    view_list = experiment_settings.view_list

    logger.info("OK: get names and lists from experiment settings")
    # Check that theres only 1 sim and 1 agent

    logger.info("ATTEMPT: Check lists are valid")
    valid_lists = check_lists(sim_list, agent_list, view_list)
    if all(list is True for list in valid_lists):
        logger.info("OK: All lists valid")
    else:
        logger.error(
            "FAILED: Invalid lists. Lists labeled false are invalid. Sim: %s ; Agent: %s; View: %s"
            % (valid_lists[0], valid_lists[1], valid_lists[2])
        )
        sys.exit(1)

    generate_experiment(sim_list, agent_list, view_list, sim_name, exp_name)
Ejemplo n.º 2
0
def create_experiment_database():
    from mTurk1.simulations.sim_test_1.configExp import ExperimentSettings
    #TRY: get settings from ExperimentSettings module
    try:
        experiment_settings=ExperimentSettings
    except:
        logger.error("create_database: Could not initialise ExperimentSettings config file")
        return 1
    
    #TRY: set up the varaibles for creating an experiment
    try: 
        sim_name=experiment_settings.sim_name
        exp_name=experiment_settings.exp_name
        agent_list=experiment_settings.agent_list
        sim_list=experiment_settings.sim_list
        view_list=experiment_settings.view_list
            
    except:
        logger.error("create_database: Could not create sim, agent and view lists ")
        return 1
    
    try:   
        valid_lists=check_lists(sim_list,agent_list,view_list)
        if all(list is True for list in valid_lists):
            logger.debug("create_database: All lists valid")
        else:
            logger.debug("create_databse: INVALID lists (labelled False). Sim: %s ; Agent: %s; View: %s" %(valid_lists[0],valid_lists[1], valid_lists[2]))
    except:
        logger.critical("create_database: Could not run valid_lists")
        return 1
        
    try:
        logger.info("Running generate_experiment")
        logger.debug("Sim_list: %s" %sim_list)
        logger.debug("Agent_list: %s" %agent_list)
        logger.debug("View_list: %s" %view_list)
        status=generate_experiment(sim_list,agent_list,view_list,sim_name,exp_name)
        if status==1:
            raise Exception
        
    except:
        logger.error("create_database: Could not run generate_experiment")
        return 1
    
    return 0