code: def add_flow(self, flow):
          
          from .flows import Flow
          flow = Flow.as_flow(flow)
  
          if flow in self.flows:
              raise self.Error("Cannot add same flow twice!")
  
          if not flow.allocated:
              # Set the workdir of the flow here. Create a dir in self.workdir with name flow.name
              flow_workdir = os.path.join(self.workdir, os.path.basename(flow.name))
              if flow_workdir in (flow.workdir for flow in self.flows):
                  raise self.Error("Two flows have the same name and hence the same workdir!")
              flow.allocate(workdir=flow_workdir)
  
          # Check if we are already using a scheduler to run this flow
          flow.check_pid_file()
          flow.set_spectator_mode(False)
  
          flow.check_status(show=False)
  
          #if flow.all_ok:
          #    print("flow.all_ok: Ignoring %s" % flow)
          #    return 0
  
          self.flows.append(flow)
          #print("Flow %s added to the BatchLauncher" % flow)
  
          return 1
docs: Add a flow. Accept filepath or :class:`Flow` object. Return 1 if flow was added else 0.