def get_replicas(self, service_id: str) -> str:
        """Get the replication level of a service.

        Args:
            service_id (str): docker swarm service id

        Returns:
            str, replication level of the service

        """
        # Initialising empty list
        replicas = []

        # Raise an exception if we are not a manager
        if not self._manager:
            raise RuntimeError('Only the Swarm manager node can retrieve '
                               'replication level of the service')

        service_tasks = self._client.services.get(service_id).tasks()
        for task in service_tasks:
            if task['Status']['State'] == "running":
                replicas.append(task)
        return len(replicas)
def get_replicas ( self , service_id : str ) -> str : replicas = [ ] if not self . _manager : raise RuntimeError ( 'Only the Swarm manager node can retrieve ' 'replication level of the service' ) service_tasks = self . _client . services . get ( service_id ) . tasks ( ) for task in service_tasks : if task [ 'Status' ] [ 'State' ] == "running" : replicas . append ( task ) return len ( replicas )
Get the replication level of a service.

        Args:
            service_id (str): docker swarm service id

        Returns:
            str, replication level of the service