Пример #1
0
def test_sessions_error_metamodel():
    with test_core.t1() as (bdb, _generator_id):
        bayeslite.bayesdb_register_metamodel(bdb, ErroneousMetamodel())
        bdb.execute('''
            CREATE GENERATOR t1_err FOR t1
                USING erroneous(age NUMERICAL)
        ''')
        tr = sescap.SessionOrchestrator(bdb)
        cursor = bdb.execute('''
            ESTIMATE PREDICTIVE PROBABILITY OF age FROM t1_err
        ''')
        with pytest.raises(Boom):
            cursor.fetchall()
        #tr._start_new_session()
        assert tr._check_error_entries(tr.session_id) > 0
Пример #2
0
def test_sessions_no_errors():
    with test_core.analyzed_bayesdb_population(test_core.t1(),
            10, None, max_seconds=1) as (bdb, population_id, generator_id):
        tr = sescap.SessionOrchestrator(bdb)
        # simple query
        cursor = bdb.execute('''
            SELECT age, weight FROM t1
                WHERE label = 'frotz'
                ORDER BY weight
        ''')
        cursor.fetchall()
        # add a metamodel and do a query
        cursor = bdb.execute('''
            ESTIMATE PREDICTIVE PROBABILITY OF age FROM p1
        ''')
        cursor.fetchall()
        # there should be no error entries in the previous session
        #tr._start_new_session()
        assert tr._check_error_entries(tr.session_id) == 0
Пример #3
0
def test_sessions_start_stop():
    bdb = make_bdb()

    # the session table exists but there should be no entries before we
    # register the session tracer
    assert get_num_sessions(bdb.execute) == 0
    _simple_bql_query(bdb)
    assert get_num_entries(bdb.execute) == 0

    # registering the tracer starts recording of sessions
    tr = sescap.SessionOrchestrator(bdb)
    _simple_bql_query(bdb)
    num = get_num_entries(bdb.execute)
    assert num > 0

    # stopping the tracer
    tr.stop_saving_sessions()
    _simple_bql_query(bdb)
    assert get_num_entries(bdb.execute) == num

    # restarting the tracer
    tr.start_saving_sessions()
    _simple_bql_query(bdb)
    assert get_num_entries(bdb.execute) > num
Пример #4
0
def make_bdb_with_sessions(*args, **kwargs):
    bdb = make_bdb()
    tr = sescap.SessionOrchestrator(bdb, *args, **kwargs)
    return (bdb, tr)