Computes a schedule to minimize peak memory.

  Args:
    graph: an mtf.auto_mtf.graph_interface.GraphInterface.
    scheduler_alg: a string, one of 'NAIVE' or 'LIST'

  Returns:
    an iterable of integers representing the schedule.
426984
def minimize_peak_memory(graph, scheduler_alg):
  
  if scheduler_alg == 'NAIVE':
    return _minimize_peak_memory_naive(graph)
  elif scheduler_alg == 'LIST':
    return _minimize_peak_memory_list(graph)
  else:
    raise NotImplementedError('{} is not a scheduler algorithm. It should be '
                              'one of NAIVE or LIST.'
                              .format(scheduler_alg))
891393
def _pull_schedule_loop(self):
        
        try:
            self.pull_schedule()
            delay = 16*60
        except ScheduleError, e:
            self.l.exception("ScheduleError while pulling schedule.  "+
                             "Retrying in 5m")
            delay = 5*60
        if not self.running:
            return
        self.scheduler.plan(time.time() + delay, self._pull_schedule_loop)
958751
def get_results_from_passive(self, scheduler_instance_id):
        
        # Do I know this scheduler?
        # logger.info("My schedulers: %s %s", self.schedulers, type(self.schedulers))
        if not self.schedulers:
            # Probably not yet configured ...
            logger.debug("I do not have any scheduler: %s", self.schedulers)
            return []

        scheduler_link = None
        for link in list(self.schedulers.values()):
            if scheduler_instance_id == link.instance_id:
                scheduler_link = link
                break
        else:
            logger.warning("I do not know this scheduler: %s", scheduler_instance_id)
            return []

        logger.debug("Get results for the scheduler: %s", scheduler_instance_id)
        ret, scheduler_link.wait_homerun = scheduler_link.wait_homerun, {}
        logger.debug("Results: %s" % (list(ret.values())) if ret else "No results available")

        return list(ret.values())
954191
def scheduled(self) -> ScheduledTxsAggregate:
        
        if not self.__scheduled_tx_aggregate:
            self.__scheduled_tx_aggregate = ScheduledTxsAggregate(self.book)
        return self.__scheduled_tx_aggregate
188588
function executeScheduleItem(schedule, iteration, value) {
  if (schedule.length < iteration + 1) {
    throw Error("ZLIQ: schedule for iteration " + iteration + " not defined");
  }
  let item = schedule[iteration];
  if (typeof item === "function") {
    return item(value);
  } else {
    return item;
  }
}
297977
def main(graph):
    
    args = parse_args(graph)

    if args.drop:
        drop_all(graph)
    create_all(graph)
801145
def schedule_jobs(job_list)
      Jobbr::Ohm.models(Jobbr::Scheduled).each do |job|
        if job.every
          job_list.every job.every[0], job.every[1] do
            job_list.jobbr job.task_name
          end
        end
      end
    end
607388
def run(self, format=None, reduce=False, *args, **kwargs):
        
        plan = self._generate_plan()
        if reduce:
            # This will performa a transitive reduction on the underlying
            # graph, producing less edges. Mostly useful for the "dot" format,
            # when converting to PNG, so it creates a prettier/cleaner
            # dependency graph.
            plan.graph.transitive_reduction()

        fn = FORMATTERS[format]
        fn(sys.stdout, plan.graph)
        sys.stdout.flush()
1289767
def _expand_scheduledict(scheduledict):
    """"""
    result = []
    def f(d):
        nonlocal result
        #print(d)
        d2 = {}
        for k,v in d.items():
            if isinstance(v, str) and _cronslash(v, k) is not None:
                d[k] = _cronslash(v, k)

        for k,v in d.items():
            if isinstance(v, Iterable):
                continue
            else:
                d2[k] = v

        if len(d2.keys()) == len(d.keys()):
            result.append(d2)
            return

        for k,v in d.items():
            if isinstance(v, Iterable):
                for i in v:
                    dprime = dict(**d)
                    dprime[k] = i
                    f(dprime)
                break
    f(scheduledict)
    return result
