Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError when running oapi.get_structures_with_sets([1]) #2684

Open
pderdeyn opened this issue May 25, 2023 · 1 comment
Open

JSONDecodeError when running oapi.get_structures_with_sets([1]) #2684

pderdeyn opened this issue May 25, 2023 · 1 comment
Labels

Comments

@pderdeyn
Copy link

Describe the bug
I want to load a structure graph using the OntologiesApi from AllenSDK. I've used this code in the past perfectly fine and have not updated this conda environment since the last time I ran it. Today, I am getting JSONDecodeError. Perhaps this is an API issue?

To Reproduce

from allensdk.api.queries.ontologies_api import OntologiesApi
oapi = OntologiesApi()
structure_graph = oapi.get_structures_with_sets([1])

Expected behavior
structure_graph should successfully load in the proper set of structures

Actual Behavior


JSONDecodeError                           Traceback (most recent call last)
<ipython-input-1-082887841e6e> in <module>
      1 from allensdk.api.queries.ontologies_api import OntologiesApi
      2 oapi = OntologiesApi()
----> 3 structure_graph = oapi.get_structures_with_sets([1])

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/cache.py in w(*args, **kwargs)
    607             result = Cache.cacher(func,
    608                                   *args,
--> 609                                   **kwargs)
    610             return result
    611 

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/cache.py in cacher(fn, *args, **kwargs)
    332 
    333         if strategy == 'pass_through':
--> 334                 data = fn(*args, **kwargs)
    335         elif strategy in ['create']:
    336             Manifest.safe_make_parent_dirs(path)

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/queries/ontologies_api.py in get_structures_with_sets(self, structure_graph_ids, order, num_rows, count, **kwargs)
    236                                    graph_ids=structure_graph_ids,
    237                                    order=order, num_rows=num_rows,
--> 238                                    count=count)
    239 
    240 

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/queries/rma_template.py in template_query(self, template_name, entry_name, **kwargs)
    130         query_args.update(kwargs)
    131 
--> 132         data = self.model_query(**query_args)
    133 
    134         return data

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/queries/rma_api.py in model_query(self, *args, **kwargs)
    257         return self.json_msg_query(
    258             self.build_query_url(
--> 259                 self.model_stage(*args, **kwargs)))
    260 
    261     def service_query(self, *args, **kwargs):

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/api.py in json_msg_query(self, url, dataframe)
    163 
    164         data = self.do_query(lambda *a, **k: url,
--> 165                              self.read_data)
    166 
    167         if dataframe is True:

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/api.py in do_query(self, url_builder_fn, json_traversal_fn, *args, **kwargs)
    202         post = kwargs.get('post', False)
    203 
--> 204         json_parsed_data = self.retrieve_parsed_json_over_http(api_url, post)
    205 
    206         return json_traversal_fn(json_parsed_data)

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/api/api.py in retrieve_parsed_json_over_http(self, url, post)
    369             data = json_utilities.read_url_get(
    370                 requests.utils.quote(url,
--> 371                                      ';/?:@&=+$,'))
    372         else:
    373             data = json_utilities.read_url_post(url)

~/anaconda2/envs/pieter/lib/python3.7/site-packages/allensdk/core/json_utilities.py in read_url_get(url)
    110     json_string = response.read().decode('utf-8')
    111 
--> 112     return json.loads(json_string)
    113 
    114 



~/anaconda2/envs/pieter/lib/python3.7/site-packages/simplejson/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
    523             parse_constant is None and object_pairs_hook is None
    524             and not use_decimal and not kw):
--> 525         return _default_decoder.decode(s)
    526     if cls is None:
    527         cls = JSONDecoder

~/anaconda2/envs/pieter/lib/python3.7/site-packages/simplejson/decoder.py in decode(self, s, _w, _PY3)
    368         if _PY3 and isinstance(s, bytes):
    369             s = str(s, self.encoding)
--> 370         obj, end = self.raw_decode(s)
    371         end = _w(s, end).end()
    372         if end != len(s):

~/anaconda2/envs/pieter/lib/python3.7/site-packages/simplejson/decoder.py in raw_decode(self, s, idx, _w, _PY3)
    398             elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
    399                 idx += 3
--> 400         return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Environment (please complete the following information):

  • Ubuntu 18.04.5 LTS
  • Python 3.7.4
  • allensdk 1.1.1
@pderdeyn pderdeyn added the bug label May 25, 2023
@pderdeyn
Copy link
Author

Today it is working. I restarted my jupyter notebook and the exact same code was able to run. Not sure what was causing the issue. I'll leave the bug open for y'all to categorize and record according to your process, if you'd like to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant