def add_subparser(parser): """Return the parser that needs to be used for this command""" init_only_parser = parser.add_parser('init_only', help='init_only help') orion_group = cli.get_basic_args_group(init_only_parser, group_name='init_only arguments', group_help='') orion.core.config.experiment.add_arguments( orion_group, rename=dict(max_broken='--exp-max-broken', max_trials='--exp-max-trials')) orion_group.add_argument( '--max-trials', type=int, metavar='#', help= "(DEPRECATED) This argument will be removed in v0.3. Use --exp-max-trials instead" ) evc_cli.get_branching_args_group(init_only_parser) cli.get_user_args_group(init_only_parser) init_only_parser.set_defaults(func=main) init_only_parser.set_defaults( help_empty=True) # Print help if command is empty return init_only_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" hunt_parser = parser.add_parser('hunt', help='hunt help') orion_group = cli.get_basic_args_group(hunt_parser) orion_group.add_argument('--max-trials', type=int, metavar='#', help="number of jobs/trials to be completed " "(default: %s)" % resolve_config.DEF_CMD_MAX_TRIALS[1]) orion_group.add_argument( "--pool-size", type=int, metavar='#', help="number of concurrent workers to evaluate candidate samples " "(default: %s)" % resolve_config.DEF_CMD_POOL_SIZE[1]) evc_cli.get_branching_args_group(hunt_parser) cli.get_user_args_group(hunt_parser) hunt_parser.set_defaults(func=main) return hunt_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" hunt_parser = parser.add_parser('hunt', help='hunt help') orion_group = cli.get_basic_args_group(hunt_parser) orion_group.add_argument( '--max-trials', type=int, metavar='#', help="number of trials to be completed for the experiment. This value " "will be saved within the experiment configuration and reused " "across all workers to determine experiment's completion. " "(default: %s)" % resolve_config.DEF_CMD_MAX_TRIALS[1]) orion_group.add_argument( '--worker-trials', type=int, metavar='#', help="number of trials to be completed for this worker. " "If the experiment is completed, the worker will die even if it " "did not reach its maximum number of trials " "(default: %s)" % resolve_config.DEF_CMD_WORKER_TRIALS[1]) orion_group.add_argument( "--pool-size", type=int, metavar='#', help="number of concurrent workers to evaluate candidate samples " "(default: %s)" % resolve_config.DEF_CMD_POOL_SIZE[1]) evc_cli.get_branching_args_group(hunt_parser) cli.get_user_args_group(hunt_parser) hunt_parser.set_defaults(func=main) return hunt_parser
def add_subparser(parser): """Return the parser that needs to be used for this command""" init_only_parser = parser.add_parser("init_only", help=DESCRIPTION, description=DESCRIPTION) orion_group = cli.get_basic_args_group(init_only_parser, group_name="init_only arguments", group_help="") orion.core.config.experiment.add_arguments( orion_group, rename=dict(max_broken="--exp-max-broken", max_trials="--exp-max-trials"), ) orion_group.add_argument( "--max-trials", type=int, metavar="#", help= "(DEPRECATED) This argument will be removed in v0.3. Use --exp-max-trials instead", ) evc_cli.get_branching_args_group(init_only_parser) cli.get_user_args_group(init_only_parser) init_only_parser.set_defaults(func=main) init_only_parser.set_defaults( help_empty=True) # Print help if command is empty return init_only_parser
def test_user_group_arguments(setup_pickleddb_database, monkeypatch): """Test the parsing of the user group""" monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__))) parser = _create_parser(False) args_list = ["./black_box.py", "-x~normal(50,50)"] cli.get_user_args_group(parser) args = vars(parser.parse_args(args_list)) assert len(args["user_args"]) == 2 assert args["user_args"] == ["./black_box.py", "-x~normal(50,50)"]
def add_subparser(parser): """Add the subparser that needs to be used for this command""" insert_parser = parser.add_parser('insert', help='insert help') cli.get_basic_args_group(insert_parser) cli.get_user_args_group(insert_parser) insert_parser.set_defaults(func=main) return insert_parser
def add_subparser(parser): """Return the parser that needs to be used for this command""" init_only_parser = parser.add_parser('init_only', help='init_only help') cli.get_basic_args_group(init_only_parser) evc_cli.get_branching_args_group(init_only_parser) cli.get_user_args_group(init_only_parser) init_only_parser.set_defaults(func=main) return init_only_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" hunt_parser = parser.add_parser("hunt", help=SHORT_DESCRIPTION, description=DESCRIPTION) orion_group = cli.get_basic_args_group(hunt_parser, group_name="Hunt arguments", group_help="") orion.core.config.experiment.add_arguments( orion_group, rename=dict(max_broken="--exp-max-broken", max_trials="--exp-max-trials"), ) orion_group.add_argument( "--max-trials", type=int, metavar="#", help= "(DEPRECATED) This argument will be removed in v0.3. Use --exp-max-trials instead", ) orion_group.add_argument( "--init-only", default=False, action="store_true", help= "Only create the experiment and register in database, but do not execute any trial.", ) worker_args_group = hunt_parser.add_argument_group( "Worker arguments (optional)", description="Arguments to automatically resolved branching events.", ) orion.core.config.worker.add_arguments( worker_args_group, rename=dict(max_broken="--worker-max-broken", max_trials="--worker-max-trials"), ) evc_cli.get_branching_args_group(hunt_parser) cli.get_user_args_group(hunt_parser) hunt_parser.set_defaults(func=main) hunt_parser.set_defaults(help_empty=True) # Print help if command is empty return hunt_parser
def test_common_and_user_group_arguments(database, monkeypatch): """Test the parsing of the command and user groups""" monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__))) parser = _create_parser(False) args_list = ["-n", "test", "-c", "./orion_config_random.yaml", "./black_box.py", "-x~normal(50,50)"] cli.get_basic_args_group(parser) cli.get_user_args_group(parser) args = vars(parser.parse_args(args_list)) assert args['name'] == 'test' assert args['config'].name == './orion_config_random.yaml' assert len(args['user_args']) == 2 assert args['user_args'] == ['./black_box.py', '-x~normal(50,50)']
def add_subparser(parser): """Add the subparser that needs to be used for this command""" hunt_parser = parser.add_parser('hunt', help='hunt help') orion_group = cli.get_basic_args_group(hunt_parser) orion_group.add_argument( '--max-trials', type=int, metavar='#', help="number of trials to be completed for the experiment. This value " "will be saved within the experiment configuration and reused " "across all workers to determine experiment's completion. " "(default: %s)" % resolve_config.DEF_CMD_MAX_TRIALS[1]) orion_group.add_argument( '--worker-trials', type=int, metavar='#', help="number of trials to be completed for this worker. " "If the experiment is completed, the worker will die even if it " "did not reach its maximum number of trials " "(default: %s)" % resolve_config.DEF_CMD_WORKER_TRIALS[1]) orion_group.add_argument( '--working-dir', type=str, help="Set working directory for running experiment.") orion_group.add_argument( "--pool-size", type=int, metavar='#', help="number of simultaneous trials the algorithm should suggest. " "This is useful if many workers are executed in parallel and the algorithm has a " "strategy to sample non-independant trials simultaneously. Otherwise, it is better " "to leave `pool_size` to 1 and set a Strategy for Oríon's producer. " "Note that this option is not usefull useless you " "know the algorithm have a strategy to produce multiple trials " "simultaneously. If you have any doubt, leave it to 1. " "(default: %s)" % resolve_config.DEF_CMD_POOL_SIZE[1]) evc_cli.get_branching_args_group(hunt_parser) cli.get_user_args_group(hunt_parser) hunt_parser.set_defaults(func=main) return hunt_parser
def test_common_and_user_group_arguments(setup_pickleddb_database, monkeypatch): """Test the parsing of the command and user groups""" monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__))) parser = _create_parser(False) args_list = [ "-n", "test", "-c", "./orion_config_random.yaml", "./black_box.py", "-x~normal(50,50)", ] cli.get_basic_args_group(parser) cli.get_user_args_group(parser) args = vars(parser.parse_args(args_list)) assert args["name"] == "test" assert args["config"].name == "./orion_config_random.yaml" assert len(args["user_args"]) == 2 assert args["user_args"] == ["./black_box.py", "-x~normal(50,50)"]
def add_subparser(parser): """Add the subparser that needs to be used for this command""" hunt_parser = parser.add_parser('hunt', help='hunt help') orion_group = cli.get_basic_args_group(hunt_parser, group_name='Hunt arguments', group_help='') orion.core.config.experiment.add_arguments( orion_group, rename=dict(max_broken='--exp-max-broken', max_trials='--exp-max-trials')) orion_group.add_argument( '--max-trials', type=int, metavar='#', help= "(DEPRECATED) This argument will be removed in v0.3. Use --exp-max-trials instead" ) worker_args_group = hunt_parser.add_argument_group( "Worker arguments (optional)", description="Arguments to automatically resolved branching events.") orion.core.config.worker.add_arguments( worker_args_group, rename=dict(max_broken='--worker-max-broken', max_trials='--worker-max-trials')) evc_cli.get_branching_args_group(hunt_parser) cli.get_user_args_group(hunt_parser) hunt_parser.set_defaults(func=main) hunt_parser.set_defaults(help_empty=True) # Print help if command is empty return hunt_parser