class_docstr: A Launchpad program, representing a distributed program and its topology.
  
  A Launchpad program contains nodes, each node could be just a process, or
  provide a service, etc (please refer to Launchpad documentation for types of
  nodes). Homogenous nodes are organized as groups. Here's an example of
  adding nodes to a group:
  
      with program.group('actor'):
        program.add_node(lp.CourierNode(MyActor, ...))
  
  `add_node()` returns a handle, which can be passed to another node for
  communication purpose, and is the way to set up distributed communication
  topology. For example:
  
      with program.group('learner'):
        learner = program.add_node(lp.CourierNode(MyLearner, ...))
  
      with program.group('actor'):
        program.add_node(lp.CourierNode(MyActor, learner=leaner))
class_docstr_tok: ["A","Launchpad","program",",","representing","a","distributed","program","and","its","topology",".","A","Launchpad","program","contains","nodes",",","each","node","could","be","just","a","process",",","or","provide","a","service",",","etc","(","please","refer","to","Launchpad","documentation","for","types","of","nodes",")",".","Homogenous","nodes","are","organized","as","groups",".","Here","'s","an","example","of","adding","nodes","to","a","group",":","with","program.group","(","'actor","'",")",":","program.add_node","(","lp.CourierNode","(","MyActor",",","...",")",")","`","add_node","(",")","`","returns","a","handle",",","which","can","be","passed","to","another","node","for","communication","purpose",",","and","is","the","way","to","set","up","distributed","communication","topology",".","For","example",":","with","program.group","(","'learner","'",")",":","learner","=","program.add_node","(","lp.CourierNode","(","MyLearner",",","...",")",")","with","program.group","(","'actor","'",")",":","program.add_node","(","lp.CourierNode","(","MyActor",",","learner=leaner",")",")"]
code: def __init__(self, name: str):
      self._name = name
      self._groups = {}  # type: Dict[str, List[base.Node]]
      # Group to add nodes to. Used by group()
      self._current_group = None
  
file_path: launchpad/launchpad/program.py
imports: import contextlib
  import dataclasses
  import itertools
  from typing import Any, Dict, List, Optional, Tuple
  from launchpad.nodes import base
label_desc: Use image node_id 1 to create a new Program object from inherited base classes: object with example: obj = Program(name)