

@contextlib.contextmanager
def analyzed_bayesdb_generator(mkbdb, nmodels, nsteps, max_seconds=None):
    with mkbdb as (bdb, generator_id):
        generator = core.bayesdb_generator_name(bdb, generator_id)
        qg = bql_quote_name(generator)
        bql = ('INITIALIZE %d MODELS FOR %s' % (max_seconds, qg))
        bdb.execute(bql)
        duration = None
        if max_seconds:
            duration = ('%d SECONDS' % (max_seconds,))
        else:
            duration = ('%d ITERATIONS' % (nsteps,))
        bql = ('ANALYZE %s FOR %s WAIT' % (qg, duration))
        bdb.execute(bql)
        (yield (bdb, generator_id))

dataset/ETHPy150Open probcomp/bayeslite/tests/test_core.py analyzed_bayesdb_generator/VarMisuse@58/100 `nmodels`->`max_seconds`