MolecularAI / REINVENT4

AI molecular design tool for de novo design, scaffold hopping, R-group replacement, linker design and molecule optimization.
Apache License 2.0
359 stars 89 forks source link

Problem with Reinvent4 and Pydantic #111

Closed ismorphism closed 3 months ago

ismorphism commented 4 months ago

Hello, everyone! In today's release - REINVENT4 4.4.22 there is a problem with pydantic. I've attached the screenshot of the error. I checked with version of 4.3.5 and there is no problem with 4.3.5 and pydantic. The envs are the same, the only one difference is the version of Reinvent. Screenshot_error

halx commented 4 months ago

Hi,

many thanks for your interest in REINVENT and welcome to the community!

Since release 4.4 we do strict input validation. We have not done this before. The reason for this is that we want to ensure that the user can configure a REINVENT run as they intend to and REINVENT is able to tell that a configuration is valid or not. Typical errors in config files are typos or the use of obsolete configuration. If such mistakes are not caught the program may still run but not in the way the user thinks it does. But it is worth mentioning here, that REINVENT can write out a JSON config file with all the current settings. This is an optional feature though.

Unfortunately, pydantic errors are a bit cryptic and need to get some mental effort to get used to. From your error I see that you are using a key scoring_function in the first stage section. There is no such key. Please consult the documentation/config examples for details or provide the config file for me to help you.

Please do not provide screen shots from text output. It may be necessary to copy-and-paste the original text and a screenshot makes this unnecessarily difficult.

Many thanks, Hannes.

ismorphism commented 4 months ago

@halx Thank you for the answer! I will take a closer look. I used REINVENT4's introductory notebook and maybe authors of the repo should change the notebook content according to the changes in the last release, for begginer users it would be helpful. Or leave some bew comments on that.

halx commented 4 months ago

Many thanks for reporting this.

You are right, that is indeed a bug in the notebook and I have fixed that now. But please also understand that REINVENT is provided on a voluntary basis especially the notebooks which have no real value to AZ but are only maintained as a courtesy to our users.

MachineGUN001 commented 4 months ago

@halx thanks for your kind help.

the same error I've met and I pasted the related error info as below:

the command line I used:

reinvent -I sampling.log .configs/toml/sampling.toml

Traceback (most recent call last):
  File "C:\Users\SSS\.conda\envs\resgen\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\SSS\.conda\envs\resgen\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\SSS\.conda\envs\Resgen\Scripts\reinvent.exe\__main__.py", line 7, in <module>
  File "C:\Users\SSS\.conda\envs\resgen\lib\site-packages\reinvent\Reinvent.py", line 334, in main
    runner(
  File "C:\Users\SSS\.conda\envs\resgen\lib\site-packages\reinvent\runmodes\samplers\run_sampling.py", line 51, in run_sampling
    config = SamplingConfig(**input_config)
  File "C:\Users\SSS\.conda\envs\resgen\lib\site-packages\pydantic\main.py", line 175, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for SamplingConfig
parameters.temperature
  Extra inputs are not permitted [type=extra_forbidden, input_value=1.0, input_type=float]
    For further information visit https://errors.pydantic.dev/2.7/v/extra_forbidden
parameters.tb_logdir
  Extra inputs are not permitted [type=extra_forbidden, input_value='tb_logs', input_type=str]
    For further information visit https://errors.pydantic.dev/2.7/v/extra_forbidden

my OS is Windows 10 with python 3.10

many thanks again for your great help.

Best,

halx commented 4 months ago

tb_logdir is now global and must go to the top, temperature is not valid parameter.

MachineGUN001 commented 4 months ago

tb_logdir is now global and must go to the top, temperature is not valid parameter.

thanks for your explanation, solve it now!