Decouple server and worker side of Task
I keep being irked by all Tasks having a valid work_request object except for worker tasks, and this is a proposal for refactoring that I can explore:
- split the Task object that runs on the worker from the Task object that runs on the server
- when reasoning with WorkRequests on the server, they instantiate a WorkerTask object, that wraps the actual Task
- methods that are meant for the server, like applying task configuration, looking up artifacts, computing dynamic data, and so on, are implemented in the WorkerTask version
- the server doesn't have to care about how to execute the task on the worker, so the (Task, SigningTask) hierarchy and the (WorkerTask, ServerTask, Workflow, ...) can diverge over time according to their specific needs
Effectively, this acknowledges that server-side we are having two different types in one: the Task that runs on the worker, and the Task that provides specialized behaviour for a WorkRequest object, and proposes to distinguish between the two.
TODO list (provisional):
-
Split
BaseTaskandDBTaskhierarchies (!2720 (merged)) -
decouple computing dynamic data and tags from
BaseTask(it only runs on the server) (!2725 (merged)) (!2748 (merged)) - refactor applying task configuration (!2743 (merged))
-
review
WorkRequestmethods that instantiate a task to work, looking for things that can be moved toDBTask(!2743 (merged)) -
review
BaseTaskAPI for things that really only belong server-side (!2743 (merged)) - update task-related documentation (!2804 (merged))
- refactor tabs in the workrequest view so that they only take a task (with a work request) rather than taking a work request and a task as separate arguments (!2807 (merged))
Edited by Enrico Zini