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

Unquote printed Allen API URL query in abagen.mouse #73

Closed
rmarkello opened this issue Aug 14, 2019 · 1 comment
Closed

Unquote printed Allen API URL query in abagen.mouse #73

rmarkello opened this issue Aug 14, 2019 · 1 comment
Labels
good first issue Good for newcomers refactor Not an enhancement, but not a bug

Comments

@rmarkello
Copy link
Owner

rmarkello commented Aug 14, 2019

The issue

The following code snippet highlights the undesirable behavior:

>>> from abagen import mouse
>>> info = mouse.get_structure_info(id=22, attributes='name', verbose=True)
'Querying https://api.brain-map.org/api/v2/data/Structure/query.json?criteria=%5Bid%24eq22%5D%2Contology%5Bid%24eq1%5D&only=name%2Cid&'
>>> info
                                    name
id                                      
22  Posterior parietal association areas

That URL printed by the call to mouse.get_structure_info() is "quoted" for the purposes of making the actual API query, but should be "unquoted" for printing purposes since it's almost entirely unreadable by the average person! The whole point of printing the query URL is to make sure that it's formatted correctly, but I can't tell if it's formatted correctly if I can barely read the thing.

Proposed solution

In abagen.mouse.utils, change L63 from:

        print("Querying {}...".format(url))

to

        print("Querying {}...".format(urllib.parse.unquote_plus(url)))

should do the trick! We only unquote for the purposes of printing the URL, but leave the actual URL quoted for the query.

@rmarkello rmarkello added good first issue Good for newcomers refactor Not an enhancement, but not a bug labels Aug 14, 2019
@4lovi4
Copy link
Contributor

4lovi4 commented Oct 19, 2020

Also assigned to issue. Here is the result:

Querying https://api.brain-map.org/api/v2/data/Structure/query.json?criteria=[id$eq22],ontology[id$eq1]&only=name,acronym,id&...

rmarkello added a commit that referenced this issue Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactor Not an enhancement, but not a bug
Projects
None yet
Development

No branches or pull requests

2 participants