pybliometrics-dev / pybliometrics

Python-based API-Wrapper to access Scopus
https://pybliometrics.readthedocs.io/en/stable/
Other
407 stars 127 forks source link

Scopus authentication functions inconsistely across Mac and Linux systems #283

Closed poldrack closed 1 year ago

poldrack commented 1 year ago

pybliometrics version: 3.4.0 (on both systems)

Code to reproduce the bug:

git clone https://github.com/poldrack/academicdb.git
cd academicdb
pip install .
make test

Expected behavior:

When the same tests are run on my mac (MacOS 13.2.1), using the same version of pybliometrics and the same API key (confirmed same contents of ~/.pybliometrics/config.ini:Authentication:APIKey) on the same home network (with no VPN or proxy set on either AFAIK, and same external IP address according to https://whatismyipaddress.com/) , I get the following:

=========================== short test summary info ============================
FAILED src/test/test_query_scopus.py::test_single_record_returned - pybliometrics.scopus.exception.Scopus401Error: The requestor is not authori...
FAILED src/test/test_researcher.py::test_get_publications - pybliometrics.scopus.exception.Scopus401Error: The requestor is not authori...
FAILED src/test/test_researcher.py::test_get_coauthors - pybliometrics.scopus.exception.Scopus401Error: The requestor is not authori...
ERROR src/test/test_converters.py::test_scopus_converter - pybliometrics.scopus.exception.Scopus401Error: The requestor is not authori...
============== 3 failed, 23 passed, 5 warnings, 1 error in 18.24s ==============
make: *** [test] Error 1
poldrack commented 1 year ago

Note: The tests require a MongoDB instance to be running locally...

Michael-E-Rose commented 1 year ago

Very strange. The only idea I have is that on Mac the API key is not loaded properly.

Could you please verify that

from pybliometrics.scopus.utils.startup import KEYS
print(KEYS)

is not empty?

poldrack commented 1 year ago

thanks - KEYS is not empty on the Mac:

In [1]: from pybliometrics.scopus.utils.startup import KEYS
   ...: print(KEYS)
['65...04']

and contents match those on my linux box.

poldrack commented 1 year ago

I also tried creating a new API key and testing that - same problem.

poldrack commented 1 year ago

Update: I tried running the same code within a docker container on both the Mac and the linux system. I get the same Scopus401 errors in the docker container on each of those machines using the key that still works properly within a shell on the linux system.

poldrack commented 1 year ago

OK, figured it out: The apparent success on my linux box was due to the fact that it was using the cached results. when I moved the original .pybliometrics directory then it failed as the other machines did. Not sure what's up with my scopus key, but at least this doesn't seem to be a pybliometrics problem so I'm closing this.

Michael-E-Rose commented 1 year ago

Glad you found the cause!

I should have asked earlier whether the conditions to access Scopus were the same on both machines.

This documentation might help with your software: https://pybliometrics.readthedocs.io/en/stable/access.html

poldrack commented 1 year ago

Thanks - I hadn't realized that the results of previous searches were cached in the .pybliometrics folder, might be worth adding a note about that to the docs.

On Sun, Apr 2, 2023 at 2:41 AM Michael E. Rose @.***> wrote:

Glad you found the cause!

I should have asked earlier whether the conditions to access Scopus were the same on both machines.

This documentation might help with your software: https://pybliometrics.readthedocs.io/en/stable/access.html

— Reply to this email directly, view it on GitHub https://github.com/pybliometrics-dev/pybliometrics/issues/283#issuecomment-1493280650, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUVEFBYB3P42X5W2PJE2LW7FCTBANCNFSM6AAAAAAWPXPSKQ . You are receiving this because you modified the open/close state.Message ID: @.***>

-- Russell A. Poldrack Albert Ray Lang Professor of Psychology Associate Director, Stanford Data Science Director, SDS Center for Open and Reproducible Science Building 420 Stanford University Stanford, CA 94305

@. @.> http://www.poldracklab.org/

Michael-E-Rose commented 1 year ago

might be worth adding a note about that to the docs

Where would you expect that? Because it's described at the end of each class, in the configuration page as well as a special section in Tips .

poldrack commented 1 year ago

thanks, that seems fine, I just need to read better :-)

On Sun, Apr 2, 2023 at 8:10 AM Michael E. Rose @.***> wrote:

might be worth adding a note about that to the docs

Where would you expect that? Because it's described at the end of each class, in the configuration page https://pybliometrics.readthedocs.io/en/stable/configuration.html as well as a special section in Tips https://pybliometrics.readthedocs.io/en/stable/tips.html#database-updates .

— Reply to this email directly, view it on GitHub https://github.com/pybliometrics-dev/pybliometrics/issues/283#issuecomment-1493368512, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUVEF6LY7IOVE6PAFT6ULW7GJG5ANCNFSM6AAAAAAWPXPSKQ . You are receiving this because you modified the open/close state.Message ID: @.***>

-- Russell A. Poldrack Albert Ray Lang Professor of Psychology Associate Director, Stanford Data Science Director, SDS Center for Open and Reproducible Science Building 420 Stanford University Stanford, CA 94305

@. @.> http://www.poldracklab.org/