SciencerIO / sciencer-toolkit

A smarter way to find articles.
MIT License
9 stars 1 forks source link

KeyError: 'data' in semantic_scholar_provider.py line 151 #10

Closed RicardoEPRodrigues closed 2 years ago

RicardoEPRodrigues commented 2 years ago

An error was launched when running the examples/example_1_hello_world.py (I provided an API key, IDK if it is relevant). It seems the response did not have a "data" field.

Traceback (most recent call last):
  File "/home/ricardo/Documents/Projects/sciencer-toolkit/./examples/example_1_hello_world.py", line 77, in <module>
    first_batch = s.iterate(
  File "/home/ricardo/Documents/Projects/sciencer-toolkit/venv/lib/python3.9/site-packages/sciencer/core.py", line 249, in iterate
    paper_after_expansion.update(expander.execute(
  File "/home/ricardo/Documents/Projects/sciencer-toolkit/venv/lib/python3.9/site-packages/sciencer/expanders/expand_by_authors.py", line 32, in execute
    author_papers = provider.get_papers_by_author(author_id)
  File "/home/ricardo/Documents/Projects/sciencer-toolkit/venv/lib/python3.9/site-packages/sciencer/providers/semantic_scholar_provider.py", line 151, in get_papers_by_author
    paper_json) for paper_json in response_json["data"]])
KeyError: 'data'
ratuspro commented 2 years ago

@RicardoEPRodrigues I've not been able to reproduce the bug. Did it happen while running any of the examples? If not can you provide the code? Also, where you using any development branch?

RicardoEPRodrigues commented 2 years ago

Perhaps it might be a network error that is not being dealt with. It seems it is always assumed that there is going to be a "data" type in the response, but if not internet is available what happens?

ratuspro commented 2 years ago

We are not dealing with network errors yet (I'll handle it on the next release). Still, I believe the error you identified as nothing to do with network errors. Otherwise the response would be None. I'm gonna run some test to see what is happening.

ratuspro commented 2 years ago

Seems like @PipzCorreiaz also experienced this error.

ratuspro commented 2 years ago

Fixed on #13