Hi,
I'm currently developing a chimerax extension that makes a REST Api call using the gradio_client library:
Here is a minimal working example (using gradio_client==1.4.0)
from gradio_client import Client
from chimerax.core.commands import run
def print_result(self, results):
results[1] is a path to a local file
run(self.session, f"open {results[1]}")
result = client.submit(
input_sequence="",
input_ligand="COc1ccc(cc1)n2c3c(c(n2)C(=O)N)CCN(C3=O)c4ccc(cc4)N5CCCCC5=O",
exhaustiveness=1,
api_name="/predict",
result_callbacks=[print_result]
)
However, when I try to open the loaded file in ChimeraX after the prediction is finished and the callback is run I get the following error:
RuntimeError: Attempted to make OpenGL context current in wrong thread (26408, context thread 21820).
I presume I need to use a Task like here to run the chimerax.core.commands.run in the same thread as the ui.
Are there any minimal examples how to do this or other suggestions how to make this work?
Thanks,