Domzou-kun / prpl

MIT License
3 stars 0 forks source link

prpl Logo

![PyPI](https://img.shields.io/pypi/v/progress-parallel) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/progress-parallel) ![PyPI - Format](https://img.shields.io/pypi/format/progress-parallel) ![PyPI - License](https://img.shields.io/pypi/l/progress-parallel) [![Downloads](https://static.pepy.tech/personalized-badge/progress-parallel?period=total&units=international_system&left_color=grey&right_color=blue&left_text=Downloads)](https://pepy.tech/project/progress-parallel) ![GitHub issues](https://img.shields.io/github/issues/Domzou-kun/prpl)
![GitHub followers](https://img.shields.io/github/followers/Domzou-kun?style=social) [![Twitter](https://badgen.net/badge/icon/tweet?icon=twitter&label)](https://twitter.com/intent/tweet?text="prpl"%20is%20a%20recommended%20repository😊👍%0a&url=https://github.com/Domzou-kun/prpl&hashtags=Github,Python)

# **the latest version of 3.2.1🎉** ## Changes in the new version of **3.2.1** **- Some serious bugs were fixed. -**

# CAUTION **Serious bugs are fixed as hotfixes in v3.1.1. We have discovered a serious flaw in the functionality available in for-loop added in v3.0.1. This has been corrected in v3.1.1. Accordingly, v3.0.1 has been removed from PyPI.**


prpl

prpl(progress-parallel) is a library to visualize the progress of parallel processing by concurrent.futures, the standard python library.


Description

prpl is a "Tips" library that makes the standard python parallel processing library simpler to use.

The general functionality is the same as concurrent.futures itself, but it is possible to visualize the parallel processing status of threads generated using this library.


More about prpl

In prpl, when performing calculations on numbers managed by a list, the list is automatically parallelized and parallelized. The progress of the parallel processing can be visualized and the parallel processing can be checked.

Standard features include the following,

For other samples, test code is available at tests directory. Please run it.

(and gifs are at sample git directory)

parallel processing

For parallel processing, it is CPU parallel processing using the standard python library. For more information, check the python concurrent.futures documentation.

Sample code

An actual code sample example would be as follows. An example of implementation in actual code is shown below.

When performing some calculation process on a set of numbers compiled in a list, the conventional implementation is as follows:

""" conventional method """
calculation_result = []
target_list = list(range(0, 100000))
for target_var in target_list:
    calc_answer = (target_var**target_var)**2   # formula
    calculation_result.append(calc_answer)

By using prpl, the process inside a for loop statement is automatically executed in parallel by passing it as a function, and the result is returned.

""" Separate formulas to be processed in the for loop as functions """
def target_function(target_var):
    calc_answer = (target_var**target_var)**2   # target formula
    return calc_answer

""" Methods using prpl """
from prpl import prpl
target_list = list(range(0, 100000))
calculation_result = prpl(target_list, target_function) # prpl

The actual operating gif of the comparison is as follows:

prpl test gif 1

It is important to note that if the formula is not complex, it is not suitable for parallel processing. Because of the nature of parallel processing, prpl should not be used unnecessarily.

Optional arguments, etc

The list of arguments, etc. that can be used in prpl is as follows.

result_list = prpl(  # The results will always return with a type of List.

   target_list,      # Required argument
      ### List to be used in the target function.

   target_function,  # May be required argument.
      ### A function that contains a target formula, etc, and must include a return statement.
      ### Required arguments if prpl is used in parallel processing visualization.
      ### It is not required if it is used in the for-loop.

   args,
      ### Multiple arguments managed by dictionary type.

   list_sep,
      ### Number of list divisions. 
      ### Default setting is 5.

   checkpoint,
      ### Number of breaks to display progress.
      ### ### Default setting is 10.

   title,
      ### Title of each progress bar.
      ### By default, the name of the target function.

   symbol,
      ### Progress bar mark settings.

   symbol_c,
      ### Setting the length of the progress bar.
      ### Default setting is 50.

   smpl,
      ### Simple display mode.
      ### Default setting is False.

   timer,
      ### Measuring run time.
      ### Not available in simple mode.

   color
      ### Change the color of the progress bar.

)

Impossible and warning with prpl

Getting Started

Installing

Latest prpl via PyPI (pip install)

PyPI Downloads

pip install progress-parallel

Install by pip from github

pip install git+https://github.com/Domzou-kun/prpl.git

or install via SSH

pip install git+git://github.com:Domzou-kun/prpl.git

Particularly technical notes

display

prpl's, the progressbar on the console uses ESC and CSI sequences to control multiple lines simultaneously.

When using CSI and ESC sequences with cmd, etc., terminal settings must be enabled.

However, many of the programs that display such a progressbar as this one have modified kernel and console settings to suit their individual programs. This means that if other console-controlling programs are used at the same time, the settings may conflict and break the drawing.

We have already confirmed that when tqdm and prpl are imported and used at the same time, there is a conflict with tqdm's settings and prpl's display is corrupted.

We are currently working on a fix for this problem.

If you have a suggestion for a technical solution, please write to the issue. We will gladly review and consider it.

Authors

Domzou

link

Version history

If you want to know about past versions, please refer to version history.

LICENSE

prpl has a MIT license, as found in the LICENSE file.