Esempio n. 1
0
def test_command_3():
    cmd = Command('predict', options=[Option(name="@AI")])
    assert cmd.parse(["@stubborn-dishwasher", "predict"]) == {
        '@AI': 'stubborn-dishwasher'
    }
    with pytest.raises(VergeMLError):
        cmd.parse(["predict"])
Esempio n. 2
0
def test_command_2():
    cmd = Command('run', options=[Option('<args>', type=list), Option('@AIs', type=list)])
    assert cmd.parse(["run", "tensorboard"]) == {'@AIs': [], '<args>': ["tensorboard"]}
    assert cmd.parse(["@funky-terminator", "run", "tensorboard"]) == \
        {'@AIs': ['funky-terminator'], '<args>': ["tensorboard"]}
    assert cmd.parse(["@funky-terminator", "@touchy-brobot", "run", "tensorboard", "--port=2204"]) == \
                    {'@AIs': ['funky-terminator', 'touchy-brobot'], '<args>': ["tensorboard", "--port=2204"]}
Esempio n. 3
0
def test_command_7():
    cmd = Command('help', options=[Option(name='<topic>'),
                                   Option(name="@AI", type='Optional[@]')], free_form=True)
    assert cmd.parse(["@funky-robot", "help", "--option=xyz", "something"]) == \
           ('funky-robot', ["--option=xyz", "something"])

    assert cmd.parse(["help", "--option=xyz", "something"]) == \
           (None, ["--option=xyz", "something"])
Esempio n. 4
0
def test_command_5():
    options = [
        Option('threshold', type=float, validate=">0", short='t'),
        Option('id', default=False, type=bool, flag=True, short='i')
    ]
    cmd = Command('predict', options=options)
    assert cmd.parse(["predict", "--threshold=0.2"]) == {'threshold': 0.2, 'id': False}
    assert cmd.parse(["predict", "-t0.2"]) == {'threshold': 0.2, 'id': False}
    assert cmd.parse(["predict", "-t0.2", "--id"]) == {'threshold': 0.2, 'id': True}
    assert cmd.parse(["predict", "-t0.2", "-i"]) == {'threshold': 0.2, 'id': True}
Esempio n. 5
0
def test_command_1():
    cmd = Command('train', options=[Option('epochs', 20, int, validate='>=1')])
    assert cmd.parse(["train", "--epochs=14"]) == {'epochs': 14}

    with pytest.raises(VergeMLError):
        cmd.parse(["train", "--epochs=abc"])

    with pytest.raises(VergeMLError):
        cmd.parse(["train", "--epochz=14"])

    with pytest.raises(VergeMLError):
        cmd.parse(["train", "--epochs=-1"])
Esempio n. 6
0
def test_command_6():
    cmd = Command('new', options=[Option(name='<project-name>', type='str')])
    assert cmd.parse(["new", "xxx"]) == {'<project-name>': "xxx"}
    with pytest.raises(VergeMLError):
        cmd.parse(["new"])
Esempio n. 7
0
def test_command_4():
    cmd = Command('predict', options=[Option(name="@AI", type="Optional[AI]")])
    assert cmd.parse(["@stubborn-dishwasher", "predict"]) == {
        '@AI': 'stubborn-dishwasher'
    }
    assert cmd.parse(["predict"]) == {'@AI': None}