Closed j-berg closed 2 months ago
Thanks for the extensive issue! We have had quite some issues with making everything M1 chip compatible. In fact partly because of that we transitioned form tensorflow to pytorch (since 2.0). However, I was not aware that there were also installation issues with pytorch on M1.
Until recent it was impossible to automatically test installing on macos + M1 chip using github actions. However, I think they have released that earlier this year, so I will try to implement that. If I get that up and running I will add this to the readme and change recommended python version to 3.11.
Trying to implement in #221 based on https://github.com/actions/runner-images/issues/9254
Weirdly enough the python 3.11 seems to fail for me now... Did your tests run correctly for the installation? @j-berg
Yeah, while all dependencies installed, I have been running into some finicky behavior downstream. I am trying to run:
from matchms import calculate_scores
from matchms.importing import load_from_msp
from ms2deepscore import MS2DeepScore
from ms2deepscore.models import load_model
# Import data
references = load_from_msp("./GNPS-LIBRARY.msp")
queries = load_from_msp("./ms2_spectra.msp")
# Load pretrained model
model = load_model("./ms2deepscore_model.pt")
similarity_measure = MS2DeepScore(model)
# Calculate scores and get matchms.Scores object
scores = calculate_scores(references, queries, similarity_measure)
But I am having some issues with the msp file formatting. I wasn't sure if that was just my input files though since some of them are custom generated. I'm currently trying to resolve and will let you know if I figure out a solution.
I ran the tests and they seemed to work fine in my Python 3.11 environment (from what i can tell, just warnings but no errors):
(ms2deepscore) jberg@Jordans-Laptop ms2deepscore-2.0.0 % pytest
================================================= test session starts ==================================================
platform darwin -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
rootdir: /Users/jberg/repositories/ms2deepscore-2.0.0
plugins: anyio-4.2.0
collected 106 items
tests/test_MetadataFeatureGenerator.py .......... [ 9%]
tests/test_SettingsMS2deepscore.py ..... [ 14%]
tests/test_calculate_tanimoto_scores_for_plotting.py ... [ 16%]
tests/test_data_generators.py ..... [ 21%]
tests/test_embedding_evaluator.py ........ [ 29%]
tests/test_loss_functions.py ......... [ 37%]
tests/test_ms2deepscore.py .... [ 41%]
tests/test_ms2deepscore_evaluated.py ... [ 44%]
tests/test_ms2deepscoremontecarlo.py .... [ 48%]
tests/test_plotting.py ...... [ 53%]
tests/test_plotting_wrapper_functions.py .. [ 55%]
tests/test_siamese_spectra_model.py .... [ 59%]
tests/test_spectrum_pair_selection.py .............. [ 72%]
tests/test_train_ms2deepscore.py .. [ 74%]
tests/test_training_wrapper_function.py . [ 75%]
tests/test_utils.py .. [ 77%]
tests/test_validation_and_test_split.py ... [ 80%]
tests/test_validation_loss_calculator.py .. [ 82%]
tests/test_vector_operations.py ................... [100%]
=================================================== warnings summary ===================================================
../../miniconda3/envs/ms2deepscore/lib/python3.11/site-packages/sparsestack/StackedSparseArray.py:4
/Users/jberg/miniconda3/envs/ms2deepscore/lib/python3.11/site-packages/sparsestack/StackedSparseArray.py:4: DeprecationWarning: Please use `get_index_dtype` from the `scipy.sparse` namespace, the `scipy.sparse.sputils` namespace is deprecated.
from scipy.sparse.sputils import get_index_dtype
tests/test_data_generators.py::test_DataGeneratorPytorch
tests/test_data_generators.py::test_generator_initialization
tests/test_data_generators.py::test_batch_generation
tests/test_data_generators.py::test_epoch_end_functionality
tests/test_embedding_evaluator.py::test_train_embedding_evaluator
tests/test_train_ms2deepscore.py::test_train_ms2ds_model
tests/test_train_ms2deepscore.py::test_too_little_spectra
/Users/jberg/miniconda3/envs/ms2deepscore/lib/python3.11/site-packages/matchms/Metadata.py:124: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
metadata_filtered = {k:v for k,v in metadata_filtered.items() if v not in invalid_entries}
tests/test_embedding_evaluator.py::test_train_embedding_evaluator
/Users/jberg/repositories/ms2deepscore-2.0.0/ms2deepscore/models/EmbeddingEvaluatorModel.py:157: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
evaluations = self(torch.tensor(embeddings).reshape(-1, 1, embedding_dim).to(device, dtype=torch.float32))
tests/test_training_wrapper_function.py::test_train_wrapper_ms2ds_model
/Users/jberg/repositories/ms2deepscore-2.0.0/ms2deepscore/benchmarking/plot_stacked_histogram.py:95: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
_, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, nr_of_bins),
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================== 106 passed, 10 warnings in 22.60s ===========================================
Hi all,
I don't know if this is just occurring on my machine, but just wanted to make you aware of an issue I came across trying to install m2deepscore on my M1 mac.
What doesn't work
README environment install method # 1
README environment install method # 3
README environment install method # 1 with no Python version specified
A slightly different error:
Along with several other combinations.
What does work
README environment install method # 1 with Python == 3.11
python3.11_environment.yml
No set Python version (v3.12 works here) and a custom
setup.py
And then I specifically need to download the repository (@v2.0.0) and remove any forced versioning for dependencies:
And then install via:
pip install .
(from within the local copy of the repo). I've attached the exported conda environment from my working setup: python3.12_environment.yml Although this method leads to issues later with numpy compilation asmatchms
is also forcing certain versions of dependencies.Conclusion
It seems like the environment is very sensitive to different forced version requirements on certain dependencies.