Deploying Swarms ================ After successfully connecting to the cluster, you can deploy swarms for execution on the nodes. The deployment process involves sending the swarm to the manager, registering it, and starting it. The following is a step-by-step guide to deploying a swarm using the :code:`Cluster` object. 1. **Initialize the Cluster**: Connect to the Manta Manager by initializing the :code:`Cluster` object with the appropriate host and port. 2. **Check Cluster Availability**: Ensure that the cluster is available by using the :code:`is_available()` method. 3. **Send the Swarm**: Register your swarm with the manager using the :code:`send_swarm()` method. 4. **Start the Swarm**: Initiate the swarm's execution using the :code:`start_swarm()` method. Example: Swarm Deployment and Execution --------------------------------------- .. code-block:: python from manta import Cluster from swarm import FLSwarm # Initialize the Cluster object with the Manager's host and port cluster = Cluster.connect(host="localhost", port=50051, ca_port=50050) # Ensure the cluster is available response = cluster.is_available() print(response.message) # Should print "Available" # Define a Swarm object, e.g., a Federated Learning Swarm swarm = FLSwarm() # Send the Swarm to the Manager swarm_response = cluster.send_swarm(swarm) swarm_id = swarm_response.swarm_id print(f"Swarm registered with ID: {swarm_id}") # Start the Swarm start_response = cluster.start_swarm(swarm_id) print(start_response.message) # Should confirm that the swarm has started Explanation of key methods -------------------------- - **Cluster Initialization**: Connects to the Manta Manager at the specified :code:`host` and :code:`port`. - **Swarm Deployment**: The :code:`send_swarm()` method registers the swarm with the manager. The returned :code:`swarm_id` can be used to track the swarm's status. - **Swarm Execution**: The :code:`start_swarm()` method triggers the execution of the swarm on the connected nodes. The response indicates whether the swarm has started successfully. .. note:: You can also use :code:`deploy_swarm` instead of :code:`send_swarm` and :code:`start_swarm` to perform both actions with a single request.