How to use the orion.core.cli.main function in orion

To help you get started, we’ve selected a few orion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Epistimio / orion / tests / functional / branching / test_branching.py View on Github external
def test_branch_from_selected_version(clean_db, monkeypatch, database):
    """Test that branching from a version passed with `--version` works."""
    monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1)".split(" "))
    orion.core.cli.main("init_only -n experiment ./black_box.py -x~normal(0,1) -y~+normal(0,1)"
                        .split(" "))
    orion.core.cli.main("init_only -n experiment --version 1 -b experiment_2 ./black_box.py "
                        "-x~normal(0,1) -z~+normal(0,1)".split(" "))

    parent = database.experiments.find({'name': 'experiment', 'version': 1})[0]
    exp = database.experiments.find({'name': 'experiment_2'})[0]
    assert exp['refers']['parent_id'] == parent['_id']
github Epistimio / orion / tests / functional / commands / test_status_command.py View on Github external
def test_experiment_w_child_w_name(clean_db, three_experiments_with_trials, capsys):
    """Test status with the name argument and one child."""
    orion.core.cli.main(['status', '--name', 'test_double_exp'])

    captured = capsys.readouterr().out

    expected = """\
test_double_exp-v1
==================
status         quantity
-----------  ----------
broken                1
completed             1
interrupted           1
new                   1
reserved              1
suspended             1

github Epistimio / orion / tests / functional / commands / test_init_only_command.py View on Github external
def test_no_args(capsys):
    """Test that help is printed when no args are given."""
    with pytest.raises(SystemExit):
        orion.core.cli.main(['init_only'])

    captured = capsys.readouterr().out

    assert 'usage:' in captured
    assert 'Traceback' not in captured
github Epistimio / orion / tests / functional / commands / test_status_command.py View on Github external
def test_two_related_w_ac(clean_db, family_with_trials, capsys):
    """Test two related experiments with --collapse and --all."""
    orion.core.cli.main(['status', '--collapse', '--all'])

    captured = capsys.readouterr().out

    expected = """\
test_double_exp-v1
==================
id                                status
--------------------------------  -----------
c2187f4954884c801e423d851aec9a0b  broken
e42cc22a15188d72df315b9eac79c9c0  completed
b849f69cc3a77f39382d7435d0d41b14  interrupted
7fbbd152f7ca2c064bf00441e311609d  new
d5f1c1cae188608b581ded20cd198679  new
667513aa2cb2244bee9c4f41c7ff1cea  reserved
557b9fdb9f96569dff7eb2de10d3946f  suspended
github Epistimio / orion / tests / functional / commands / test_status_command.py View on Github external
def test_experiment_same_name_wout_exv_w_c_w_child_w_name(
        clean_db, three_experiments_family_same_name, capsys):
    """Test status name collapsed with two experiments having the same name and one with a child."""
    orion.core.cli.main(['status', '--name', 'test_single_exp', '--collapse'])

    captured = capsys.readouterr().out

    expected = """\
test_single_exp-v2
==================
empty


"""

    assert captured == expected
github Epistimio / orion / tests / functional / commands / test_status_command.py View on Github external
def test_experiment_same_name_w_exv_w_child(clean_db, three_experiments_family_same_name, capsys):
    """Test status with two experiments having the same name and one with a child."""
    orion.core.cli.main(['status', '--expand-versions'])

    captured = capsys.readouterr().out

    expected = """\
test_single_exp-v1
==================
empty


  test_single_exp-v2
  ==================
  empty


  test_single_exp_child-v1
  ========================
github Epistimio / orion / tests / functional / commands / test_setup_command.py View on Github external
def test_creation_when_not_existing(monkeypatch, tmp_path):
    """Test if a configuration file is created when it does not exist."""
    config_path = str(tmp_path) + "/tmp_config.yaml"
    monkeypatch.setattr(orion.core, "DEF_CONFIG_FILES_PATHS", [config_path])
    monkeypatch.setattr(builtins, "input", _mock_input(['type', 'name', 'host']))

    try:
        os.remove(config_path)
    except FileNotFoundError:
        pass

    orion.core.cli.main(["db", "setup"])

    assert os.path.exists(config_path)

    with open(config_path, 'r') as output:
        content = yaml.safe_load(output)

    assert content == {"database": {"type": "type", "name": "name", "host": "host"}}
github Epistimio / orion / tests / functional / commands / test_insert_command.py View on Github external
monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
    orion.core.cli.main(["init_only", "-n", "experiment",
                         "-c", "./orion_config_random.yaml", script_path, "-x~normal(0,1)"])
    orion.core.cli.main(["init_only", "-n", "experiment",
                         "-c", "./orion_config_random.yaml", script_path, "-x~normal(0,1)",
                         "-y~+normal(0,1)"])

    exp = list(get_storage().fetch_experiments({"name": "experiment", "version": 1}))
    assert len(exp) == 1
    exp = exp[0]
    assert '_id' in exp

    trials = list(get_storage().fetch_trials(uid=exp['_id']))
    assert len(trials) == 0

    orion.core.cli.main(["insert", "-n", "experiment", "--version", "1",
                         "-c", "./orion_config_random.yaml", script_path, "-x=1"])

    trials = list(get_storage().fetch_trials(uid=exp['_id']))

    assert len(trials) == 1
github Epistimio / orion / tests / functional / commands / test_insert_command.py View on Github external
def test_insert_two_hyperparameters(database, monkeypatch):
    """Try to insert a single trial with two hyperparameters"""
    monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
    monkeypatch.setattr("getpass.getuser", get_user_corneau)
    orion.core.cli.main(["insert", "-n", "test_insert_two_hyperparameters",
                         "-c", "./orion_config_random.yaml", "./black_box.py", "-x=1", "-y=2"])

    exp = list(database.experiments.find({"name": "test_insert_two_hyperparameters"}))
    assert len(exp) == 1
    exp = exp[0]
    assert '_id' in exp

    trials = list(database.trials.find({"experiment": exp['_id']}))

    assert len(trials) == 1

    trial = trials[0]

    assert trial['status'] == 'new'
    assert trial['params'][0]['value'] == 1
    assert trial['params'][1]['value'] == 2
github Epistimio / orion / tests / functional / commands / test_list_command.py View on Github external
def test_two_exp(capsys, clean_db, two_experiments):
    """Test that experiment and child are printed."""
    orion.core.cli.main(['list'])

    captured = capsys.readouterr().out

    assert captured == """\
 test_double_exp-v1┐