erdogant / bnlearn

Python package for Causal Discovery by learning the graphical structure of Bayesian networks. Structure Learning, Parameter Learning, Inferences, Sampling methods.
https://erdogant.github.io/bnlearn
Other
482 stars 46 forks source link

wget is not maintained and results in weird errors #73

Closed adam2392 closed 1 year ago

adam2392 commented 1 year ago

Hi,

Thanks for this package wrapping bnlearn R. I am using this to import datasets and I get the following error on circleCI cuz I'm running a CI pipeline:

Unexpected failing examples:
/home/circleci/project/examples/plot_psifci_alg.py failed leaving traceback:
Traceback (most recent call last):
  File "/home/circleci/project/examples/plot_psifci_alg.py", line 64, in <module>
    ground_truth_dag = bnlearn.import_DAG("sachs", verbose=False)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/bnlearn/bnlearn.py", line 1358, in import_DAG
    PATH_TO_DATA = _download_example(filepath, verbose=3)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/bnlearn/bnlearn.py", line 1311, in _download_example
    wget.download(url, curpath)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/wget.py", line 526, in download
    (tmpfile, headers) = ulib.urlretrieve(binurl, tmpfile, callback)
  File "/home/circleci/.pyenv/versions/3.8.16/lib/python3.8/urllib/request.py", line 273, in urlretrieve
    reporthook(blocknum, bs, size)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/wget.py", line 513, in callback_charged
    callback_progress(blocks, block_size, total_size, bar_function=bar)
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/wget.py", line 461, in callback_progress
    width = min(100, get_console_width())
  File "/home/circleci/.cache/pypoetry/virtualenvs/dodiscover-3aSsmiER-py3.8/lib/python3.8/site-packages/wget.py", line 337, in get_console_width
    ioctl(sys.stdout.fileno(), TIOCGWINSZ, winsize)
AttributeError: '_LoggingTee' object has no attribute 'fileno'

I tracked this down, but basically wget does not look like it is maintained anymore. How would you feel about switching to pooch? https://www.fatiando.org/pooch/latest/

erdogant commented 1 year ago

True. I agree and I will replace it with some basic core functionality of python itself. Thank you for mentioning.

erdogant commented 1 year ago

I replaced wget and created a new release. update with: pip install -U bnlearn

adam2392 commented 1 year ago

Cool! works now without the errors.

erdogant commented 1 year ago

👍🏻