sivarajankumar / pygr

Automatically exported from code.google.com/p/pygr
0 stars 0 forks source link

KeyError on deleting pygr.Data resource #47

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Save a resource to pygr.Data with no SCHEMA
2. Delete the resource (i.e. via pygr.Data.deleteResource )

What is the expected output? What do you see instead?
Expected output is nothing.  We see a KeyError instead:

Traceback (most recent call last):
  File "/Users/Robby/pygr-dev/bin/python", line 23, in <module>
    execfile(sys.argv[0])
  File "/Users/Robby/Desktop/delete-resource-schema-error.py", line 32, in
<module>
    remRes()
  File "/Users/Robby/Desktop/delete-resource-schema-error.py", line 26, in
remRes
    pygr.Data.deleteResource(sqltab)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/p
ygr-0.7-py2.5-macosx-10.3-fat.egg/pygr/Data.py",
line 864, in deleteResource
    self.delSchema(id,layer)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/p
ygr-0.7-py2.5-macosx-10.3-fat.egg/pygr/Data.py",
line 1019, in delSchema
    d=db.getschema(id) # GET THE EXISTING SCHEMA
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/p
ygr-0.7-py2.5-macosx-10.3-fat.egg/pygr/Data.py",
line 536, in getschema
    return self.db['SCHEMA.'+id]
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/shelve.py", 
line
112, in __getitem__
    f = StringIO(self.dict[key])
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/bsddb/__init__.
py",
line 223, in __getitem__
    return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/bsddb/dbutils.p
y",
line 62, in DeadlockWrap
    return function(*_args, **_kwargs)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/bsddb/__init__.
py",
line 223, in <lambda>
    return _DeadlockWrap(lambda: self.db[key])  # self.db[key]
KeyError: 'SCHEMA.Bio.Seq.Genome.ECOLI'

What version of the product are you using? On what operating system?
Using MacOS v10.4 or v10.5
git commit # c42925322ab8258b40bd09fd9bf0c871c6ebf75a

Please provide any additional information below.
The pygr.Data resource does in fact get deleted but a call is made to
delSchema() with a pygr.Data resource id of 'SCHEMA.name.of.resource'.  If
no schema was ever saved, this resource will never exist and thus retrieval
via "d=db.getschema(id) # GET THE EXISTING SCHEMA" will always produce the
KeyError.

See attached script and modified ecoli 'genome' file to reproduce.

Original issue reported on code.google.com by robert.d...@gmail.com on 17 Oct 2008 at 11:22

Attachments:

GoogleCodeExporter commented 8 years ago
added try: except KeyError clause to handle this.  We should add a test to the 
test
suite.

Original comment by cjlee...@gmail.com on 6 Jan 2009 at 10:53

GoogleCodeExporter commented 8 years ago

Original comment by mare...@gmail.com on 21 Feb 2009 at 2:06

GoogleCodeExporter commented 8 years ago

Original comment by cjlee...@gmail.com on 5 Mar 2009 at 12:12

GoogleCodeExporter commented 8 years ago

Original comment by mare...@gmail.com on 12 Mar 2009 at 9:57

GoogleCodeExporter commented 8 years ago
To clarify: the fix has been verified.

Original comment by mare...@gmail.com on 12 Mar 2009 at 11:52