コード例 #1
0
ファイル: test_tinydb_reader.py プロジェクト: remss/sacred
def run_test_experiment(exp_name, exp_id, root_dir):

    T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
    T3 = datetime.datetime(1999, 5, 5, 6, 6, 6, 6)

    run_date = sample_run()
    run_date['ex_info']['name'] = exp_name
    run_date['_id'] = exp_id

    # Create
    tinydb_obs = TinyDbObserver.create(path=root_dir)

    # Start exp 1
    tinydb_obs.started_event(**run_date)

    # Heartbeat
    info = {'my_info': [1, 2, 3], 'nr': 7}
    outp = 'some output'
    tinydb_obs.heartbeat_event(info=info, captured_out=outp, beat_time=T2)
    # Add Artifact
    filename = "sacred/__about__.py"
    name = 'about'
    tinydb_obs.artifact_event(name, filename)

    # Add Resource
    filename = "sacred/__init__.py"
    tinydb_obs.resource_event(filename)

    # Complete
    tinydb_obs.completed_event(stop_time=T3, result=42)

    return tinydb_obs
コード例 #2
0
ファイル: test_tinydb_reader.py プロジェクト: elanmart/sacred
def run_test_experiment(exp_name, exp_id, root_dir):

    T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)
    T3 = datetime.datetime(1999, 5, 5, 6, 6, 6, 6)

    run_date = sample_run()
    run_date['ex_info']['name'] = exp_name
    run_date['_id'] = exp_id

    # Create
    tinydb_obs = TinyDbObserver.create(path=root_dir)

    # Start exp 1
    tinydb_obs.started_event(**run_date)

    # Heartbeat
    info = {'my_info': [1, 2, 3], 'nr': 7}
    outp = 'some output'
    tinydb_obs.heartbeat_event(info=info, captured_out=outp, beat_time=T2,
                               result=7)
    # Add Artifact
    filename = "sacred/__about__.py"
    name = 'about'
    tinydb_obs.artifact_event(name, filename)

    # Add Resource
    filename = "sacred/__init__.py"
    tinydb_obs.resource_event(filename)

    # Complete
    tinydb_obs.completed_event(stop_time=T3, result=42)

    return tinydb_obs
コード例 #3
0
def test_tinydb_observer_equality(tmpdir, tinydb_obs):

    db = TinyDB(os.path.join(tmpdir.strpath, 'metadata.json'))
    fs = HashFS(os.path.join(tmpdir.strpath, 'hashfs'), depth=3,
                width=2, algorithm='md5')
    m = TinyDbObserver(db, fs)

    assert tinydb_obs == m
    assert not tinydb_obs != m

    assert not tinydb_obs == 'foo'
    assert tinydb_obs != 'foo'
コード例 #4
0
def test_tinydb_observer_equality(tmpdir, tinydb_obs):

    db = TinyDB(os.path.join(tmpdir.strpath, "metadata.json"))
    fs = HashFS(
        os.path.join(tmpdir.strpath, "hashfs"), depth=3, width=2, algorithm="md5"
    )
    m = TinyDbObserver.create_from(db, fs)

    assert tinydb_obs == m
    assert not tinydb_obs != m

    assert not tinydb_obs == "foo"
    assert tinydb_obs != "foo"
コード例 #5
0
def test_tinydb_observer_creates_missing_directories(tmpdir):
    tinydb_obs = TinyDbObserver.create(path=os.path.join(tmpdir.strpath, 'foo'))
    assert tinydb_obs.root == os.path.join(tmpdir.strpath, 'foo')
コード例 #6
0
def tinydb_obs(tmpdir):
    return TinyDbObserver.create(path=tmpdir.strpath)
コード例 #7
0
ファイル: test_tinydb_observer.py プロジェクト: IDSIA/sacred
def test_tinydb_observer_creates_missing_directories(tmpdir):
    tinydb_obs = TinyDbObserver.create(path=os.path.join(tmpdir.strpath, 'foo'))
    assert tinydb_obs.root == os.path.join(tmpdir.strpath, 'foo')
コード例 #8
0
ファイル: test_tinydb_observer.py プロジェクト: IDSIA/sacred
def tinydb_obs(tmpdir):
    return TinyDbObserver.create(path=tmpdir.strpath)