执行 @ray.remote 函数时,会引发以下异常,即使我提供了函数定义中设置的所有参数:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ray/signature.py in extend_args(function_signature, args, kwargs)
208 raise Exception("No value was provided for the argument "
209 "'{}' for the function '{}'.".format(
--> 210 keyword_name, function_name))
211
212 no_positionals = len(arg_is_positionals) == 0 or not arg_is_positionals[-1]
Exception: No value was provided for the argument 'phones' for the function 'compile_file'.
编辑:我的远程函数定义和远程调用的最小示例如下:
import ray
ray.init(num_cpus=4, num_gpus=1, include_webui=False) #initialize ray with 4 CPUs
@ray.remote
def compile_file(self, rgx_patts, phones): # method for my Case class
self._phones = self.phonelist(rgx_patts, phones)
def compile_all(inputDirectory='C/TODOS', phones = ['10002000']):
d = {}
file_lst = pdfLister(inputDirectory, termin)
for i, file in enumerate(file_lst):
doc = Case(file)
doc.compile_file.remote(rgx_patts, phones) # exception thrown here
d[i] = doc
case_dic = {k: ray.get(dic_id) for k, dic_id in d.items()}
return case_dic
编辑:下面的完整例外
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<timed exec> in <module>()
~/compile_files.py in compile_all(pckle, inputDirectory, pickle_op_file, termin, rgx_patts, ceav_phones)
111 prm._rgx_patts, prm._ceav_phones)
114 d[i] = doc
115 ceav_dic = {k: ray.get(dic_id) for k, dic_id in d.items()}
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ray/remote_function.py in remote(self, *args, **kwargs)
103 def remote(self, *args, **kwargs):
104 """This runs immediately when a remote function is called."""
--> 105 return self._submit(args=args, kwargs=kwargs)
106
107 def _submit(self,
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ray/remote_function.py in _submit(self, args, kwargs, num_return_vals, num_cpus, num_gpus, resources)
118 kwargs = {} if kwargs is None else kwargs
119 args = ray.signature.extend_args(self._function_signature, args,
--> 120 kwargs)
121
122 if num_return_vals is None:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ray/signature.py in extend_args(function_signature, args, kwargs)
208 raise Exception("No value was provided for the argument "
209 "'{}' for the function '{}'.".format(
--> 210 keyword_name, function_name))
211
212 no_positionals = len(arg_is_positionals) == 0 or not arg_is_positionals[-1]
Exception: No value was provided for the argument 'ceav_phones' for the function 'compile_file'.