Search code examples
pythonpandasbottlepytables

Pandas reading HDFStore in Bottle - DeprecationWarning?


I am attempting to read a few Pandas created HDF5 files in a simple web application using Bottle. In doing so, I'm receiving a DeprecationWarning when reading an HDFStore that was created outside of the Bottle app server.

Environment:

  • OSX: 10.9.4
  • Python: 2.7.8 (homebrew)
  • pandas: 0.14.1
  • Bottle: 0.12.7
  • tables: 3.1.1

Here's a working example that illustrates the issue:

test-pandas.py

import pandas as pd
import numpy as np

df1 = pd.DataFrame(np.random.randn(20, 5),columns=['a', 'b', 'c', 'd', 'e'])
df1.to_hdf('/tmp/df.hdf',key='dfkey',format='table',append=False,complib='blosc',complevel=9)

Then in another file, we have:

test-bottle.py

import pandas as pd
import bottle as bt

app = bt.Bottle()
@app.route('/test')
def test():
    bt.response.set_header("Content-Type","application/json")
    df2 = pd.read_hdf('/tmp/df.hdf','dfkey')
    return df2.to_json(orient='split')

app.run(host='localhost', port=8080, debug=True)

Run the server via python test-bottle.py, and then point a browser to http://localhost:8080/test. Bottle spits out the following debug data:

Bottle v0.12.7 server starting up (using WSGIRefServer())...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.

/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py:533: DeprecationWarning: openFile() is pending deprecation, use open_file() instead. You may use the pt2to3 tool to update your source code.
  self._handle = tables.openFile(self._path, self._mode, **kwargs)
/usr/local/lib/python2.7/site-packages/pandas/io/pytables.py:1041: DeprecationWarning: getNode() is pending deprecation, use get_node() instead. You may use the pt2to3 tool to update your source code.
  return self._handle.getNode(self.root, key)
127.0.0.1 - - [16/Sep/2014 09:04:31] "GET /test HTTP/1.1" 200 1481

However, if you were to originally write the HDFStore within the same python source file as the bottle app, test-bottle.py, no deprecation warning appears. Is this a bug? If not, what exactly is happening here?


Solution

  • you don't normally run with DeprecationWarning enabled. In any event this is an innocuous warning from PyTables that the API changed (in 3.0.0) and eventually be changed.

    Pandas 0.15.0 (1 month or so for release) will use the new API and remove the warning.