refact: remove output to tasks
This commit is contained in:
parent
7b64dcf8d6
commit
480ced3259
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"]
|
||||
|
Loading…
Reference in New Issue
Block a user