dkirkby / bossdata

Tools for accessing SDSS BOSS data
MIT License
1 stars 3 forks source link

bossquery --verbose behavior #41

Closed dmargala closed 9 years ago

dmargala commented 9 years ago

A TypeError occurs when a query returns no results and the --verbose option is specified.

$ bossquery --where "PLATE < 0" --verbose
Database contains 2467000 rows.
Traceback (most recent call last):
  File "/Users/Daniel/anaconda/bin/bossquery", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/Users/Daniel/source/bossdata/bin/bossquery", line 73, in <module>
    main()
  File "/Users/Daniel/source/bossdata/bin/bossquery", line 50, in main
    print('Query returned {:d} rows.'.format(len(table)))
TypeError: object of type 'NoneType' has no len()

Without the verbose option, a message is displayed.

$ bossquery --where "PLATE < 0"
No rows found for this query.

But for a query that returns a result, no message:

$ bossquery --where "PLATE < 4000"

The TypeError should probably be fixed. The behavior without the --verbose option seems inconsistent to me.

belaa commented 9 years ago

I'm having a similar issue when going between lite and full versions. For example:

$ bossquery --what PLATE,MJD,FIBER --max-rows 5 --print

works fine, but

bossquery --full -what PLATE,MJD,FIBER --max-rows 5 --print

returns: No rows found for this query.

dmargala commented 9 years ago

Is there a typo in your second command? -what -> --what

Both seem to work fine for me.

$ bossquery --what PLATE,MJD,FIBER --max-rows 5 --print
PLATE  MJD  FIBER
----- ----- -----
 3586 55181    16
 3586 55181    18
 3586 55181    20
 3586 55181    32
 3586 55181    36
$ bossquery --full --what PLATE,MJD,FIBER --max-rows 5 --print
PLATE  MJD  FIBER
----- ----- -----
 3586 55181    16
 3586 55181    18
 3586 55181    20
 3586 55181    32
 3586 55181    36
belaa commented 9 years ago

I mistyped what I had originally written. This is what I had:

$ bossquery --full --what PLATE,MJD,FIBER --max-rows 5 --print
No rows found for this query.
dcunning11235 commented 9 years ago

Hmm, what is the file size of you full DB (filename spAll-v5_7_0.db)?

belaa commented 9 years ago

It's 22KB. I removed spAll-v5_7_0.db and spAll-v5_7_0.fits from my local directory since I'm assuming it was only partially downloaded. I re-ran the command with the --full option and it seems to be downloading now.

dkirkby commented 9 years ago

I just created #45 to address the problem that Bela had with a partially built database file, since this is separate from the subject of issue (which we still need to fix...)

dkirkby commented 9 years ago

I added a simple fix for this issue in PR #46

dkirkby commented 9 years ago

Fixed with PR #46