ersilia-os / ersilia

The Ersilia Model Hub, a repository of AI/ML models for infectious and neglected disease research.
https://ersilia.io
GNU General Public License v3.0
203 stars 131 forks source link

🐛 Bug: eos5qfo - Predict Error: products #371

Closed Chigoziee closed 1 year ago

Chigoziee commented 1 year ago

Describe the bug.

I successfully fetched and serve my model 'eos5qfo' but when i tried to test it using the 'eml_canonical.csv' test dataset it was stuck in a loop for a very long time. i restarted my CL and my internet connection but that did not seem to help. during fetching the model, it took a lot of time so i assumed it was one of those large models and that it would take time to finish predictions so i decided to test in on a smaller data. i tested it on "CCCCC" and "CN(C)CCC=C1c2ccccc2CCc3ccccc13" and they gave me an AssertionError in the log. eos5qfo_predict_log.log

Describe the steps to reproduce the behavior

No response

Expected behavior.

No response

Screenshots.

No response

Operating environment

windows 10 WLS ubuntu 20.04

Additional context

No response

GemmaTuron commented 1 year ago

Hi @Chigoziee

Thanks, this is helpful. The error is due to the input format type, which requires two molecules, you can check the Ersilia Model Hub website and read what is this model doing Utilizes a Weisfeiler-Lehman network (attentive mechanism) to predict the products of an organic reaction given the reactants. The model identifies the reaction centers (set of atoms/bonds that change from reactant to product) and obtains the products directly from a graph-based neural network. It sounds complex, but the key part here is Predict the products of an organic reaction given the reactants This means you need to pass TWO Molecules or two lists of molecules. Read more about it here: https://ersilia.gitbook.io/ersilia-book/ersilia-model-hub/inputs

Let me link here @mamabear25 for issue #367 as she is getting problems in fetching the model

Chigoziee commented 1 year ago

Hi @GemmaTuron i created a csv called "test" with two inputs and tested it with the model, this gave me a "KeyError: 'products'" error, i have attached the test input data and also the log eos5qfo_log.log test.csv

GemmaTuron commented 1 year ago

Hi @Chigoziee !

Thanks for the test. Two things:

  1. MY FAULT: I gave you the wrong input format. A trick we have in the Hub is to automatically generate a template with the shape that the model needs, the command is: ersilia example eos5qfo -n 1 -f myexample.csv (it will create a my example file). You will see SMILES separated by a .
  2. BAD NEWS: the correct input file still fails with same error We will have a look at this. Please change the issue title to: "eos5qfo - Predict Error: products" And mark it in the excel file
Chigoziee commented 1 year ago

Done

DhanshreeA commented 1 year ago

I am able to reproduce this error even by generating an example file in the correct input format as suggested by @GemmaTuron. This is similar to the issue I am facing while trying to run the generate API in the recently incorporated model eos4q1a

DhanshreeA commented 1 year ago

Hi @GemmaTuron and @miquelduranfrigola!

I have been debugging this for a while and here are my findings so far:

DhanshreeA commented 1 year ago

If there's no strong reason to dump the output of this model as JSON, we can just use CSVs and like with other models and see if that works? What do you think @miquelduranfrigola?

miquelduranfrigola commented 1 year ago

Hi @DhanshreeA, apologies for a slow response here. Thanks for going deeply into the code. :hugs:

I have been thinking of robust ways of serializing any JSON output into a CSV table. One option would be to consider the JSONL format. In that case, our output adapter would:

  1. Try to convert the JSON content to multiple columns in a CSV file.
  2. In case this doesn't work, simply store a one-column CSV file with the JSON string as the value in that column.

Obviously, we would need to be careful when the length of the output is variable. Perhaps we can think of of flexible-width CSV output, where the number of columns is equivalent to the maximum length across the output?

Please let me know your thoughts and perhaps we can open a Feature Request to tackle this issue beyond this model?

carcablop commented 1 year ago

Hello @miquelduranfrigola and @DhanshreeA A similar problem occurs with the eos526j model https://github.com/ersilia-os/ersilia/issues/374#issuecomment-1384351625, and this https://github.com/ersilia-os/ersilia/issues/377. I would like to be able to work together with you on the output adapter and try what @miquelduranfrigola is proposing to also give a solution to the eos526j model. In the case of the eos526j model, the size of the output is variable, we have an input (molecule) that breaks down into different precursors.

miquelduranfrigola commented 1 year ago

As reflected above, we are now moving this discussion to #560 . As soon as we finish this, we will come back to this model and hopefully finish it.

ana42742 commented 1 year ago

Hey everyone! I have been trying to fetch this model for hours, but nothing seems to be working. I own a macOS ARM pc. Seems like the numpy version necessary for this model is 1.19.2, which only works with python 3.7.0. Unfortunately, conda installs for python 3.7 are not available (conda has been recommended in the docs). Could someone please help me with this? https://github.com/ersilia-os/ersilia/issues/612#issuecomment-1462891952

GemmaTuron commented 1 year ago

Hi @ana42742 !

Sorry, I missed that comment here. We are aware of the issues with MacBook systems they have just recently stopped support for py3.7 We are deciding how to tackle this

AhmedYusuff commented 1 year ago

Hello @GemmaTuron.

The Model was Fetched, Served and Predicted Successfully on Google Colab.

Since the Model requires TWO molecules to give prediction I tested the Model using an input file generated by running. ersilia example eos5qfo -n 1 -f myexample.csv as suggested. And the Product predictions of this SMILES were successful.

rnewout.csv

I also tested the model with "eml_canonical" SMILES file without editing the format, and the prediction was also successful and I got the Products of the molecules.

newout.csv

GemmaTuron commented 1 year ago

Hi @AhmedYusuff !

That's great, we can then close off this issue!