BigDataBiology / SemiBin

SemiBin: metagenomics binning with self-supervised deep learning
https://semibin.rtfd.io/
115 stars 10 forks source link

Specifiy the numpy version #136

Closed shenwei356 closed 1 year ago

shenwei356 commented 1 year ago

Hi guys, you may need to update the meta.yaml in bioconda recipe to limit the numpy version, because the latest numpy (1.24) would cause an error:

2023-05-29 17:55:25,634 - Calculating depth matrix.
2023-05-29 17:56:16,993 - Edges:407419
Traceback (most recent call last):
  File "/home/shenwei/app/miniconda3/envs/semibin/bin/SemiBin", line 10, in <module>
    sys.exit(main())
  File "/home/shenwei/app/miniconda3/envs/semibin/lib/python3.9/site-packages/SemiBin/main.py", line 895, in main
    single_easy_binning(
  File "/home/shenwei/app/miniconda3/envs/semibin/lib/python3.9/site-packages/SemiBin/main.py", line 728, in single_easy_binning
    binning(logger, args.bams, args.num_process, data_path,
  File "/home/shenwei/app/miniconda3/envs/semibin/lib/python3.9/site-packages/SemiBin/main.py", line 669, in binning
    cluster(
  File "/home/shenwei/app/miniconda3/envs/semibin/lib/python3.9/site-packages/SemiBin/cluster.py", line 97, in cluster
    contig_labels = np.zeros(shape=(len(matrix)), dtype=np.int)
  File "/home/shenwei/app/miniconda3/envs/semibin/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

https://github.com/WongKinYiu/yolov7/issues/1280

This happens because you have installed the latest numpy version 1.24.0 where np.int is depreciated. Instead install a lower version of numpy pip install "numpy<1.24.0".

A current solution for users:

mamba install -c conda-forge numpy==1.23
luispedro commented 1 year ago

Thanks. That is a quick fix for current users, but the right fix is to specify the right type

@psj1997 : can you add a fix that's compatible for multiple versions?

luispedro commented 1 year ago

The underlying bug is actually that our testing is too limited. We should have tested a matrix of Python x NumPy and we'd have caught this (e.g., as is done here: https://github.com/luispedro/mahotas/blob/master/.github/workflows/test-python-package-with-conda.yml, but we probably don't need to go all the way back to Numpy 1.18). /cc @psj1997

luispedro commented 1 year ago

Hi @shenwei356

I had a look at this issue again and it seems that you are running a very old version of SemiBin?

Commit 25af575a2750865874c74d65138b8e786777919f (from Jan 2022) would have fixed this issue.

shenwei356 commented 1 year ago

Hmm, I'm not sure now :( I remember it was a fresh new installation with conda.

I can't access my PC remotely right now, and I'll check it next Monday.

shenwei356 commented 1 year ago

I'm sorry for the inconvenience. @luispedro You're right, it was an old version I installed before. I'm closing this issue.