From 480ced3259e26c7ac8ec1a4a20263054a1a3882b Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Fri, 8 Apr 2022 21:29:35 +0200 Subject: [PATCH] refact: remove output to tasks --- bopytex/planner.py | 8 +------- bopytex/scheduler.py | 5 +++-- test/test_planner.py | 5 ----- test/test_scheduler.py | 8 ++++---- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/bopytex/planner.py b/bopytex/planner.py index 0818129..f564fd3 100644 --- a/bopytex/planner.py +++ b/bopytex/planner.py @@ -1,6 +1,6 @@ """ Produce tasks to do -It essentially place things at the right place and define the way that files are named. +It essentially place things at the right place. """ from dataclasses import dataclass @@ -11,7 +11,6 @@ class Task: action: str args: dict deps: list - output: str def generate(template: str, meta: dict): @@ -20,7 +19,6 @@ def generate(template: str, meta: dict): action="GENERATE", args=meta, deps=[template], - output=meta["subject"] + template[3:], ) @@ -30,7 +28,6 @@ def activate_corr_on(src: str): action="ACTIVATE_CORR", args={}, deps=[src], - output="corr_" + src, ) @@ -40,7 +37,6 @@ def compile_pdf(src: str): action="COMPILE", args={}, deps=[src], - output=src[:-3] + "pdf" ) def join_pdfs(pdfs: list): @@ -49,7 +45,6 @@ def join_pdfs(pdfs: list): action="JOIN", args={}, deps=pdfs, - output="joined.pdf" ) @@ -59,5 +54,4 @@ def clean(files: list): action="CLEAN", args={}, deps=files, - output=None ) diff --git a/bopytex/scheduler.py b/bopytex/scheduler.py index fe651c3..1fadec7 100644 --- a/bopytex/scheduler.py +++ b/bopytex/scheduler.py @@ -25,5 +25,6 @@ class Scheduler: def __next__(self): task = self._tasks.pop() - self._done.append(task.output) - return self.dispatch(task) + ans = self.dispatch(task) + self._done.append(ans) + return ans diff --git a/test/test_planner.py b/test/test_planner.py index 77b491c..f45ae96 100644 --- a/test/test_planner.py +++ b/test/test_planner.py @@ -7,7 +7,6 @@ def test_build_task_generate(): assert task.action == "GENERATE" assert task.args == {"subject": "01"} assert task.deps == [template] - assert task.output == "01_source.tex" def test_build_task_activate_corr_on(): @@ -16,7 +15,6 @@ def test_build_task_activate_corr_on(): assert task.action == "ACTIVATE_CORR" assert task.args == {} assert task.deps == [src] - assert task.output == "corr_source.tex" def test_build_task_compile(): @@ -25,7 +23,6 @@ def test_build_task_compile(): assert task.action == "COMPILE" assert task.args == {} assert task.deps == [src] - assert task.output == "source.pdf" def test_build_task_join(): @@ -34,7 +31,6 @@ def test_build_task_join(): assert task.action == "JOIN" assert task.args == {} assert task.deps == pdfs - assert task.output == "joined.pdf" def test_build_task_compile(): @@ -43,4 +39,3 @@ def test_build_task_compile(): assert task.action == "CLEAN" assert task.args == {} assert task.deps == files - assert task.output is None diff --git a/test/test_scheduler.py b/test/test_scheduler.py index c9be4f6..e994d50 100644 --- a/test/test_scheduler.py +++ b/test/test_scheduler.py @@ -5,14 +5,14 @@ from bopytex.scheduler import Scheduler def test_schedule_append(): actions = {"DO": lambda _: "done"} scheduler = Scheduler(actions) - tasks = [Task(action="DO", args={}, deps=[], output="")] + tasks = [Task(action="DO", args={}, deps=[])] scheduler.append(tasks) assert scheduler.tasks == tasks def test_schedule_dispatch(): actions = {"DO": lambda _: "done"} scheduler = Scheduler(actions) - task = Task(action="DO", args={}, deps=[], output="Nothing") + task = Task(action="DO", args={}, deps=[]) result = scheduler.dispatch(task) assert result == "done" @@ -20,8 +20,8 @@ def test_schedule_dispatch(): def test_schedule_one_task(): actions = {"DO": lambda _: "done"} scheduler = Scheduler(actions) - scheduler.append([Task(action="DO", args={}, deps=[], output="Nothing")]) + scheduler.append([Task(action="DO", args={}, deps=[])]) result = scheduler.__next__() assert result == "done" assert scheduler.tasks == [] - assert scheduler.done == ["Nothing"] + assert scheduler.done == ["done"]