| 3371 | |
| 3372 | |
| 3373 | def _make_remote(function_or_class, options): |
| 3374 | if not function_or_class.__module__: |
| 3375 | function_or_class.__module__ = "global" |
| 3376 | |
| 3377 | if inspect.isfunction(function_or_class) or is_cython(function_or_class): |
| 3378 | is_generator_callable = inspect.isgeneratorfunction( |
| 3379 | function_or_class |
| 3380 | ) or inspect.isasyncgenfunction(function_or_class) |
| 3381 | ray_option_utils.validate_task_options( |
| 3382 | options, in_options=False, is_generator_callable=is_generator_callable |
| 3383 | ) |
| 3384 | return ray.remote_function.RemoteFunction( |
| 3385 | Language.PYTHON, |
| 3386 | function_or_class, |
| 3387 | None, |
| 3388 | options, |
| 3389 | ) |
| 3390 | |
| 3391 | if inspect.isclass(function_or_class): |
| 3392 | ray_option_utils.validate_actor_options(options, in_options=False) |
| 3393 | return ray.actor._make_actor(function_or_class, options) |
| 3394 | |
| 3395 | raise TypeError( |
| 3396 | "The @ray.remote decorator must be applied to either a function or a class." |
| 3397 | ) |
| 3398 | |
| 3399 | |
| 3400 | class RemoteDecorator(Protocol): |