probcomp / iventure

An interactive, browser-based probabilistic programming environment.
Apache License 2.0
14 stars 2 forks source link

.interactive_pairplot crashes if there is no metamodel #39

Closed Schaechtle closed 7 years ago

Schaechtle commented 7 years ago

If a user creates a population but has not yet created a metamodel, .interactive_pairplot will fail with the following error message:

ValueErrorTraceback (most recent call last)
<ipython-input-15-125858ad74d2> in <module>()
----> 1 get_ipython().run_cell_magic(u'bql', u'', u'.interactive_pairplot --population=gapminder_population \nSELECT \n    life_expectancy, \n    mortality_kid,\n    continent,\n    physicians,\n    sanitation,\n    water_source\nFROM gapminder_table;')

/scratch/ulli/venv/local/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2113             magic_arg_s = self.var_expand(line, stack_depth)
   2114             with self.builtin_trap:
-> 2115                 result = fn(magic_arg_s, cell)
   2116             return result
   2117 

/scratch/ulli/venv/local/lib/python2.7/site-packages/iventure/magics.pyc in logged_cell_wrapper(self, line, cell)
    166             raw = self._retrieve_raw(line, cell)
    167             try:
--> 168                 output = func(self, line, cell)
    169             except:
    170                 exception = traceback.format_exc()

<decorator-gen-129> in bql(self, line, cell)

/scratch/ulli/venv/local/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

/scratch/ulli/venv/local/lib/python2.7/site-packages/iventure/magics.pyc in bql(self, line, cell)
    333                 continue
    334             if cmd.startswith('.'):
--> 335                 result = self._cmd(cmd)
    336             else:
    337                 result = self._bql([cmd])

/scratch/ulli/venv/local/lib/python2.7/site-packages/iventure/magics.pyc in _cmd(self, cmd, sql)
    378                 args = str.replace(args, m, '')
    379             args = str.strip(args)
--> 380             return self._PLTS[dot_command](self, args, sql=sql, **kwargs)
    381         else:
    382             sys.stderr.write('Unknown command: %s\n' % (dot_command,))

/scratch/ulli/venv/local/lib/python2.7/site-packages/iventure/magics.pyc in _cmd_interactive_pairplot(self, query, sql, **kwargs)
    524         c = self._bdb.sql_execute(query) if sql else self._bdb.execute(query)
    525         df = utils_bql.cursor_to_df(c)
--> 526         schema = utils_mml.get_schema_as_list(self._bdb, population)
    527         return jsviz.interactive_pairplot(df, schema)
    528 

/scratch/ulli/venv/local/lib/python2.7/site-packages/iventure/utils_mml.pyc in get_schema_as_list(bdb, population_name)
    102     generator_ids = bayesdb_population_generators(bdb, population_id)
    103     if len(generator_ids) == 0:
--> 104         raise ValueError('At least 1 metamodel required in population.')
    105     generator_id = generator_ids[0]
    106     variable_names = bayesdb_variable_names(bdb, population_id, None)

ValueError: At least 1 metamodel required in population.

This error was caused by running the following code:

%%bql
.interactive_pairplot --population=gapminder_population 
SELECT 
    life_expectancy, 
    mortality_kid,
    continent,
    physicians,
    sanitation,
    water_source
FROM gapminder_table;

Temporary workaround: create metamodel.