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

[RLlib] Fix connector registry #30635

Merged
merged 4 commits into from
Nov 30, 2022

Conversation

kouroshHakha
Copy link
Contributor

@kouroshHakha kouroshHakha commented Nov 24, 2022

Nice!

image

Why are these changes needed?

This fixes test_tune_restore with connectors enabled.

Related issue number

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 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 :(

@kouroshHakha
Copy link
Contributor Author

@gjoliver Please review, I have to disable connector in algorithm_config anyway, so I'll wait for your feedback and then flip the switch for merge.

Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

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

looks good. a couple of quick questions.



@PublicAPI(stability="alpha")
def register_connector(name: str, cls: Connector):
Copy link
Member

Choose a reason for hiding this comment

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

define these 2 in registry.py and just import here?

Copy link
Contributor Author

@kouroshHakha kouroshHakha Nov 28, 2022

Choose a reason for hiding this comment

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

Tried that, it gave me circular dependency issues :( I solved circular dependency by this. Basically the problem is that pipleineconnectors use register_connector and get_connector. I cannot import them in the registry.py if registry.py also includes register_connector. The register_connector API has to be imported before both of these connector apis.

Copy link
Member

Choose a reason for hiding this comment

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

I thought the reason to use a registry is to break this circular dependency.
so why do we move these 2 out of connector.py?

@@ -58,6 +61,7 @@ def setup(self, config):
register_trainable(alias, _see_contrib(alias))


_register_all()
Copy link
Member

Choose a reason for hiding this comment

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

looks a bit suspicious. why didn't we have to register anything before this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have explicitly called _register_all() in places where it was needed. for example in the tune_restore_test() we explicitly call this in the tear_down() function to reimport all the classes after the tune actor dies. For some reason that does not work for the connectors. We could have also called register_all when importing algorithm.py but I don't think that's the right place to call register_all. Basically the logic is that as soon as you import rllib all the namespaces with rllib should be recognizable globally.

Copy link
Member

@gjoliver gjoliver left a comment

Choose a reason for hiding this comment

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

looks good. a couple of quick questions.

Jun Gong added 3 commits November 29, 2022 19:57
… the global registry is lost.

Signed-off-by: Jun Gong <jungong@anyscale.com>
Signed-off-by: Jun Gong <jungong@anyscale.com>
Signed-off-by: Jun Gong <jungong@anyscale.com>
@gjoliver gjoliver force-pushed the fix-connector-registry branch from e6046ee to 5786282 Compare November 30, 2022 04:40
@gjoliver
Copy link
Member

Tests look good when I flip enable_connectors to True. Reverting the flag change now.
Screen Shot 2022-11-29 at 9 55 28 PM

Signed-off-by: Jun Gong <jungong@anyscale.com>
"""
for module in ALL_CONNECTORS:
if module in sys.modules:
importlib.reload(sys.modules[module])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice. I learned something new :)

@gjoliver gjoliver merged commit 0b9a7cb into ray-project:master Nov 30, 2022
@gjoliver gjoliver mentioned this pull request Nov 30, 2022
7 tasks
jeicher pushed a commit to tweag/ray that referenced this pull request Dec 1, 2022
Introduce API to force re-register all the connectors in case the global registry is lost.

Signed-off-by: Jun Gong <jungong@anyscale.com>
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
Introduce API to force re-register all the connectors in case the global registry is lost.

Signed-off-by: Jun Gong <jungong@anyscale.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
tamohannes pushed a commit to ju2ez/ray that referenced this pull request Jan 25, 2023
Introduce API to force re-register all the connectors in case the global registry is lost.

Signed-off-by: Jun Gong <jungong@anyscale.com>
Signed-off-by: tmynn <hovhannes.tamoyan@gmail.com>
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.

2 participants