python/ray/actor.py
def options(self, **actor_options):
        """Configures and overrides the actor instantiation parameters.

        The arguments are the same as those that can be passed
        to :obj:`ray.remote`.

        Examples:

        .. code-block:: python

            @ray.remote(num_cpus=2, resources={"CustomResource": 1})
            class Foo:
                def method(self):
                    return 1
            # Class Foo will require 1 cpu instead of 2.
            # It will also require no custom resources.
            Bar = Foo.options(num_cpus=1, resources=None)
        """

        actor_cls = self

        # override original options
        default_options = self._default_options.copy()
        # "concurrency_groups" could not be used in ".options()",
        # we should remove it before merging options from '@ray.remote'.
        default_options.pop("concurrency_groups", None)
        updated_options = {**default_options, **actor_options}
        ray_option_utils.validate_actor_options(updated_options, in_options=True)

        # only update runtime_env when ".options()" specifies new runtime_env
        if "runtime_env" in actor_options:
            updated_options["runtime_env"] = parse_runtime_env(
                updated_options["runtime_env"]
            )

        class ActorOptionWrapper:
            def remote(self, *args, **kwargs):
                # Handle the get-or-create case.
                if updated_options.get("get_if_exists"):
                    return self._get_or_create_impl(args, kwargs)

                # Normal create case.
                return actor_cls._remote(args=args, kwargs=kwargs, **updated_options)

            def bind(self, *args, **kwargs):
                """
                **Experimental**

                For ray DAG building. Implementation and interface subject
                to changes.
                """
                from ray.experimental.dag.class_node import ClassNode

                return ClassNode(
                    actor_cls.__ray_metadata__.modified_class,
                    args,
                    kwargs,
                    updated_options,
                )

            def _get_or_create_impl(self, args, kwargs):
                name = updated_options["name"]
                try:
                    return ray.get_actor(
                        name, namespace=updated_options.get("namespace")
                    )
                except ValueError:
                    # Attempt to create it (may race with other attempts).
                    try:
                        return actor_cls._remote(
                            args=args,
                            kwargs=kwargs,
                            **updated_options,
                        )
                    except ValueError:
                        # We lost the creation race, ignore.
                        pass
                    return ray.get_actor(
                        name, namespace=updated_options.get("namespace")
                    )

        return ActorOptionWrapper()
Configures and overrides the actor instantiation parameters.

        The arguments are the same as those that can be passed
        to :obj:`ray.remote`.

        Examples:

        .. code-block:: python

            @ray.remote(num_cpus=2, resources={"CustomResource": 1})
            class Foo:
                def method(self):
                    return 1
            # Class Foo will require 1 cpu instead of 2.
            # It will also require no custom resources.
            Bar = Foo.options(num_cpus=1, resources=None)
        
Configures and overrides the actor instantiation parameters.
The arguments are the same as those that can be passed
to :obj:`ray.remote`.
Configures and overrides the actor instantiation parameters . The arguments are the same as those that can be passed to : obj : ` ray . remote ` .
def options(self, **actor_options):
        actor_cls = self
        default_options = self._default_options.copy()
        default_options.pop("concurrency_groups", None)
        updated_options = {**default_options, **actor_options}
        ray_option_utils.validate_actor_options(updated_options, in_options=True)
        if "runtime_env" in actor_options:
            updated_options["runtime_env"] = parse_runtime_env(
                updated_options["runtime_env"]
            )
        class ActorOptionWrapper:
            def remote(self, *args, **kwargs):
                if updated_options.get("get_if_exists"):
                    return self._get_or_create_impl(args, kwargs)
                return actor_cls._remote(args=args, kwargs=kwargs, **updated_options)
            def bind(self, *args, **kwargs):
                from ray.experimental.dag.class_node import ClassNode
                return ClassNode(
                    actor_cls.__ray_metadata__.modified_class,
                    args,
                    kwargs,
                    updated_options,
                )
            def _get_or_create_impl(self, args, kwargs):
                name = updated_options["name"]
                try:
                    return ray.get_actor(
                        name, namespace=updated_options.get("namespace")
                    )
                except ValueError:
                    try:
                        return actor_cls._remote(
                            args=args,
                            kwargs=kwargs,
                            **updated_options,
                        )
                    except ValueError:
                        pass
                    return ray.get_actor(
                        name, namespace=updated_options.get("namespace")
                    )
        return ActorOptionWrapper()
def options ( self , ** actor_options ) : actor_cls = self default_options = self . _default_options . copy ( ) default_options . pop ( "concurrency_groups" , None ) updated_options = { ** default_options , ** actor_options } ray_option_utils . validate_actor_options ( updated_options , in_options = True ) if "runtime_env" in actor_options : updated_options [ "runtime_env" ] = parse_runtime_env ( updated_options [ "runtime_env" ] ) class ActorOptionWrapper : def remote ( self , * args , ** kwargs ) : if updated_options . get ( "get_if_exists" ) : return self . _get_or_create_impl ( args , kwargs ) return actor_cls . _remote ( args = args , kwargs = kwargs , ** updated_options ) def bind ( self , * args , ** kwargs ) : """
                **Experimental**

                For ray DAG building. Implementation and interface subject
                to changes.
                """ from ray . experimental . dag . class_node import ClassNode return ClassNode ( actor_cls . __ray_metadata__ . modified_class , args , kwargs , updated_options , ) def _get_or_create_impl ( self , args , kwargs ) : name = updated_options [ "name" ] try : return ray . get_actor ( name , namespace = updated_options . get ( "namespace" ) ) except ValueError : try : return actor_cls . _remote ( args = args , kwargs = kwargs , ** updated_options , ) except ValueError : pass return ray . get_actor ( name , namespace = updated_options . get ( "namespace" ) ) return ActorOptionWrapper ( )
Configures and overrides the actor instantiation parameters.
Configures and overrides the actor instantiation parameters .
"""Configures and overrides the actor instantiation parameters.

        The arguments are the same as those that can be passed
        to :obj:`ray.remote`.

        Examples:

        .. code-block:: python

            @ray.remote(num_cpus=2, resources={"CustomResource": 1})
            class Foo:
                def method(self):
                    return 1
            # Class Foo will require 1 cpu instead of 2.
            # It will also require no custom resources.
            Bar = Foo.options(num_cpus=1, resources=None)
        """ # override original options # "concurrency_groups" could not be used in ".options()", # we should remove it before merging options from '@ray.remote'. # only update runtime_env when ".options()" specifies new runtime_env # Handle the get-or-create case. # Normal create case. """
                **Experimental**

                For ray DAG building. Implementation and interface subject
                to changes.
                """ # Attempt to create it (may race with other attempts). # We lost the creation race, ignore.
self
examples
None