Closed orionarcher closed 2 months ago
Thanks for writing in @orionarcher - I just tried the same on my machine and got the same error.
@jthorton could I pass this to you? My normal bag of tricks (start executor separately, pkill redis
, etc) doesn't seem to be applicable here.
Hi @orionarcher, due to the bespokefit server running asynchronously you need to make sure this runs in a main block try the following. Note it will fail similarly to the CLI though as the example molecule of ethane has no rotatable bonds by definition used in bespokefit, as we assume the base force field well represents methyl rotations.
from openff.bespokefit.workflows import BespokeWorkflowFactory
from openff.qcsubmit.common_structures import QCSpec
def main():
factory = BespokeWorkflowFactory(
# Define the starting force field that will be augmented with bespoke
# parameters.
initial_force_field="openff_unconstrained-2.1.1.offxml",
# Change the level of theory that the reference QC data is generated at
default_qc_specs=[
QCSpec(
method="gfn2xtb",
basis=None,
program="xtb",
spec_name="xtb",
spec_description="gfn2xtb",
)
]
)
print("Setup factory")
from openff.toolkit.topology import Molecule
input_molecule = Molecule.from_smiles("CC") # ethanol
workflow_schema = factory.optimization_schema_from_molecule(
molecule=input_molecule
)
from openff.bespokefit.executor import BespokeExecutor, BespokeWorkerConfig, wait_until_complete
print("Running bespoke fitting workflow")
with BespokeExecutor(
n_fragmenter_workers = 1,
n_optimizer_workers = 1,
n_qc_compute_workers = 1,
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)
print("Completed bespoke fitting workflow")
if output.status == "success":
# Save the resulting force field to an OFFXML file
output.bespoke_force_field.to_file("output-ff.offxml")
elif output.status == "errored":
# OR the print the error message if unsuccessful
print(output.error)
if __name__ == "__main__":
main()
Thank you for the help. Your code is now running on my system (I am getting a "No fragments found" issue but I suspect that is due to my choice of molecule).
In my use case, I am trying to run BespokeFit within a high-throughput workflow; running it as main isn't ideal. Is there a workaround or should I make calls to the CLI instead?
@orionarcher in a high-throughput workflow I would consider setting up the server and workers using the CLI by following this guide you can then interact with the server to submit molecules, inspect progress and gather results from a script using the methods in the example above.
Got it, thank you!
Description
I've entered the code from the "Getting Started" page into a python script and executed it, but that is producing an error.
It appears to be an issue with Redis, I tried changing the port with
export BEFLOW_REDIS_PORT=6380
but that did not solve the issue, just moved it to a different port.The command line code from the tutorial is also failing but it appears to be making it significantly further into the process. Any help appreciated!
Reproduction
Output
Software versions
osx-64
) or natively (osx-arm64
)? No.conda list
?I admit, my conda environment is quite messy.
Output of
conda list