コード例 #1
0
ファイル: test_dbs.py プロジェクト: yonittanenbaum/mlrun
def test_runs(db: RunDBInterface):
    run1 = new_run("s1", {"l1": "v1", "l2": "v2"}, x=1)
    db.store_run(run1, "uid1")
    run2 = new_run("s1", {"l2": "v2", "l3": "v3"}, x=2)
    db.store_run(run2, "uid2")
    run3 = new_run("s2", {"l3": "v3"}, x=2)
    uid3 = "uid3"
    db.store_run(run3, uid3)
    db.store_run(run3, uid3)  # should not raise

    updates = {
        "status": {
            "start_time": run_now(),
            "state": "s2"
        },
    }
    db.update_run(updates, uid3)

    runs = db.list_runs(labels={"l2": "v2"})
    assert 2 == len(runs), "labels length"
    assert {1, 2} == {r["x"] for r in runs}, "xs labels"

    runs = db.list_runs(state="s2")
    assert 1 == len(runs), "state length"
    run3["status"] = updates["status"]
    assert run3 == runs[0], "state run"

    db.del_run(uid3)
    with pytest.raises(mlrun.errors.MLRunNotFoundError):
        db.read_run(uid3)

    label = "l1"
    db.del_runs(labels=[label])
    for run in db.list_runs():
        assert label not in run["metadata"]["labels"], "del_runs"
コード例 #2
0
ファイル: test_dbs.py プロジェクト: zhuohuwu0603/mlrun
def test_runs(db: RunDBInterface):
    run1 = new_run('s1', {'l1': 'v1', 'l2': 'v2'}, x=1)
    db.store_run(run1, 'uid1')
    run2 = new_run('s1', {'l2': 'v2', 'l3': 'v3'}, x=2)
    db.store_run(run2, 'uid2')
    run3 = new_run('s2', {'l3': 'v3'}, x=2)
    uid3 = 'uid3'
    db.store_run(run3, uid3)
    db.store_run(run3, uid3)  # should not raise

    updates = {
        'status': {
            'start_time': run_now(),
            'state': 's2',
        },
    }
    db.update_run(updates, uid3)

    runs = db.list_runs(labels={'l2': 'v2'})
    assert 2 == len(runs), 'labels length'
    assert {1, 2} == {r['x'] for r in runs}, 'xs labels'

    runs = db.list_runs(state='s2')
    assert 1 == len(runs), 'state length'
    run3['status'] = updates['status']
    assert run3 == runs[0], 'state run'

    db.del_run(uid3)
    with pytest.raises(RunDBError):
        db.read_run(uid3)

    label = 'l1'
    db.del_runs(labels=[label])
    for run in db.list_runs():
        assert label not in run['metadata']['labels'], 'del_runs'
コード例 #3
0
ファイル: test_dbs.py プロジェクト: yonittanenbaum/mlrun
def test_list_runs(db: RunDBInterface):
    if isinstance(db, FileRunDB):
        pytest.skip("FIXME")
    uid = "u183"
    run = new_run("s1", {"l1": "v1", "l2": "v2"}, uid, x=1)
    count = 5
    for iter in range(count):
        db.store_run(run, uid, iter=iter)

    runs = list(db.list_runs(uid=uid))
    assert 1 == len(runs), "iter=False"

    runs = list(db.list_runs(uid=uid, iter=True))
    assert 5 == len(runs), "iter=True"
コード例 #4
0
ファイル: test_dbs.py プロジェクト: zhuohuwu0603/mlrun
def test_list_runs(db: RunDBInterface):
    if isinstance(db, FileRunDB):
        pytest.skip('FIXME')
    uid = 'u183'
    run = new_run('s1', {'l1': 'v1', 'l2': 'v2'}, uid, x=1)
    count = 5
    for iter in range(count):
        db.store_run(run, uid, iter=iter)

    runs = list(db.list_runs(uid=uid))
    assert 1 == len(runs), 'iter=False'

    runs = list(db.list_runs(uid=uid, iter=True))
    assert 5 == len(runs), 'iter=True'