Noble-Lab / casanovo

De Novo Mass Spectrometry Peptide Sequencing with a Transformer Model
https://casanovo.readthedocs.io
Apache License 2.0
90 stars 31 forks source link

Numpy release 2.0.0 breaks depthcharge dependency #339

Closed Lilferrit closed 1 week ago

Lilferrit commented 2 weeks ago

The casanovo installation process automatically installs the latest numpy release (2.0.0 at the time of writing) - however the depthcharge package seems to use numpy functionality that was depreciated in release 2.0.0. After installing the casanovo package and it's dependencies, running any of the casanovo cli commands will result in an error. A stacktrace is available below.

A workaround for this issue is to manually downgrade the installed numpy release after all of the casanovo dependencies are installed using:

pip install --force-reinstall numpy==1.26.4

Error stack trace (same error for all cli commands):

Traceback (most recent call last):
  File "D:\anaconda3\envs\casanovo_env\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\anaconda3\envs\casanovo_env\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\anaconda3\envs\casanovo_env\Scripts\casanovo.exe\__main__.py", line 4, in <module>
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\casanovo\casanovo.py", line 32, in <module>
    import depthcharge
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\depthcharge\__init__.py", line 3, in <module>
    from . import components
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\depthcharge\components\__init__.py", line 2, in <module>
    from .transformers import SpectrumEncoder, PeptideDecoder
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\depthcharge\components\transformers.py", line 8, in <module>
    from .. import utils
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\depthcharge\utils.py", line 5, in <module>
    from tensorboard.backend.event_processing.event_accumulator import (
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\backend\event_processing\event_accumulator.py", line 24, in <module>
    from tensorboard.backend.event_processing import event_file_loader
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\backend\event_processing\event_file_loader.py", line 21, in <module>
    from tensorboard import dataclass_compat
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\dataclass_compat.py", line 33, in <module>
    from tensorboard.plugins.hparams import metadata as hparams_metadata
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\plugins\hparams\metadata.py", line 32, in <module>
    NULL_TENSOR = tensor_util.make_tensor_proto(
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\util\tensor_util.py", line 405, in make_tensor_proto
    numpy_dtype = dtypes.as_dtype(nparray.dtype)
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py", line 677, in as_dtype
    if type_value.type == np.string_ or type_value.type == np.unicode_:
  File "D:\anaconda3\envs\casanovo_env\lib\site-packages\numpy\__init__.py", line 411, in __getattr__
    raise AttributeError(
AttributeError: `np.string_` was removed in the NumPy 2.0 release. Use `np.bytes_` instead.. Did you mean: 'strings'?
Lilferrit commented 2 weeks ago

This bug seems to break the testing pipeline as well.

bittremieux commented 1 week ago

Hotfix in #344, but NumPy should be upgraded to v2.0 after/during the new DepthCharge integration.