Skip to content

Conversation

@guoyuhong
Copy link
Contributor

What do these changes do?

Move function/actor exporting & loading code to function_manager.py to prepare the code change for function descriptor for python.

Related issue number

#2576

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/8492/
Test FAILed.

@robertnishihara
Copy link
Collaborator

@suquark can you take a look at this?

@robertnishihara
Copy link
Collaborator

Thanks @guoyuhong! Can you say if there are any behavior changes or if it is only code reorganization?

@suquark
Copy link
Member

suquark commented Oct 2, 2018

@robertnishihara I think it is similiar to #2602 where python/ray/execution_info.py resembles function_manager.py. In my full implementation #2577 there are also things dealing with actors & workers. But they are pending because we have not yet reached a consensus.

I think this commit along with previous trials indicate that refactoring Ray's core components will definitely changes hundreds lines of codes because current code is highly coupled. This will make code review slow. However, if we just postpone the refactoring, our situation will be harder in the future. That's our problem.

@suquark
Copy link
Member

suquark commented Oct 2, 2018

So my suggestion is that we should be more decisive in refactoring. We should first discuss when to start refactoring (because we are still building a new release) and define a time window in which to complete the refactoring tasks.

@robertnishihara
Copy link
Collaborator

Thanks @suquark, this PR feels fairly self-contained to me, so while I agree that major refactoring to worker.py should probably be put off until 0.6 is released, incremental cleanups that can be done quickly are probably a good idea.

@guoyuhong
Copy link
Contributor Author

@robertnishihara @suquark There is no behavior change in this PR. However, we may further leverage this PR to implement the function descriptor as @raulchen talked about the function descriptor change in the meeting. The next step, we will have a PR that change the backend code to remove the function id and use function descriptor in python.

@guoyuhong
Copy link
Contributor Author

One more question, when will Version0.6 be released?

@robertnishihara
Copy link
Collaborator

@guoyuhong we're tracking tasks for 0.6 in https://github.com/ray-project/ray/projects/5. The To do column is the highest priority stuff and the Optional backlog column is optional.

Probably somewhere between the middle of October and the end of October.

@guoyuhong
Copy link
Contributor Author

@robertnishihara Thanks for the clarification. Will this PR be accepted right now or only after Release0.6?

@robertnishihara
Copy link
Collaborator

robertnishihara commented Oct 3, 2018 via email

Copy link
Collaborator

@robertnishihara robertnishihara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left very minor comments. I guess the main question is whether this should be a "FunctionManager" which managers remote functions and actors, or whether we should generalize it to handle all importing/exporting of Python functions (e.g., remote functions, actors, and "functions to run" (custom serializers)).

The more general approach is what @suquark did in a different PR, and I think that's probably the direction we want to go in (though probably in a follow up PR).

"""Save a checkpoint on the actor and log any errors.
Args:
Args:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline before Args:

"""Restore an actor from a checkpoint and log any errors.
Args:
Args:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline before Args:

namedtuple,
defaultdict,
)
import ray
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline before ray imports


class FunctionManager(object):
"""
A class used to export/load remote functions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be

"""A class used to export/load remote functions.

A class used to export/load remote functions.
Attributes:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the documentation


def _do_export(self, remote_function):
"""
Pickle a remote function and export it to redis.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to previous line

def __init__(self, worker):
self._worker = worker
self._functions_to_export = []
self._actor_to_export = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should be _actors_to_export.


def get_execution_info(self, driver_id, function_id):
"""
Get the FunctionExecutionInfo of a remote function.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to previous line

Args:
driver_id: id of the driver that the function belongs to.
function_id: id of the function to get.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id -> ID, in both lines above

time.sleep(0.001)

@classmethod
def function_predictor(cls, x):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is_function_or_method?

@guoyuhong
Copy link
Contributor Author

@robertnishihara Thanks for the comments and communicating with @suquark . Yes, @suquark 's change may be a better choice for long term planning. Will his change be merged only after Release 0.6? Current PR is important to us because we want to enable calling Python code from Java as soon as possible due to the schedule.

time.sleep(0.001)

@classmethod
def is_function_or_method(cls, x):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we put is_function_or_method & is_classmethod into ray.utils? They are more like general type inspecting tools.


# Create a temporary actor with some temporary methods so that if
# the actor fails to be unpickled, the temporary actor can be used
# (just to produceerror messages and to prevent the driver from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space between 'produceerror'.

@suquark
Copy link
Member

suquark commented Oct 3, 2018

This PR looks good for me. This could also be helpful for further worker refactoring.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/8527/
Test FAILed.

@robertnishihara
Copy link
Collaborator

Thanks @suquark! I went ahead and made this changes. Will merge assuming tests pass.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/8528/
Test PASSed.

@robertnishihara robertnishihara merged commit 9948e8c into ray-project:master Oct 3, 2018
suquark added a commit to suquark/ray that referenced this pull request Oct 4, 2018
1. Remove a comment that should have been removed in ray-project#3003
2. Remove `redis_protected_mode` that is never used in `ray.init()`
3. Fix `object_id_seed` that is forgotten to be passed into `ray._init()`
4. Remove several redundant brackets.
robertnishihara pushed a commit that referenced this pull request Oct 4, 2018
This commit fix some small defects. 
1. Remove a comment that should have been removed in #3003
2. Remove `redis_protected_mode` that is never used in `ray.init()`
3. Fix `object_id_seed` that is forgotten to be passed into `ray._init()`
4. Remove several redundant brackets.
@guoyuhong
Copy link
Contributor Author

@robertnishihara @suquark Thanks!

@guoyuhong guoyuhong deleted the func_mng branch January 25, 2019 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants