MolecularAI / ReinventCommunity

MIT License
152 stars 56 forks source link

FileNotFoundError: config.json #22

Closed aish-tan closed 2 years ago

aish-tan commented 2 years ago

Hello there, Firstly, thanks for developing the intuitive "ReinventCommunity" repo allowing an easy kick-start to ReInvent 3.0.

I would like to report this issue I am facing. I cloned both the main 'ReInvent 3.0' repo and this community repo on my machine, created the environments for both the base 'Reinvent 3.0' and the community as described in the instructions.

When running a demo community notebook (so far I have tried 2 of them: notebooks/Reinforcement_Learning_Demo_Simple_Tanimoto.ipynb and one more), I changed the paths as mentioned:

# load dependencies
import os
import re
import json
import tempfile

# --------- change these path variables as required
reinvent_dir = os.path.expanduser("home/DL/AZReinvent/Reinvent")
reinvent_env = os.path.expanduser("home/DL/anaconda3/envs/reinvent.v3.0")
output_dir = os.path.expanduser("home/DL/AZReinvent/Reinvent_Output_Ash/REINVENT_RL_Tanimoto_Similarity_demo")

# --------- do not change
# get the notebook's root path
try: ipynb_path
except NameError: ipynb_path = os.getcwd()

# if required, generate a folder to store the results
try:
    os.mkdir(output_dir)
except FileExistsError:
    pass

I didn't change anything else in the script to reproduce the example. However, the output captured under the:

# print the output to a file, just to have it for documentation
with open(os.path.join(output_dir, "run.err"), 'w') as file:
    file.write(captured_err_stream.stdout)

# prepare the output to be parsed
list_epochs = re.findall(r'INFO.*?local', captured_err_stream.stdout, re.DOTALL)
data = [epoch for idx, epoch in enumerate(list_epochs) if idx in [1, 75, 124]]
data = ["\n".join(element.splitlines()[:-1]) for element in data]

would read:

Traceback (most recent call last): File "home/DL/AZReinvent/Reinvent/input.py", line 20, in manager = Manager(configuration) File "home/DL/AZReinvent/Reinvent/running_modes/manager.py", line 13, in init self._load_environmental_variables() File "home/DL/AZReinvent/Reinvent/running_modes/manager.py", line 22, in _load_environmental_variables with open(os.path.join(project_root, '../configs/config.json'), 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: 'home/DL/AZReinvent/Reinvent/running_modes/../configs/config.json'

And thus, while the Jupyter notebook is running fine and apparently the ReInvent code itself since the error is generated, for me it is not functioning.

The final line of code: !head -n 15 {output_dir}/results/memory.csv would thereby give me this error (for obvious reasons):

head: cannot open 'home/DL/AZReinvent/Reinvent_Output_Ash/REINVENT_RL_Tanimoto_Similarity_demo/results/memory.csv' for reading: No such file or directory

Could you please provide me with some insights?

Thanks in advance! Kind regards, Aishvarya

aish-tan commented 2 years ago

For clarity, a "RL_config.json" file IS created in the _outputdir, and reads:

{
    "logging": {
        "job_id": "demo",
        "job_name": "Reinforcement learning demo",
        "logging_frequency": 10,
        "logging_path": "/home/DL/AZReinvent/Reinvent_Output_Ash/REINVENT_RL_Tanimoto_Similarity_demo/progress.log",
        "recipient": "local",
        "result_folder": "/home/DL/AZReinvent/Reinvent_Output_Ash/REINVENT_RL_Tanimoto_Similarity_demo/results",
        "sender": "http://0.0.0.1"
    },
    "parameters": {
        "diversity_filter": {
            "minscore": 0.4,
            "minsimilarity": 0.4,
            "name": "IdenticalMurckoScaffold",
            "nbmax": 25
        },
        "inception": {
            "memory_size": 100,
            "sample_size": 10,
            "smiles": []
        },
        "reinforcement_learning": {
            "agent": "/home/DL/AZReinvent/ReinventCommunity/notebooks/models/random.prior.new",
            "batch_size": 128,
            "learning_rate": 0.0001,
            "margin_threshold": 50,
            "n_steps": 125,
            "prior": "/home/DL/AZReinvent/ReinventCommunity/notebooks/models/random.prior.new",
            "reset": 0,
            "reset_score_cutoff": 0.5,
            "sigma": 128
        },
        "scoring_function": {
            "name": "custom_product",
            "parallel": false,
            "parameters": [
                {
                    "component_type": "tanimoto_similarity",
                    "name": "Tanimoto similarity",
                    "specific_parameters": {
                        "smiles": [
                            "O=S(=O)(c3ccc(n1nc(cc1c2ccc(cc2)C)C(F)(F)F)cc3)N"
                        ]
                    },
                    "weight": 1
                }
            ]
        }
    },
    "run_type": "reinforcement_learning",
    "version": 3
}
xuzhang5788 commented 2 years ago

Please try this: Go to the directory where Reinvent 3.0 was installed and rename Reinvent/configs/example.config.json to Reinvent/configs/config.json. Then try your notebook. Hopefully, it will work.

aish-tan commented 2 years ago

@xuzhang5788 Thanks a lot for your quick reply. The notebook works now.

Closing this issue.