probcomp / bdbcontrib

BayesDB contributions, including plotting, helper methods, and examples
http://probcomp.csail.mit.edu/bayesdb
Apache License 2.0
9 stars 6 forks source link

Error: quickstart on "empty" bdb #137

Closed leocasarsa closed 8 years ago

leocasarsa commented 8 years ago

Trying to reproduce the gpmcc_metamodel example in quickstart syntax.

import os
os.environ['BAYESDB_WIZARD_MODE'] = '1'

import bayeslite
from bayeslite.read_pandas import bayesdb_read_pandas_df

import bdbcontrib
from bdbcontrib import quickstart

import gpmcc_metamodel

bdb_path = 'tmp/foo.bdb'
with bayeslite.bayesdb_open(bdb_path) as bdb:
    bdb.sql_execute('CREATE TABLE IF NOT EXISTS data (x INTEGER)')
    bdb.sql_execute('INSERT INTO data VALUES (1), (2), (3)')

    # This is the most important line!
    bayeslite.metamodel.bayesdb_register_metamodel(bdb, gpmcc_metamodel.Metamodel())
    test = bdbcontrib.quickstart(name='test', bdb_path=bdb_path)

Error:

Traceback (most recent call last):
  File "gen_test_bdb.py", line 19, in <module>
    test = bdbcontrib.quickstart(name='test', bdb_path=bdb_path)
  File "/home/leo/venv/20160507-scalpbdb/local/lib/python2.7/site-packages/bdbcontrib/__init__.py", line 30, in quickstart
    return Population(*args, **kwargs)
  File "/home/leo/venv/20160507-scalpbdb/local/lib/python2.7/site-packages/bdbcontrib/population.py", line 124, in __init__
    self.initialize()
  File "/home/leo/venv/20160507-scalpbdb/local/lib/python2.7/site-packages/bdbcontrib/population.py", line 169, in initialize
    raise BLE(ValueError("No data sources specified, and an empty bdb."))
bayeslite.exception.BayesLiteException: No data sources specified, and an empty bdb.
leocasarsa commented 8 years ago

This is not an urgent error, as I can pass the example dataset as a pandas DataFrame. Still, I find the behavior of quickstart with "empty" bdb files anti-intuitive.