libpysal icon indicating copy to clipboard operation
libpysal copied to clipboard

libpysal calling web requests at module import (not working behind a corporate proxy, thus slowing process)

Open tgrandje opened this issue 1 year ago • 1 comments

I just updated libpysal in a old project (this was long overdue). I'm now encountering a (very) long loading of the package, which is linked to :

  • me working behind a corporate proxy;
  • the examples module still being loaded at import, notwithstanding this closed issue; to be accurate, it may not be loaded (I didn't check), but a web query is still called to update the available_datasets.

I added a raised exception in my examples/remotes.py (on poll_remotes) to identify the culprit. The traceback is the following:

Traceback (most recent call last):

  File "my_path/commons.py", line 11, in <module>
    from libpysal.cg.voronoi import voronoi_frames

  File "/my_other_path/.cache/pypoetry/virtualenvs/venv-ire-Z5e797_--py3.9/lib/python3.9/site-packages/libpysal/__init__.py", line 26, in <module>
    from . import examples

  File "/my_other_path/.cache/pypoetry/virtualenvs/venv-ire-Z5e797_--py3.9/lib/python3.9/site-packages/libpysal/examples/__init__.py", line 18, in <module>
    available_datasets.update(remote_datasets.datasets)

  File "/my_other_path/.cache/pypoetry/virtualenvs/venv-ire-Z5e797_--py3.9/lib/python3.9/site-packages/libpysal/examples/remotes.py", line 108, in datasets
    self._datasets = poll_remotes()

  File "/my_other_path/.cache/pypoetry/virtualenvs/venv-ire-Z5e797_--py3.9/lib/python3.9/site-packages/libpysal/examples/remotes.py", line 21, in poll_remotes
    raise Exception('Dummy')   # <-- this is my custom exception being raised

I'm not sure how to proceed on this (I'm not using the examples of the package): should'nt these requests being stored in the fetch_all function (for instance) ?

  • Platform information: posix linux posix.uname_result(sysname='Linux', nodename='siddee', release='5.4.0-131-generic', version='#147~18.04.1-Ubuntu SMP Sat Oct 15 13:10:18 UTC 2022', machine='x86_64')
  • Python version: 3.9.6 (default, Jun 29 2021, 12:40:25) [GCC 7.5.0]
  • SciPy version: 1.9.3
  • NumPy version: 1.23.5

tgrandje avatar Mar 09 '23 08:03 tgrandje

xref https://github.com/pysal/libpysal/issues/734

sjsrey avatar May 27 '23 15:05 sjsrey