You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using 2.0 on windows, is there anyway of calling methods defined by getattr in the kernel? I tried getattr on its own in the kernel and that didn't work, and then tried using it in build instead. However, I get an error message when I try to access the method. Using the following code,
ERROR:worker(27342,getattr_test.py):root:Terminating with exception (AttributeEr
ror: type object 'Getattr_Test' has no attribute 'test_method')
Traceback (most recent call last):
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\master\worker
_impl.py", line 228, in main
exp_inst.run()
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\language\core
.py", line 54, in run_on_core
return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\coredevice\co
re.py", line 111, in run
self.compile(function, args, kwargs, set_result)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\coredevice\co
re.py", line 95, in compile
library = target.compile_and_link([module])
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\targ
ets.py", line 180, in compile_and_link
return self.link([self.assemble(self.compile(module)) for module in modules]
,
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\targ
ets.py", line 180, in <listcomp>
return self.link([self.assemble(self.compile(module)) for module in modules]
,
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\targ
ets.py", line 137, in compile
llmod = module.build_llvm_ir(self)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\modu
le.py", line 82, in build_llvm_ir
return llvm_ir_generator.process(self.artiq_ir, attribute_writeback=True)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 408, in process
self.process_function(func)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 570, in process_function
llinsn = getattr(self, "process_" + type(insn).__name__)(insn)
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 1463, in process_Quote
return self._quote(insn.value, insn.type, lambda: [repr(insn.value)])
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 1410, in _quote
lambda: path() + ['__class__'])
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 1411, in _quote
return _quote_attributes()
File "C:\Anaconda3\envs\artiq-2016-09-27\lib\site-packages\artiq\compiler\tran
sforms\llvm_ir_generator.py", line 1388, in _quote_attributes
attrvalue = getattr(value, attr)
AttributeError: type object 'Getattr_Test' has no attribute 'test_method'
ERROR:master:artiq.master.scheduler:got worker exception in run stage, deleting
RID 27342
If I get rid of the kernel decorator it prints the value 50 as you expect. Is there a better way of calling methods by name in the kernel?
The text was updated successfully, but these errors were encountered:
getattr is not supported in kernels by design. Every use of getattr that could be in principle efficiently compiled can also be represented using closures, which also shows intent better IMO. Is there a reason you cannot rewrite what you want using closures?
Using 2.0 on windows, is there anyway of calling methods defined by getattr in the kernel? I tried getattr on its own in the kernel and that didn't work, and then tried using it in build instead. However, I get an error message when I try to access the method. Using the following code,
I got the message,
If I get rid of the kernel decorator it prints the value 50 as you expect. Is there a better way of calling methods by name in the kernel?
The text was updated successfully, but these errors were encountered: