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

[Core] Make "import ray" work without grpcio #35737

Merged
merged 19 commits into from
May 25, 2023

Conversation

pcmoritz
Copy link
Contributor

@pcmoritz pcmoritz commented May 24, 2023

Why are these changes needed?

Import cleanups to push grpc imports out of the critical path of Ray

Related issue number

Next step in #35472

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

@pcmoritz pcmoritz changed the title [WIP] Clean up imports [Core] Make "import ray" work without grpcio May 25, 2023
Copy link
Contributor

@rkooo567 rkooo567 left a comment

Choose a reason for hiding this comment

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

maybe it is not ready yet since we didn't merge the Pubsub PR yet, but we can probably add a unit test to verify grpc modules are not imported from some of unit tests using contest?

@@ -135,11 +134,13 @@ def set_default_actor_lifetime(self, default_actor_lifetime: str) -> None:
Args:
default_actor_lifetime: The default actor lifetime to set.
"""
import ray.core.generated.common_pb2 as common_pb2
Copy link
Contributor

Choose a reason for hiding this comment

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

For the protobuf, any special reason we import inside a method?

Copy link
Contributor Author

@pcmoritz pcmoritz May 25, 2023

Choose a reason for hiding this comment

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

This is needed so the docs build is working (some stuff gets mocked there and if this is top level, that prevents things from working). Now that I'm thinking about this, let me actually wrap this use in Cython -- then we can get rid of this import and also wrapping it will be needed anyways going forward when we also want to get rid of the Python protobuf dependency as well :)

python/ray/_private/runtime_env/packaging.py Outdated Show resolved Hide resolved
@@ -141,7 +140,7 @@ class PyModulesPlugin(RuntimeEnvPlugin):

name = "py_modules"

def __init__(self, resources_dir: str, gcs_aio_client: GcsAioClient):
def __init__(self, resources_dir: str, gcs_aio_client):
Copy link
Contributor

Choose a reason for hiding this comment

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

same question as above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found a better way now to keep expressing the typing without needing to import the module, updated :)

@pcmoritz pcmoritz merged commit ed661cd into ray-project:master May 25, 2023
scv119 pushed a commit to scv119/ray that referenced this pull request Jun 16, 2023
Why are these changes needed?

Import cleanups to push grpc imports out of the critical path of Ray

Related issue number

Next step in ray-project#35472

Signed-off-by: Philipp Moritz <[email protected]>
Co-authored-by: SangBin Cho <[email protected]>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
Why are these changes needed?

Import cleanups to push grpc imports out of the critical path of Ray

Related issue number

Next step in ray-project#35472

Signed-off-by: Philipp Moritz <[email protected]>
Co-authored-by: SangBin Cho <[email protected]>
Signed-off-by: e428265 <[email protected]>
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.

3 participants