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

Reloadable uvicorn app over dev #8971

Closed
wants to merge 9 commits into from
Closed

Conversation

snwagh
Copy link
Contributor

@snwagh snwagh commented Jun 25, 2024

This adds the ability to create in-memory nodes (python nodes) with a reloadable uvicorn server. Instead of adding a notebook, adding some small code snippets here for local testing.

import syft as sy

CANADA_DOMAIN_PORT = 9081
ITALY_DOMAIN_PORT = 9082
CANADA_ENCLAVE_PORT = 9083

The way to run servers is to use start_reloadable_server as an alternative to sy.orchestra.launch (it returns as NodeHandle)

from syft.node.server_management import start_reloadable_server, stop_all_reloadable_servers

canada_node = start_reloadable_server(name="canada-domain", port=CANADA_DOMAIN_PORT, reset=True)
italy_node = start_reloadable_server(name="italy-domain", port=ITALY_DOMAIN_PORT, reset=True)
canada_enclave = start_reloadable_server(name="canada-enclave", node_type="enclave", 
                                      port=CANADA_ENCLAVE_PORT, reset=True)

Right now this only takes a few of the import arguments from sy.orchestra.launch (name: str, node_type: str, node_side_type: str, port: int, processes: int, local_db: bool, reset: bool) but not all.

Test login

do_canada_client = canada_node.login(email="[email protected]", password="changethis")
do_italy_client = italy_node.login(email="[email protected]", password="changethis")

Test enclave login which should give a SyftError preventing admin logging into Enclaves.

enclave_login = canada_enclave.login(email="[email protected]", password="changethis")
enclave_login

Then comes the magic to check the reloading in action. Comment out these lines from user_service.py to allow admin login into Enclaves as well. And just rerun the last cell and it should allow the login!

Additional Notes

  • To keep the experience as close to before, you can do canada_node.land() to shut the server or use stop_all_reloadable_servers() to shutdown/land all servers.
  • Since the server takes a few seconds to spin up, an intentional sleep has been added to the code so that the uvicorn logs do not show up in future cells when rapidly cruising through jupyter lab cells.

Thanks @itstauq!

@snwagh snwagh mentioned this pull request Jun 25, 2024
@snwagh snwagh self-assigned this Jun 25, 2024
@snwagh
Copy link
Contributor Author

snwagh commented Jun 27, 2024

@madhavajay This work and you will be able to give this a try locally (and maybe fix the security issues).

@rasswanth-s
Copy link
Collaborator

Superseded by #8988

@rasswanth-s rasswanth-s closed this Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants