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

[serve] Support for imported backends #12923

Merged
merged 3 commits into from
Dec 18, 2020

Conversation

edoakes
Copy link
Contributor

@edoakes edoakes commented Dec 16, 2020

Why are these changes needed?

In some cases users may not want to pass the backend class directly, but instead import it on the remote machine. For example, the backend may have different dependencies than the local machine/driver.

This provides an application-level wrapper where the user can just pass an import path and the class will be imported in the replica:

from ray.serve.backends import ImportedBackend
client.create_backend("my_backend", ImportedBackend("module.ClassName"), arg1, arg2)

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@edoakes edoakes changed the title [serve] Support for imported backends [WIP] [serve] Support for imported backends Dec 16, 2020
@@ -342,3 +342,37 @@ def get_node_id_for_actor(actor_handle):
"""Given an actor handle, return the node id it's placed on."""

return ray.actors()[actor_handle._actor_id.hex()]["Address"]["NodeID"]


def import_class(full_path: str):
Copy link
Contributor

Choose a reason for hiding this comment

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

This is neat! Maybe it could be useful elsewhere in Ray. I almost feel like this should be a built-in function in Python, but maybe there are good reasons for it not to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is basically recreating:
from module.submodule import Class just using the lower-level API, so it sort of is a built-in function :)

@edoakes edoakes changed the title [WIP] [serve] Support for imported backends [serve] Support for imported backends Dec 17, 2020
@edoakes edoakes merged commit 3521e74 into ray-project:master Dec 18, 2020
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.

None yet

3 participants