def add_subparser(parser): """Add the subparser that needs to be used for this command""" status_parser = parser.add_parser('status', help='status help') cli.get_basic_args_group(status_parser) status_parser.add_argument( '-a', '--all', action="store_true", help= "Show all trials line by line. Otherwise, they are all aggregated by status" ) status_parser.add_argument( '-C', '--collapse', action="store_true", help= ("Aggregate together results of all child experiments. Otherwise they are all " "printed hierarchically")) status_parser.add_argument( '-e', '--expand-versions', action='store_true', help= ("Show all the version of every experiments instead of only the latest one" )) status_parser.set_defaults(func=main) return status_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" info_parser = parser.add_parser('info', help='info help') get_basic_args_group(info_parser) info_parser.set_defaults(func=main) return info_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" list_parser = parser.add_parser('list', help='list help') cli.get_basic_args_group(list_parser) list_parser.set_defaults(func=main) return list_parser
def test_common_group_arguments(setup_pickleddb_database, monkeypatch): """Check the parsing of the common group""" monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__))) parser, subparsers = _create_parser() args_list = ["-n", "test", "--config", "./orion_config_random.yaml"] cli.get_basic_args_group(parser) args = vars(parser.parse_args(args_list)) assert args["name"] == "test" assert args["config"].name == "./orion_config_random.yaml"
def add_subparser(parser): """Add the subparser that needs to be used for this command""" info_parser = parser.add_parser( "info", help=SHORT_DESCRIPTION, description=SHORT_DESCRIPTION ) get_basic_args_group(info_parser) info_parser.set_defaults(func=main) return info_parser
def add_subparser(parser): """Add the subparser that needs to be used for this command""" list_parser = parser.add_parser("list", help=SHORT_DESCRIPTION, description=DESCRIPTION) cli.get_basic_args_group(list_parser) list_parser.set_defaults(func=main) return list_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""" 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) insert_parser.set_defaults( help_empty=True) # Print help if command is empty return insert_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): """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 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): """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""" plot_parser = parser.add_parser("plot", help=DESCRIPTION, description=DESCRIPTION) cli.get_basic_args_group(plot_parser) plot_parser.add_argument( "kind", type=str, choices=SINGLE_EXPERIMENT_PLOTS.keys(), help="kind of plot to generate. ", ) plot_parser.add_argument( "-t", "--type", type=str, default="png", choices=VALID_TYPES, help="type of plot to return. (default: png)", ) plot_parser.add_argument( "-o", "--output", type=str, default="", help="path where plot is saved. " " Will override the `type` argument." " (default is {exp.name}-v{exp.version}_{kind}.{type})", ) plot_parser.add_argument( "--scale", type=float, default=1, help="more pixels, but same proportions of the plot. " " Scale acts as multiplier on height and width of resulting image." " Overrides value of 'scale' in plotly.io.write_image.", ) plot_parser.set_defaults(func=main) return plot_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=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""" status_parser = parser.add_parser("status", help=SHORT_DESCRIPTION, description=DESCRIPTION) cli.get_basic_args_group(status_parser) status_parser.add_argument( "-a", "--all", action="store_true", help= "Show all trials line by line. Otherwise, they are all aggregated by status", ) status_parser.add_argument( "-C", "--collapse", action="store_true", help= ("Aggregate together results of all child experiments. Otherwise they are all " "printed hierarchically"), ) status_parser.add_argument( "-e", "--expand-versions", action="store_true", help= ("Show all the version of every experiments instead of only the latest one" ), ) status_parser.set_defaults(func=main) return status_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