588645
def isa_from_graph(graph: nx.Graph, oneq_type='Xhalves', twoq_type='CZ') -> ISA:
    
    all_qubits = list(range(max(graph.nodes) + 1))
    qubits = [Qubit(i, type=oneq_type, dead=i not in graph.nodes) for i in all_qubits]
    edges = [Edge(sorted((a, b)), type=twoq_type, dead=False) for a, b in graph.edges]
    return ISA(qubits, edges)
873059
def callgraph(G, stmt_list):
    
    func_list = []
    for stmt in stmt_list:
        try:
            G.add_node(stmt.head.ident.name)
            func_list.append(stmt)
        except:
            pass
    for func in func_list:
        assert isinstance(func,node.function)
        func_name = func.head.ident.name
        #resolve.resolve(func)
        for s in node.postorder(func):
            if (s.__class__ is node.funcall and
                s.func_expr.__class__ is  node.ident):
                #if s.func_expr.name in G.nodes():
                    G.add_edge(func_name,s.func_expr.name)
458670
def main():
    
    args = parser.parse_args()

    scheduler = Scheduler()

    print 'Start %s' % scheduler.scheduler_id
    scheduler.interval = args.interval
    if args.keepalive:
        scheduler.run(once=True)
        keepalive = Job('simplescheduler.keepalive',
                        args=[0,
                              scheduler.get_running_scheduler_id(),
                              args.interval * 2])
        scheduler.schedule(keepalive, long(time.time() * 1000000))
    scheduler._run()
243380
def run(self, **kwargs):
        
        if not super().run(**kwargs):
            return

        if kwargs['list']:
            self.log.info('--- List of Scheduler Modules ---')
            for name, scheduler in list(self.scheduler_plugins.items()):
                if self.active_scheduler == name:
                    self.log.info('{} (active)'.format(name))
                else:
                    self.log.info(name)
            self.log.info('--- End list of Scheduler Modules ---')
            return

        scheduler = self.scheduler_plugins[self.active_scheduler]()
        scheduler.execute_scheduler()
1362618
def scheduler(ctx, xmlrpc, xmlrpc_host, xmlrpc_port,
              inqueue_limit, delete_time, active_tasks, loop_limit, fail_pause_num,
              scheduler_cls, threads, get_object=False):
    
    g = ctx.obj
    Scheduler = load_cls(None, None, scheduler_cls)

    kwargs = dict(taskdb=g.taskdb, projectdb=g.projectdb, resultdb=g.resultdb,
                  newtask_queue=g.newtask_queue, status_queue=g.status_queue,
                  out_queue=g.scheduler2fetcher, data_path=g.get('data_path', 'data'))
    if threads:
        kwargs['threads'] = int(threads)

    scheduler = Scheduler(**kwargs)
    scheduler.INQUEUE_LIMIT = inqueue_limit
    scheduler.DELETE_TIME = delete_time
    scheduler.ACTIVE_TASKS = active_tasks
    scheduler.LOOP_LIMIT = loop_limit
    scheduler.FAIL_PAUSE_NUM = fail_pause_num

    g.instances.append(scheduler)
    if g.get('testing_mode') or get_object:
        return scheduler

    if xmlrpc:
        utils.run_in_thread(scheduler.xmlrpc_run, port=xmlrpc_port, bind=xmlrpc_host)
    scheduler.run()
171514
def learning_rate_schedule(hparams):
  """"""
  mlperf_log.transformer_print(key=mlperf_log.OPT_LR, deferred=True)
  mlperf_log.transformer_print(
      key=mlperf_log.OPT_LR_WARMUP_STEPS,
      value=hparams.learning_rate_warmup_steps)
  step_num = _global_step(hparams)
  schedule_string = hparams.learning_rate_schedule
  names = schedule_string.split("*")
  names = [name.strip() for name in names if name.strip()]
  ret = tf.constant(1.0)
  for name in names:
    ret *= learning_rate_factor(name, step_num, hparams)
  return ret
635629
def inspect_periodic_tasks(self) -> List[Tuple[int, str]]:
        
        return [(int(e[0]), e[3][0].name) for e in self._scheduler.queue]
928124
def createLearningRateScheduler(self, optimizer):
    
    return torch.optim.lr_scheduler.StepLR(optimizer,
                                           step_size=1,
                                           gamma=self.lr_scheduler_gamma)