Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with jtvae_zinc_no_kl on Windows: os.unlink(tmp_file.name) #95

Open
1 task done
rflameiro opened this issue Feb 5, 2024 · 2 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@rflameiro
Copy link

rflameiro commented Feb 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues and found nothing

Bug description

Trying to use jtvae_zinc_no_kl to featurize a SMILES dataset, code adapted from https://molfeat.datamol.io/featurizers/jtvae_zinc_no_kl to run as a python script.
The step features = transformer(smiles) throws a series of errors due to os.unlink(tmp_file.name) on dgl_pretrained.py

How to reproduce the bug

# run as: $python jtnn.py
import pandas as pd
from molfeat.trans.pretrained import PretrainedDGLTransformer

df = pd.read_csv("training_set.csv", sep=";", header=0)
smiles = df['standard_SMILES'].to_list()

transformer = PretrainedDGLTransformer(kind='jtvae_zinc_no_kl', dtype=float)
features = transformer(smiles)

df2 = pd.DataFrame(features)
df2.to_csv("training_set_jt.csv", sep=";", index=False)

Error messages and logs

(molfeat-env) C:\Users\rafae\Desktop\jtnn>python jtnn.py
Extracting file to C:\Users\rafae\.dgl/jtvae
Traceback (most recent call last):
  File "C:\Users\rafae\Desktop\jtnn\jtnn.py", line 8, in <module>
    features = transformer(smiles)
  File "C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\molfeat\trans\base.py", line 385, in __call__
    features = self.transform(mols, ignore_errors=ignore_errors, enforce_dtype=False, **kwargs)
  File "C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\sklearn\utils\_set_output.py", line 273, in wrapped
    data_to_wrap = f(self, X, *args, **kwargs)
  File "C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\molfeat\trans\pretrained\base.py", line 208, in transform
    out = self._embed(converted_mols, **kwargs)
  File "C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\molfeat\trans\pretrained\dgl_pretrained.py", line 222, in _embed
    dataset, successes = self.graph_featurizer(smiles, kind=self.kind)
  File "C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\molfeat\trans\pretrained\dgl_pretrained.py", line 258, in graph_featurizer
    os.unlink(tmp_file.name)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:

Environment

Current environment
OS: Windows 10
dgl                       2.0.0                
dgllife                   0.3.2
molfeat                   0.10.0
#- How you installed Molfeat: conda

Additional context

No response

@rflameiro rflameiro added the bug Something isn't working label Feb 5, 2024
@rflameiro
Copy link
Author

rflameiro commented Feb 6, 2024

Update: I commented out the os.unlink(tmp_file.name) line and it appeared to work, with the warning:

C:\Users\rafae\miniconda3\envs\molfeat-env\lib\site-packages\dgl\core.py:82: DGLWarning: The input graph for the user-defined edge function does not contain valid edges
  dgl_warning(

which seems not to affect the calculation according to awslabs/dgl-lifesci#177

However, now that I tried with a larger dataset, I get the same KeyError: 'C1=CNN=C1' as mentioned in the link above.
One person suggested using rdkit 2018, so I will try to create an environment with Python 3.7 and rdkit 2018 tomorrow and see if it works. This does not seem compatible with molfeat, though, as the dependency is python>3.8

@rflameiro
Copy link
Author

There seems to be a compatibility problem with JTVAE.
From https://github.com/awslabs/dgl-lifesci: If you need to work on the example of JTVAE, then you need RDKit 2018.09.3.
And this is not compatible with molfeat (python>3.8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants