~amirouche/mutation

26e87bb4cc721a28b4af067e0594d93684a4ec09 — Amirouche 8 months ago 3cec432 v0.3.3
v0.3.3.

clean import, reduce log and better progress bar.
2 files changed, 17 insertions(+), 12 deletions(-)

M mutation.py
M pyproject.toml
M mutation.py => mutation.py +16 -11
@@ 31,8 31,6 @@ from contextlib import contextmanager
from copy import deepcopy
from datetime import timedelta
from difflib import unified_diff
from importlib.abc import SourceLoader
from importlib.machinery import FileFinder
from pathlib import Path
from uuid import UUID



@@ 50,7 48,7 @@ from lsm import LSM
from tqdm import tqdm
from ulid import ULID

__version__ = (0, 3, 2)
__version__ = (0, 3, 3)


MINUTE = 60  # seconds


@@ 514,7 512,7 @@ def mutation_pass(args):  # TODO: rename

    if out == 0:
        msg = "no error with mutation: {}"
        log.error(msg, " ".join(command))
        log.trace(msg, " ".join(command))
        with database_open(".") as db:
            db[lexode.pack([2, uid])] = b"\x00"
        return False


@@ 794,11 792,7 @@ async def play_mutations(loop, db, seed, alpha, total, max_workers, arguments):
    sampler, total = sampling_setup(sampling, total)
    uids = sampler(uids)

    for speed in [10_000, 1_000, 100, 10, 1]:
        if total // speed == 0:
            continue
        step = speed
        break
    step = 10

    gamma = time.perf_counter()



@@ 810,14 804,17 @@ async def play_mutations(loop, db, seed, alpha, total, max_workers, arguments):

        def on_progress(_):
            nonlocal remaining
            nonlocal step
            nonlocal gamma

            remaining -= 1

            if (remaining % step) == 0 or (total - remaining == 10):
            if (remaining % step) == 0:

                percent = 100 - ((remaining / total) * 100)
                now = time.perf_counter()
                delta = now - gamma
                eta = (delta / (total - remaining)) * remaining
                eta = (delta / step) * remaining

                progress.update(int(percent))
                progress.set_description("ETA {}".format(humanize(eta)))


@@ 826,6 823,14 @@ async def play_mutations(loop, db, seed, alpha, total, max_workers, arguments):
                log.debug(msg, percent)
                log.debug("ETA {}...", humanize(eta))

                for speed in [10_000, 1_000, 100, 10, 1]:
                    if total // speed == 0:
                        continue
                    step = speed
                    break

                gamma = time.perf_counter()

        with timeit() as delta:
            with futures.ThreadPoolExecutor(max_workers=max_workers) as pool:
                await pool_for_each_par_map(

M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "mutation"
version = "0.3.2"
version = "0.3.3"
description = "test mutation for pytest."
authors = ["Amirouche <amirouche@hyper.dev>"]
license = "MIT"