Skip to content

How to run warp kernels in python scripts within other software? #323

Answered by cadop
cadop asked this question in Q&A
Discussion options

You must be logged in to vote

This was the answer from @christophercrouzet that solved the problem for me:

I'm assuming that you are trying to run eval() on a string representing Warp code? If so, due to a limitation with Python, Warp code requires to be evaluated from a file. We don't expose any API that handles that workaround but the it's fairly simple: save the code into a temporary file, use importlib to load the file as a Python module, and manually call the functions in there if needed. There's an implementation example available in warp/tests/test_transient_module.py.

Essentially you use a string to wrap the code, make a temporary file, and run that as the module. From the warp test mentioned,

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cadop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant