Problem: If user wants to create new task, they need to create it and change list of tasks in actual code
Desire: Completely decouple tasks from the program and initialize them at runtime
Possible approach: create import directive in all configration files. It would describe list of tasks and directories with them as follows:
These tasks would be imported in runtime and then could be used in given configuration file.
Each file with the task should have following variables inside:
# Name of the task. Spaces are possible as well as any other symbols.
task_name: str = "ExampleTask"
# Function that would be called during initialization. It is optional. If your task need some inout parameters they would be passed here from the `args` section of the config.
initialize: Callable[[Any, ...], None] = lambda: None
# Function that takes snapshot and outputs dictionary with data. It will be called on eaxh iteration of analysis or integration.
run: Callable[[Snapshot], DataType] = lambda snapshot: {"length": len(snapshot.particles) }
Problem: If user wants to create new task, they need to create it and change list of tasks in actual code Desire: Completely decouple tasks from the program and initialize them at runtime Possible approach: create
import
directive in all configration files. It would describe list of tasks and directories with them as follows:These tasks would be imported in runtime and then could be used in given configuration file.
Each file with the task should have following variables inside: