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): """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 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_undefined_parser(): """Test that creation of new resolution class make parser creation crash""" # It works get_branching_args_group(argparse.ArgumentParser()) class DummyResolution(Resolution): ARGUMENT = "--dummy" # It doesn't with pytest.raises(AssertionError) as exc: get_branching_args_group(argparse.ArgumentParser()) assert "A resolution with metavar 'dummy'" in str(exc.value)
def test_defined_parser(): """Test that all expected branching arguments are present""" parser = argparse.ArgumentParser() get_branching_args_group(parser) options = parser.parse_args([]) assert options.auto_resolution is False assert options.algorithm_change is False assert options.branch is None assert options.cli_change_type is None assert options.code_change_type is None assert options.config_change_type is None
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 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 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