rxn4chemistry / rxnfp

Reaction fingerprints, atlases and classification. Code complementing our Nature Machine Intelligence publication on "Mapping the space of chemical reactions using attention-based neural networks" (http://rdcu.be/cenmd).
https://rxn4chemistry.github.io/rxnfp/
MIT License
156 stars 40 forks source link

Simpletransformers version/set up #5

Closed jpjanet closed 3 years ago

jpjanet commented 3 years ago

Hi,

I am trying to get this repo working but I can't get the dependencies quite right. I took the following actions:

  1. pulled the repo from github
  2. created a blank cona env and installed rkdit (from -c rdkit) and tmap, as directed
  3. pip install -e . to install rxnfp

At this stage, I am able to run the little example:

from rxnfp.transformer_fingerprints import (
    RXNBERTFingerprintGenerator, get_default_model_and_tokenizer, generate_fingerprints
)

model, tokenizer = get_default_model_and_tokenizer()

rxnfp_generator = RXNBERTFingerprintGenerator(model, tokenizer)

example_rxn = "Nc1cccc2cnccc12.O=C(O)c1cc([N+](=O)[O-])c(Sc2c(Cl)cncc2Cl)s1>>O=C(Nc1cccc2cnccc12)c1cc([N+](=O)[O-])c(Sc2c(Cl)cncc2Cl)s1"

fp = rxnfp_generator.convert(example_rxn)

correctly and obtain the expected output. Next, I tried to run some of the nice example notebooks, but I run into an unmet requirement for simpleransformers, e.g.

from rxnfp.models import SmilesClassificationModel

results in


ModuleNotFoundError                       Traceback (most recent call last)
LOCALPATH/rxnfp/rxnfp/models.py in <module>
     31 try:
---> 32     import simpletransformers
     33     logger.warning("This extension has only been tested with simpletransformers==0.34.4 and transformers==2.11.0")

ModuleNotFoundError: No module named 'simpletransformers'

I tried to install simpletransformers (from this repo) with

pip install simpletransformers

which reveals the inconsistent dependency:

  Attempting uninstall: transformers
    Found existing installation: transformers 3.5.1
    Uninstalling transformers-3.5.1:
      Successfully uninstalled transformers-3.5.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rxnfp 0.0.8 requires transformers<4,>=2.5.1, but you have transformers 4.1.1 which is incompatible.

The latest version of simpletransformers explicitly requires transformers >= 4.0.0 . I tried ignoring the requirement and forcing transformers back to 3.5.1 but I got more errors. I also tried with transformers 4.0.0 but I got errors about trying to call .squeeze() on string variables.

Is there a specific version of simpletransformers I should use?

I am running centos 7.

Thanks for any advice!

pschwllr commented 3 years ago

Hi,

I should have better placed the warning ("This extension has only been tested with simpletransformers==0.34.4 and transformers==2.11.0").

Can you try if simpletransformers==0.34.4 and transformers==2.11.0 works for you?

Hugginface is updating too fast, it is hard to keep up :). The next rxnfp version will support transformers >=4.0.0 but there were some breaking changes so I had to restrict it to <4.

jpjanet commented 3 years ago

Thanks, works now!