Sage-Bionetworks / synapser

An R package providing programmatic access to Synapse
Apache License 2.0
32 stars 21 forks source link

Possibly numpy2.0 issue? #334

Open sgosline opened 2 months ago

sgosline commented 2 months ago

Operating system

Docker container running - r-base:4.3.2 (so, ubuntu, but docker is running on Mac)

Description of the problem

When I load synapser and then reticulate, I get an error trying to use reticulate that looks a lot like the numpy2.0 compatibility issue that just came out:

Error in py_run_file_impl(file, local, convert) : 
  ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Run `reticulate::py_last_error()` for details.

However, when I run the same command without loading synapser, I get no such error.

Expected behavior

My docker container build explicitly calls out numpy==1.26.4, so I should get no error. My only suspicion is that synapser causes another numpy to be loaded.

Actual behavior

However, when I load synapser I get an error, suggesting that numpy2.0 is being installed somewhere.

Error in py_run_file_impl(file, local, convert) : 
  ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Run `reticulate::py_last_error()` for details.

Output of sessionInfo()

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-unknown-linux-gnu (64-bit)
Running under: Debian GNU/Linux trixie/sid

Matrix products: default
BLAS:   /usr/lib/aarch64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/aarch64-linux-gnu/openblas-pthread/libopenblasp-r0.3.25.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tidyr_1.3.1        synapser_2.0.0.200 reticulate_1.38.0  stringr_1.5.1     
[5] dplyr_1.1.4        data.table_1.15.4 

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5      cli_3.6.3        rlang_1.1.4      stringi_1.8.4   
 [5] purrr_1.0.2      png_0.1-8        generics_0.1.3   jsonlite_1.8.8  
 [9] glue_1.7.0       rjson_0.2.21     rprojroot_2.0.4  fansi_1.0.6     
[13] grid_4.3.2       tibble_3.2.1     lifecycle_1.0.4  compiler_4.3.2  
[17] codetools_0.2-19 Rcpp_1.0.12      pkgconfig_2.0.3  here_1.0.1      
[21] lattice_0.22-5   R6_2.5.1         tidyselect_1.2.1 utf8_1.2.4      
[25] pillar_1.9.0     magrittr_2.0.3   Matrix_1.6-5     tools_4.3.2     
sgosline commented 2 months ago

I should say that the error is not when i run python code, just when I load. The three commands in R that prompt this error are:

library(reticulate)
use_python("/opt/venv/bin/python3", required = TRUE)
source_python("pubchem_retrieval.py")
thomasyu888 commented 2 months ago

Good to see you here @sgosline !

We actually have a fix for this issue in the upcoming release which should be coming out very soon

Hopefully next 2 weeks. Sorry about that!

sgosline commented 2 months ago

Thanks @thomasyu888 I'm glad I'm not hallucinating. I tried loading packages in all sorts of orders. Thanks for letting me know.

danlu1 commented 2 months ago

Thanks for flagging @sgosline . To resolve the issue, please pin Numpy to version 1.24.4. As Tom said, we already had a fix that would be included in the upcoming release.

sgosline commented 2 months ago

Sorry I wasn’t clear in my original post. The above problem exists when i fixed my numpy version, which is why the issue is so confounding.

On Jul 15, 2024, at 11:30 AM, Dan Lu @.***> wrote:

 Check twice before you click! This email originated from outside PNNL.

Thanks for flagging @sgoslinehttps://github.com/sgosline . To resolve the issue, please pin Numpy to version 1.24.4. As Tom said, we already had a fix that would be included in the upcoming release.

— Reply to this email directly, view it on GitHubhttps://github.com/Sage-Bionetworks/synapser/issues/334#issuecomment-2229130263, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAODEORU6F3VLHBDEOYHUM3ZMQIKRAVCNFSM6AAAAABKXZDPHKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRZGEZTAMRWGM. You are receiving this because you were mentioned.Message ID: @.***>

thomasyu888 commented 1 month ago

The newer release should available soon, but it is in staging if you wanted to take a look.

install.packages("synapser", repos=c("http://staging-ran.synapse.org"))

sgosline commented 1 month ago

OK, i'll wait until it's stable, then update my docker images. I dont want the images to point to staging....

thomasyu888 commented 2 weeks ago

Thanks for the wait @sgosline . The new version of synapser should be available for you to install and should also work with the newer versions of R (4.4.1), let us know if you run into any issues.