spacepy / dbprocessing

Automated processing controller for heliophysics data
5 stars 4 forks source link

Cryptic error running on empty database should be improved #43

Open balarsen opened 3 years ago

balarsen commented 3 years ago

(The Brian breaking stuff begins...)

When ProcessQueue.py is run on an empty database the message is really cryptic.

Minimal example to reproduce issue:

$ ~/dbUtils/CreateDB.py hope_final.sqlite
$ ~/dbUtils/ProcessQueue.py -i -m hope_final.sqlite

Error message/Traceback:

Traceback (most recent call last):
  File "/home/ectsoc/dbUtils/ProcessQueue.py", line 95, in <module>
    pq.dbu.startLogging()
  File "/home/ectsoc/.local/lib/python2.7/site-packages/dbprocessing/DButils.py", line 268, in startLogging
    self.session.query(self.Mission.mission_id).first()[0],
TypeError: 'NoneType' object has no attribute '__getitem__'

OS, Python version, and dependency version information:

Linux-3.10.0-957.12.2.el7.x86_64-x86_64-with-centos-7.8.2003-Core
sys.version_info(major=2, minor=7, micro=15, releaselevel='final', serial=0)
sqlalchemy=1.2.15

Version of dbprocessing

36b441db80d2bf5f6bf1ea3d111304edea56571b

Closure condition

This issue should be closed when the error message says something closer to "empty database"

jtniehof commented 3 years ago

Ah, you're talking empty, not nonexistent (which was my first thought). I think this problem is consistent across database backends so doesn't have to wait for #14. It sort of relates to #7 where there should be some basic db structure checks when DButils is instantiated.

balarsen commented 3 years ago

Ah, you're talking empty, not nonexistent (which was my first thought). I think this problem is consistent across database backends so doesn't have to wait for #14. It sort of relates to #7 where there should be some basic db structure checks when DButils is instantiated.

Yeah the nonexistent seems good

$ ~/dbUtils/ProcessQueue.py -i -m asjkdhakhjds
Traceback (most recent call last):
  File "/home/ectsoc/dbUtils/ProcessQueue.py", line 78, in <module>
    pq = dbprocessing.ProcessQueue(options.mission, dryrun=options.dryrun, echo=options.echo)
  File "/home/ectsoc/.local/lib/python2.7/site-packages/dbprocessing/dbprocessing.py", line 44, in __init__
    dbu = DButils.DButils(self.mission, echo=echo)
  File "/home/ectsoc/.local/lib/python2.7/site-packages/dbprocessing/DButils.py", line 89, in __init__
    self.openDB(db_var=db_var, engine=engine, echo=echo)
  File "/home/ectsoc/.local/lib/python2.7/site-packages/dbprocessing/DButils.py", line 150, in openDB
    raise (ValueError("DB file specified doesn't exist"))

ValueError: DB file specified doesn't exist
jtniehof commented 3 years ago

I've been bitten before too many times by sqlite assuming if the file doesn't exist I just want to go ahead and start from scratch :)