Implementation:173TECH Sayn App set tasks
Appearance
| Knowledge Sources | |
|---|---|
| Domains | DAG_Management, Task_Lifecycle |
| Last Updated | 2026-10-17 00:00 GMT |
Overview
Concrete tool for constructing the task DAG by creating TaskWrapper instances, inferring dependencies, and topologically sorting tasks for execution.
Description
The App.set_tasks method takes a dictionary of task definitions and:
- Creates a
TaskWrapperfor each task, calling itsconfig()method - Resolves implicit dependencies by mapping outputs to tasks and matching sources
- Calls
set_parents()on each task to establish parent relationships - Validates the DAG for missing parents and cycles
- Topologically sorts the DAG to produce an ordered execution list
Usage
Used internally by App.start_app() after project and settings configuration are complete. Not called directly by users.
Code Reference
Source Location
- Repository: SAYN
- File:
sayn/core/app.py - Lines: L347-446 (
set_tasks), L332-345 (get_task_class) - File:
sayn/tasks/task_wrapper.py - Lines: L128-249 (
TaskWrapper.config), L409-436 (set_parents)
Signature
class App:
def set_tasks(self, tasks: Dict[str, Dict]) -> Result
def get_task_class(self, task_type: str, config: dict) -> Result
class TaskWrapper:
def config(
self,
task_config: Dict[str, Any],
project_parameters: Dict[str, Any],
task_parameters: Dict[str, Any],
) -> Result
def set_parents(self, all_tasks: Dict[str, TaskWrapper], output_to_task: Dict) -> Result
def src(self, obj: str, connection=None, level=None) -> str
def out(self, obj: str, connection=None, level=None) -> str
Import
from sayn.core.app import App
from sayn.tasks.task_wrapper import TaskWrapper
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| tasks | Dict[str, Dict] | Yes Task definitions from get_tasks_dict
| |
| project_parameters | Dict[str, Any] | Yes Parameters from project.yaml |
Outputs
| Name | Type | Description |
|---|---|---|
| self.tasks | Dict[str, TaskWrapper] | Ordered dict of tasks by topological sort |
| self.dag | Dict[str, List[str]] Mapping of task name to parent names | |
| result | Result | Ok on success, Err on validation failure |
Usage Examples =
Internal Usage in App Lifecycle
# This is called internally by App.start_app()
# Shown here for reference of the flow:
tasks_dict = get_tasks_dict(
self.presets,
self.file_groups,
self.autogroups,
self.run_arguments.folders.sql,
self.compiler,
self.python_loader,
)
# set_tasks creates TaskWrappers, configures them, and builds the DAG
result = self.set_tasks(tasks_dict)
if result.is_err:
self.finish_app(result)
# After set_tasks, tasks are ordered by topological sort
for task_name, task_wrapper in self.tasks.items():
print(f"{task_name}: parents={task_wrapper.parent_names}")
Task Class Resolution
# App.get_task_class maps task type strings to task classes
# "sql" -> SqlTask, "copy" -> CopyTask, "test" -> TestTask
# "python_module" -> DecoratorTaskWrapper (from python_loader)
# "python" -> PythonTask subclass (loaded via python_loader.get_class)
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment