old_contents: #!/usr/bin/env python
  import argparse
  
  from paasta_tools.marathon_tools import load_marathon_config
  from paasta_tools.paasta_metastatus import get_marathon_client
  from paasta_tools.utils import paasta_print
  
  
  def parse_args():
      parser = argparse.ArgumentParser(
          description=(
              'Helper script to get the number of in-progress marathon deployments'
          ),
      )
      return parser.parse_args()
  
  
  def get_deployments():
      marathon_config = load_marathon_config()
      marathon_client = get_marathon_client(marathon_config)
      deployments = marathon_client.list_deployments()
      return deployments
  
  
  def main():
      parse_args()
      paasta_print(len(get_deployments()))
  
  
  if __name__ == "__main__":
      main()
  
new_contents: #!/usr/bin/env python
  import argparse
  import itertools
  
  from paasta_tools.marathon_tools import get_list_of_marathon_clients
  from paasta_tools.utils import paasta_print
  
  
  def parse_args():
      parser = argparse.ArgumentParser(
          description=(
              'Helper script to get the number of in-progress marathon deployments'
          ),
      )
      return parser.parse_args()
  
  
  def get_deployments():
      clients = get_list_of_marathon_clients()
      return [deployment for deployment in itertools.chain.from_iterable(
          c.list_deployments() for c in clients
      )]
  
  
  def main():
      parse_args()
      paasta_print(len(get_deployments()))
  
  
  if __name__ == "__main__":
      main()
  
subject: Make paasta_get_num_deployments using marathon sharded code