-
I trying to resolve an issue with integrating warp in a program similar to omniverse. Essentially, scripts can be run within the program, it uses CPython (3.9). There seems to be an issue where paths are being requested but aren't accessible. My guess here is that the kernel is being built somewhere and can't be found, or the source of the python code is not visible since it is being stored internally to the software (or some temp location). Does this logic make any sense theoretically, or is totally not how things work? If it is, is there a way to specify in the python script where kernels should get stored to as a temporary/intermediary shared location? This was a discussion on discord that was answered by @christophercrouzet . I thought it would be useful for tracking on github. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This was the answer from @christophercrouzet that solved the problem for me:
Essentially you use a string to wrap the code, make a temporary file, and run that as the module. From the warp test mentioned, warp/warp/tests/test_transient_module.py Line 55 in 5dfdb52 CODE = """# -*- coding: utf-8 -*-
import warp as wp
@wp.struct
class Data:
x: wp.array(dtype=int)
@wp.func
def increment(x: int):
# This shouldn't be picked up.
return x + 123
@wp.func
def increment(x: int):
return x + 1
@wp.kernel
def compute(data: Data):
data.x[0] = increment(data.x[0])
"""
def load_code_as_module(code, name):
file, file_path = tempfile.mkstemp(suffix=".py")
try:
with os.fdopen(file, "w") as f:
f.write(code)
spec = util.spec_from_file_location(name, file_path)
module = util.module_from_spec(spec)
spec.loader.exec_module(module)
finally:
os.remove(file_path)
return module Simply calling |
Beta Was this translation helpful? Give feedback.
This was the answer from @christophercrouzet that solved the problem for me:
Essentially you use a string to wrap the code, make a temporary file, and run that as the module. From the warp test mentioned,
warp/warp/t…