Exemple #1
0
def example3():
    widgets = [Bar('>'), ' ', ETA(), ' ', ReverseBar('<')]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10 * i + 1)
    pbar.finish()
Exemple #2
0
    class CLIProgressBar(object):
        widgets = [' ', Bar(marker=RotatingMarker()), ' ', Percentage()]

        def __init__(self, size=100, label="", color=None, fd=sys.stdout):
            self.progress_bar = PB(widgets=[label] + self.widgets,
                                   maxval=size,
                                   fd=fd)
            self.progress = 0

        def start(self, width='50%'):
            self.progress_bar.start()
            self.progress = 0

        def increment(self, i=1):
            p = self.progress + i
            self.progress_bar.update(p)

        def update(self, progress):
            self.progress_bar.update(progress)

        def reset(self):
            self.progress_bar.start()
            self.progress = 0

        def end(self):
            self.progress_bar.finish()

        def __call__(self, iterable):
            return self.progress_bar(iterable)
Exemple #3
0
def example18():
    widgets = [Percentage(), ' ', Bar(), ' ', ETA(), ' ', AdaptiveETA()]
    pbar = ProgressBar(widgets=widgets, maxval=500)
    pbar.start()
    for i in range(500):
        time.sleep(0.01 + (i < 100) * 0.01 + (i > 400) * 0.9)
        pbar.update(i + 1)
    pbar.finish()
Exemple #4
0
def example1():
    widgets = ['Test: ', Percentage(), ' ', Bar(marker=RotatingMarker()),
               ' ', ETA(), ' ', FileTransferSpeed()]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10 * i + 1)
    pbar.finish()
Exemple #5
0
def example4():
    widgets = ['Test: ', Percentage(), ' ',
               Bar(marker='0', left='[', right=']'),
               ' ', ETA(), ' ', FileTransferSpeed()]
    pbar = ProgressBar(widgets=widgets, maxval=500)
    pbar.start()
    for i in range(100, 500 + 1, 50):
        time.sleep(0.2)
        pbar.update(i)
    pbar.finish()
Exemple #6
0
    def optimize_strains(self, pathways, view, aerobic=True):
        """
        Optimize targets for the identified pathways. The optimization will only run if the pathway can be optimized.

        Arguments
        ---------
        pathways: list
            A list of dictionaries to optimize ([Host, Model] -> PredictedPathways).
        view: object
            A view for multi, single os distributed processing.
        aerobic: bool
            If True, it will set `model.reactions.EX_o2_e.lower_bound` to 0.

        Returns
        -------
        pandas.DataFrame
            A data frame with strain designs processed and ranked.

        """
        opt_gene_runner = _OptGeneRunner(self.debug)
        differential_fva_runner = _DifferentialFVARunner(self.debug)
        strategies = [
            (host, model, pathway, aerobic) for (host, model) in pathways
            for pathway in pathways[host, model]
            if pathway.needs_optimization(model, objective=model.biomass)
        ]

        print("Optimizing %i pathways" % len(strategies))

        results = DataFrame(columns=[
            "host", "model", "manipulations", "heterologous_pathway",
            "fitness", "yield", "product", "biomass", "method"
        ])

        mapped_designs1 = view.map(opt_gene_runner, strategies)
        mapped_designs2 = view.map(differential_fva_runner, strategies)
        progress = ProgressBar(
            maxval=len(mapped_designs1) + len(mapped_designs2),
            widgets=["Processing solutions: ",
                     Bar(), ETA()])
        progress.start()
        results = self.build_results_data(mapped_designs1, strategies, results,
                                          progress)
        results = self.build_results_data(mapped_designs2,
                                          strategies,
                                          results,
                                          progress,
                                          offset=len(mapped_designs1))
        progress.finish()

        return results
Exemple #7
0
def example2():
    class CrazyFileTransferSpeed(FileTransferSpeed):

        """It's bigger between 45 and 80 percent."""

        def update(self, pbar):
            if 45 < pbar.percentage() < 80:
                return 'Bigger Now ' + FileTransferSpeed.update(self, pbar)
            else:
                return FileTransferSpeed.update(self, pbar)

    widgets = [CrazyFileTransferSpeed(), ' <<<', Bar(), '>>> ',
               Percentage(), ' ', ETA()]
    pbar = ProgressBar(widgets=widgets, maxval=10000000)
    # maybe do something
    pbar.start()
    for i in range(2000000):
        # do something
        pbar.update(5 * i + 1)
    pbar.finish()
Exemple #8
0
def example0():
    pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=300).start()
    for i in range(300):
        time.sleep(0.01)
        pbar.update(i + 1)
    pbar.finish()