| name | stardag |
| description | Stardag SDK usage guide. Use when writing code that imports stardag, defining tasks/DAGs, configuring builds, working with targets/serialization, or interacting with the Stardag Registry API/UI. Covers the full SDK surface: task definitions, dependencies, build execution, targets, configuration, CLI, and the Registry platform.
|
| user-invocable | false |
Stardag SDK & Platform Guide
Stardag is a declarative, composable DAG framework for Python with persistent asset management.
Tasks are Pydantic models with deterministic output paths based on parameter hashing.
Always import stardag as sd — this is the standard convention.
Quick Reference
import stardag as sd
@sd.task
def get_range(limit: int) -> list[int]:
return list(range(limit))
@sd.task
def get_sum(integers: sd.Depends[list[int]]) -> int:
return sum(integers)
root = get_sum(integers=get_range(limit=10))
sd.build(root)
print(root.load())
class Range(sd.Task[list[int]]):
limit: int
def run(self):
self._save(list(range(self.limit)))
class Sum(sd.Task[int]):
integers: sd.TaskLoads[list[int]]
def requires(self):
return self.integers
def run(self):
self._save(sum(self.integers.load()))
root = Sum(integers=Range(limit=10))
sd.build(root)
print(root.load())
Core Concepts
- Tasks: Pydantic models that define computation units with typed parameters
- Dependencies: Declared via
sd.TaskLoads[T] (class API) or sd.Depends[T] (decorator API)
- Targets: Persistence layer (filesystem by default) with automatic serialization
- Build: Bottom-up execution that skips already-completed tasks (Makefile-style)
- Task IDs: Deterministic UUID-5 from namespace + name + version + parameter hash
- Namespaces: Organize tasks into logical groups via
sd.namespace()
Three-Tier API Design
| Level | Base Class | Best For | Control |
|---|
| Decorator | @sd.task | Simple pure functions | Least |
| Task Class | sd.Task[T] | Most use cases (recommended) | Medium |
| TargetTask | sd.TargetTask[T] | Custom targets/serialization | Most |
All three produce semantically equivalent results — choose based on complexity needs.
Additional Resources
For detailed reference on specific topics, see these supporting files:
- sdk-core.md: Task hierarchy, decorators, dependencies, build execution, type system
- sdk-targets.md: Targets, serialization, storage configuration, target roots
- sdk-advanced.md: Async support, dynamic dependencies, namespaces, artifacts, versioning
- registry-and-platform.md: Registry API, UI, CLI, authentication, configuration
- examples.md: Complete code examples and common patterns
For the latest documentation, visit docs.stardag.com.
Key Imports
import stardag as sd
sd.Task[T]
sd.LoadableTask[T]
sd.TargetTask[T]
sd.BaseTask
sd.AliasTask[T]
sd.LoadValidator[T]
sd.task
sd.Depends[T]
sd.TaskLoads[T]
sd.TaskRef
sd.build(tasks)
sd.build_aio(tasks)
sd.build_sequential()
sd.get_file_target(relpath)
sd.get_directory_target(relpath)
sd.target_factory_provider
sd.config_provider
sd.registry_provider
sd.namespace(ns, scope=__name__)
sd.auto_namespace(scope=__name__)
sd.flatten_task_struct()
sd.get_default_relpath(task)
sd.HashableSet[T]
sd.StardagField(...)
sd.StardagBaseModel
sd.task_from_registry_data(data)
sd.TaskRehydrationError
from stardag.artifact import MarkdownArtifact, JSONArtifact
from stardag.testing import test_harness
sd.StardagError, sd.APIError, sd.AuthenticationError, sd.AuthorizationError
from stardag.build import BuildFailed
from stardag.build import TaskExecutionError