Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All arguments to _remote should be optional. Currently args and kwargs are required. #4300

Closed
robertnishihara opened this issue Mar 7, 2019 · 4 comments
Labels
good first issue Great starter issue for someone just starting to contribute to Ray

Comments

@robertnishihara
Copy link
Collaborator

No description provided.

@robertnishihara robertnishihara added the good first issue Great starter issue for someone just starting to contribute to Ray label Mar 7, 2019
@zbarry
Copy link
Contributor

zbarry commented Mar 8, 2019

Since this is tagged "good first issue", would you mind elaborating a little bit on what _remote is referring to? Doesn't appear to be func.remote().

@virtualluke
Copy link
Contributor

From the source code in ray/remote_function.py :

def _remote(self,
                args=None,
                kwargs=None,
                num_return_vals=None,
                num_cpus=None,
                num_gpus=None,
                resources=None):
        """An experimental alternate way to submit remote functions."""

This allows setting those parameters in the remote call, vs decoration of the function.

@zbarry
Copy link
Contributor

zbarry commented Mar 8, 2019

Ok, cool. So this would be a nicer way of implementing:

def blah(arg):
    return thing

ray.remote(blah)(num_cpus=10000).remote(arg)

Where the alternative to having to hard code the number of CPUs in the decorator is just to not use it as a decorator?

E: sorry just a bit confused re: "optional", because given this code:

    def _remote(self,
                args=None,
                kwargs=None,
                num_return_vals=None,
                num_cpus=None,
                num_gpus=None,
                resources=None):
        """An experimental alternate way to submit remote functions."""
        worker = ray.worker.get_global_worker()
        worker.check_connected()

        if self._last_export_session < worker._session_index:
            # If this function was exported in a previous session, we need to
            # export this function again, because current GCS doesn't have it.
            self._last_export_session = worker._session_index
            worker.function_actor_manager.export(self)

        kwargs = {} if kwargs is None else kwargs
        args = ray.signature.extend_args(self._function_signature, args,
                                         kwargs)

It looks like kwargs is indeed optional. args, though, is gonna error on the extend_args call, but I guess you can just follow the kwargs implementation above and say args = [] if args is None else args.

@robertnishihara
Copy link
Collaborator Author

@justinwyang has been working on this in #4305.

@zbarry that's exactly right. And you're right it is already optional for remote function invocations. However, it isn't for actor creation and actor method invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Great starter issue for someone just starting to contribute to Ray
Projects
None yet
Development

No branches or pull requests

3 participants