Fabien,
Thanks for the patch. I've opened a PR applying it in
. I'm thinking we might
want to eventually refactor a little and add more general support for
Decimal serialization, perhaps in the 'safe_dumps' machinery in
galaxy.util.json, but this looks good to me for now.
On Tue, Mar 8, 2016 at 12:42 PM, Fabien Mareuil <fmareuil(a)pasteur.fr> wrote:
Hi Dannon,
I got this error with a detail view (/api/quotas/f597429621d6eb2b) when
the quota has associated users with a disk usage different of 0,
total_disk_usage in the user dictionary is a Decimal object and is not
serializable.
I worked on it this afternoon, it's possible to correct it just by adding
the key 'total_disk_usage' in the value_mapper of the show method of
QuotaAPIController class like the show method of UserAPIController class.
I join a patch for the quota.py file with this email
I can propose a pull request if you want.
Best,
--
Fabien Mareuil | Centre d'Informatique pour la Biologie
fabien.mareuil(a)pasteur.fr | Institut Pasteur
25,28 rue du Docteur Roux 75015 Paris, France
Le 08/03/2016 16:24, Dannon Baker a écrit :
Hi Fabien,
I'm having trouble reproducing this error on my side. In the trace it
looks like the error is being thrown at the collection view (/api/quotas)
and not the detail view (/api/quotas/f597429621d6eb2b or the like). Is
that true?
Can you show me the exact configuration of this quota in the admin panel?
On Tue, Mar 8, 2016 at 8:10 AM, Fabien Mareuil <fmareuil(a)pasteur.fr>
wrote:
> Hi,
>
> We got an error when we used API to see a quota detail, we get the
> following traceback:
>
> 157.99.60.167 - - [08/Mar/2016:10:13:58 +0200] "GET /api/quotas HTTP/1.1"
> 200 - "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0)
Gecko/20100101
> Firefox/44.0"
> galaxy.web.framework.decorators ERROR 2016-03-08 10:14:10,273 Uncaught
> exception in exposed API method:
> Traceback (most recent call last):
> File ".../lib/galaxy/web/framework/decorators.py", line 142, in
> decorator
> rval = dumps( rval, indent=4, sort_keys=True )
> File ".../lib/galaxy/util/json.py", line 65, in safe_dumps
> dumped = json.dumps( *args, allow_nan=False, **kwargs )
> File "/usr/lib64/python2.6/json/__init__.py", line 237, in dumps
> **kw).encode(obj)
> File "/usr/lib64/python2.6/json/encoder.py", line 367, in encode
> chunks = list(self.iterencode(o))
> File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode
> for chunk in self._iterencode_dict(o, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 275, in
> _iterencode_dict
> for chunk in self._iterencode(value, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 306, in _iterencode
> for chunk in self._iterencode_list(o, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 204, in
> _iterencode_list
> for chunk in self._iterencode(value, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode
> for chunk in self._iterencode_dict(o, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 275, in
> _iterencode_dict
> for chunk in self._iterencode(value, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 309, in _iterencode
> for chunk in self._iterencode_dict(o, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 275, in
> _iterencode_dict
> for chunk in self._iterencode(value, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 317, in _iterencode
> for chunk in self._iterencode_default(o, markers):
> File "/usr/lib64/python2.6/json/encoder.py", line 323, in
> _iterencode_default
> newobj = self.default(o)
> File "/usr/lib64/python2.6/json/encoder.py", line 344, in default
> raise TypeError(repr(o) + " is not JSON serializable")
> TypeError: Decimal('856488698767') is not JSON serializable
>
> json can't serialize Decimal object.
> I tested it with simplejson and it works.
> An other solution is to convert the Decimal object to a float before the
> dumps.
>
> Thanks a lot for your help
> Best regards,
>
> --
> Fabien Mareuil | Centre d'Informatique pour la Biologie
> fabien.mareuil(a)pasteur.fr | Institut Pasteur
> 25,28 rue du Docteur Roux 75015 Paris, France
>
>
> ___________________________________________________________
> Please keep all replies on the list by using "reply all"
> in your mail client. To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>
https://lists.galaxyproject.org/
>
> To search Galaxy mailing lists use the unified search at:
>
http://galaxyproject.org/search/mailinglists/
>