|
1 | 1 | import os |
2 | 2 | import time |
3 | 3 | import json |
4 | | -import typer |
5 | 4 | import inspect |
6 | 5 | import importlib |
7 | 6 |
|
| 7 | +import typer |
8 | 8 | import logging |
| 9 | +from rich.progress import Progress, TextColumn, BarColumn, TimeRemainingColumn, TimeElapsedColumn |
9 | 10 | from typing import Union, Pattern, Required, Optional, Callable |
10 | 11 |
|
11 | 12 | from . import __version__ |
@@ -109,8 +110,8 @@ def process( |
109 | 110 | ds: Union[list, tuple, set, None] = None |
110 | 111 | try: |
111 | 112 | logger.info('Attempting to interpret dataset') |
112 | | - ds = json.loads(dataset) |
113 | | - logger.debug(f'Evaluated dataset: %s' % ds) |
| 113 | + ds = eval(dataset) |
| 114 | + logger.debug(f'Evaluated dataset: %s' % (str(ds)[:125] + '...' if len(str(ds)) > 125 else ds)) |
114 | 115 |
|
115 | 116 | if not isinstance(ds, (list, tuple, set)): |
116 | 117 | logger.info('Invalid dataset literal') |
@@ -158,7 +159,23 @@ def process( |
158 | 159 | logger.info('Started parallel process') |
159 | 160 | logger.info('Waiting for parallel process to complete, this may take a while...') |
160 | 161 |
|
| 162 | + with Progress( |
| 163 | + TextColumn('[bold blue]{task.description}', justify='right'), |
| 164 | + BarColumn(bar_width=None), |
| 165 | + '[progress.percentage]{task.percentage:>3.1f}%', |
| 166 | + '•', |
| 167 | + TimeRemainingColumn(), |
| 168 | + TimeElapsedColumn(), |
| 169 | + ) as progress: |
| 170 | + percentage = 0 |
| 171 | + job = progress.add_task('Working...', total = 100, fields = 'a') |
| 172 | + |
| 173 | + while percentage < 100: |
| 174 | + percentage = round(sum(i.progress for i in newProcess._threads) / (len(newProcess._threads) or 8), 2) * 100 |
| 175 | + progress.update(job, completed = percentage) |
| 176 | + time.sleep(0.1) |
| 177 | + |
161 | 178 | result = newProcess.get_return_values() |
162 | 179 |
|
163 | 180 | logger.info(f'Completed in {(time.perf_counter() - start_t):.5f}s') |
164 | | - typer.echo(result) |
| 181 | + # typer.echo(result) |
0 commit comments