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

A problem with the optimization_schemas_from_molecules function #215

Closed
ognjenperisic opened this issue Jan 12, 2023 · 2 comments
Closed

Comments

@ognjenperisic
Copy link

Hi everybody,

I am having a problem generating an optimization schema from the list of molecules.

Here are the key elements of the code:

  1. Loading a set of molecules:
    local_file_name = 'ligands.sdf'
    filename = directory + set_name + '/' + local_file_name
    molecules = Molecule.from_file(filename)

  2. generating a schema:
    workflow_schema = factory.optimization_schemas_from_molecules(molecules)

  3. Calling the executor:
    from openff.bespokefit.executor import BespokeExecutor, BespokeWorkerConfig, wait_until_complete
    with BespokeExecutor(
    n_fragmenter_workers = 1,
    n_optimizer_workers = 1,
    n_qc_compute_workers = 2,
    qc_compute_worker_config=BespokeWorkerConfig(n_cores=1)
    ) as executor:
    # Submit our workflow to the executor
    task_id = executor.submit(input_schema=workflow_schema)
    # Wait until the executor is done
    output = wait_until_complete(task_id)

This is what I get:


_Deduplication                : 100%|██████████| 24/24 [00:00<00:00, 462.61it/s]
_Building Fitting Schema: 100%|██████████████████| 24/24 [00:05<00:00,  4.08it/s]

worker: Warm shutdown (MainProcess)

worker: Warm shutdown (MainProcess)

worker: Warm shutdown (MainProcess)
Traceback (most recent call last):
  File "test_fep_benchmark_set_1.py", line 83, in <module>
    task_id = executor.submit(input_schema=workflow_schema)
  File "...../site-packages/openff/bespokefit/executor/executor.py", line 372, in submit
    data=CoordinatorPOSTBody(input_schema=input_schema).json(),
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for CoordinatorPOSTBody

input_schema
  value is not a valid dict (type=type_error.dict)__

However,
when I replace step 2. with
workflow_schema = factory.optimization_schema_from_molecule(molecules[0])
(processing just one molecule) the code runs with no issues.

My environment:
openff-bespokefit 0.1.3 pyhd8ed1ab_0 conda-forge
openff-forcefields 2.0.0 pyh6c4a22f_0 conda-forge
openff-fragmenter-base 0.1.2 pyhd8ed1ab_1 conda-forge
openff-qcsubmit 0.3.2 pyhd8ed1ab_0 conda-forge
openff-toolkit 0.10.6 pyhd8ed1ab_0 conda-forge
openff-toolkit-base 0.10.6 pyhd8ed1ab_0 conda-forge
openff-utilities 0.1.7 pyh1a96a4e_0 conda-forge

@jthorton
Copy link
Contributor

Hi @ognjenperisic, thanks for trying out BespokeFit! The issue here is that the Executor.submit method expects a single BespokeOptimizationSchema object. In this case, you could submit each one and keep track of the ids like so

with BespokeExecutor(
n_fragmenter_workers = 1,
n_optimizer_workers = 1,
n_qc_compute_workers = 2,
qc_compute_worker_config=BespokeWorkerConfig(n_cores=1)
) as executor:
    ids = []
    for optimization_schema in workflow_schema:
        task_id = executor.submit(optimization_schema)
        ids.append(task_id)

When running multiple fits in parallel however it is often better to use the server and submit methods via the CLI as explained in the docs here. I hope this helps!

@ognjenperisic
Copy link
Author

Hi @jthorton. Thank you very much for the advice. It fixed my issue.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants