API Reference¶
Auto-generated API documentation from source code.
Core Module¶
Stardag: Declarative and composable DAG framework for Python.
Stardag provides a clean Python API for representing persistently stored assets as a declarative Directed Acyclic Graph (DAG).
Basic usage::
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)
task = get_sum(integers=get_range(limit=10))
sd.build(task)
print(task.target().load()) # 45
Core components:
- :func:
task- Decorator for creating tasks from functions - :class:
Task- Task with automatic serialization and filesystem targets - :class:
LoadableTask- Abstract base for tasks withload() -> T - :class:
TargetTask- Base class for tasks with typed target outputs - :class:
Depends- Dependency injection type annotation - :func:
build- Execute task and its dependencies
See https://docs.stardag.com for full documentation.
TODO: Expand docstrings for all public API components.
TaskStruct
module-attribute
¶
target_factory_provider
module-attribute
¶
target_factory_provider = resource_provider(
type_=TargetFactory, default_factory=TargetFactory
)
BaseTask
¶
Bases: PolymorphicRoot
__init_subclass__
¶
Validate that subclasses implement either run() or run_aio().
Also wraps run() and run_aio() methods with precheck validation.
run
¶
Execute the task logic (sync).
Override this method for synchronous tasks. If you only override run_aio(), this method will automatically run it via asyncio.run().
| RETURNS | DESCRIPTION |
|---|---|
None | Generator[TaskStruct, None, None]
|
None for simple tasks, or a Generator yielding TaskStruct for |
None | Generator[TaskStruct, None, None]
|
tasks with dynamic dependencies (See Dynamic Dependencies Contract below). |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If called from within an existing event loop when only run_aio() is implemented. In that case, call run_aio() directly instead. |
NotImplementedError
|
If run_aio() is an async generator (dynamic deps). Async generators cannot be automatically converted to sync generators. |
Dynamic Dependencies Contract: When a task yields dynamic dependencies via a generator, the BUILD SYSTEM guarantees that ALL yielded tasks are COMPLETE before the generator is resumed. The task can rely on this contract:
def run(self):
# Do some initial work to get info about what additional dependencies
# are needed
initial_data = "..."
# Yield deps we need to be built first
task_a = TaskA(input=initial_data)
task_b = TaskB(input=initial_data)
yield [task_a, task_b]
# CONTRACT: When we reach here, ALL deps are complete.
# We can safely access their outputs.
result_a = task_a.target().load()
result_b = task_b.target().load()
# Yield more deps if needed
task_c = TaskC(input=result_a)
yield task_c
# Again, TaskC is complete when we reach here
self.target().save(task_c.target().load() + result_b)
This contract is essential for correctness - tasks can depend on previously yielded tasks being complete before continuing execution.
run_aio
async
¶
Execute the task logic (async).
Override this method for asynchronous tasks. If you only override run(), this method will automatically delegate to it.
For dynamic dependencies, you can use 'yield' which makes this an async generator. Note that async generator methods have different type signatures that may require type: ignore comments.
| RETURNS | DESCRIPTION |
|---|---|
None | Generator[TaskStruct, None, None]
|
None for simple tasks, or a Generator/AsyncGenerator for |
None | Generator[TaskStruct, None, None]
|
tasks with dynamic dependencies. |
Dynamic Dependencies Contract
Same as run() - the build system guarantees that ALL yielded tasks are COMPLETE before the generator is resumed. See run() docstring for detailed documentation and examples.
artifacts
¶
Return artifacts to be stored in the registry after task completion.
Override this method to expose rich outputs (reports, summaries, structured data) that will be viewable in the registry UI.
This method is called after the task completes successfully. It should be stateless - loading any required data from the task's target rather than relying on in-memory state.
| RETURNS | DESCRIPTION |
|---|---|
Sequence[Artifact]
|
Sequence of artifacts (MarkdownArtifact, JSONArtifact, etc.) |
artifacts_aio
async
¶
Asynchronously return artifacts to be stored in the registry after task completion.
resolve
classmethod
¶
Override PolymorphicRoot.resolve to handle AliasTask deserialization.
from_registry
classmethod
¶
Instantiate the task from the registry.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The UUID (or string representation) of the task to load.
TYPE:
|
registry
|
An optional registry instance to use for loading metadata. If not
provided, the default registry from
TYPE:
|
Returns: An AliasTask instance referencing the specified task.
LoadableTask
¶
Bases: BaseTask, ABC, Generic[LoadedT_co]
A task that can load its output as a typed value.
This is the minimal interface required by :class:~stardag.TaskLoads: any
BaseTask subclass that implements load() -> T is compatible with
TaskLoads[T].
Both :class:~stardag.Task (via diamond inheritance) and bare subclasses
of LoadableTask satisfy TaskLoads[T].
Subclasses must implement at least one of load() or load_aio().
The missing method will delegate to the other automatically (mirroring
the run/run_aio pattern on BaseTask).
TargetTask
¶
Bases: BaseTask, Generic[TargetType]
Base class for tasks that produce a target output.
Extends BaseTask with a typed target() method and a default complete()
implementation that checks whether the target exists.
Most users should subclass :class:~stardag.Task (which extends this class
with automatic serialization and filesystem target management) rather than
using TargetTask directly.
Task
¶
Bases: TargetTask[LoadableSaveableFileSystemTarget[LoadedT]], LoadableTask[LoadedT], ABC, Generic[LoadedT]
A base class for tasks with automatic serialization and filesystem targets.
The target of a Task is a LoadableSaveableFileSystemTarget that uses a
serializer inferred from the generic type parameter LoadedT.
The target file path is automatically constructed based on the task's namespace, name, version, and unique ID and has the following structure:
[<relpath_base>/][<namespace>/]<name>/v<version>/[<relpath_extra>/]
<id>[:2]/<id>[2:4]/<id>[/<relpath_filename>].<relpath_extension>
You can override the following properties to customize the target path:
_relpath_base, _relpath_extra, _relpath_filename, and
_relpath_extension.
See stardag.target.serialize.get_serializer for details on how the serializer
is inferred from the generic type parameter, and how to customize it.
Example:
import stardag as sd
class MyTask(sd.Task[dict[str, int]]):
def run(self):
self._save({"a": 1, "b": 2})
my_task = MyTask()
print(my_task.target())
# FileSerializable(../MyTask/03/6f/036f6e71-1b3c-54b8-aec1-182359f1e09a.json)
print(my_task.target().serializer)
# <stardag.target.serialize.JSONSerializer at 0x1064e4710>
__map_generic_args_to_ancestor__
classmethod
¶
Map generic args from Task to how they appear on an ancestor class.
This enables type compatibility checking when using Task with
polymorphic annotations like TaskLoads[T] and
SubClass[TargetTask[LoadableTarget[T]]].
| PARAMETER | DESCRIPTION |
|---|---|
ancestor_origin
|
The ancestor class to map args to
TYPE:
|
args
|
The generic args of this class (e.g., (str,) for Task[str])
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple | None
|
The mapped args for the ancestor, or None if mapping is not applicable. |
task
¶
build_aio
async
¶
build_aio(
tasks,
task_executor=None,
fail_mode=FAIL_FAST,
registry=None,
max_concurrent_discover=50,
global_lock_manager=None,
global_lock_config=None,
resume_build_id=None,
register_all=False,
on_registry_failure="raise",
)
Build tasks concurrently using hybrid async/thread/process execution.
This is the main build function for production use. It: - Discovers all tasks in the DAG(s) and registers each one with the registry as soon as it's discovered (so the full DAG is visible in the UI immediately, not progressively as tasks become runnable) - Schedules tasks for execution when dependencies are met - Handles dynamic dependencies via generator suspension - Supports multiple root tasks (built concurrently) - Routes tasks to async/thread/process based on ExecutionModeSelector - Manages all registry interactions (register/start/complete/fail task) - Optionally uses global concurrency locks for distributed execution
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
task_executor
|
TaskExecutor for executing tasks (default: HybridConcurrentTaskExecutor). Use RoutedTaskExecutor to route tasks to different executors (e.g., Modal).
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
registry
|
Registry for tracking builds (default: from registry_provider)
TYPE:
|
max_concurrent_discover
|
Maximum concurrent completion checks during DAG discovery. Higher values speed up discovery for large DAGs with remote targets.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution to ensure exactly-once execution across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
build_sequential
¶
build_sequential(
tasks,
registry=None,
fail_mode=FAIL_FAST,
dual_run_default="sync",
resume_build_id=None,
global_lock_manager=None,
global_lock_config=None,
register_all=False,
on_registry_failure="raise",
)
Sync API for building tasks sequentially.
This is intended primarily for debugging and testing.
Tasks are registered with the registry as they are discovered (in deterministic DFS order from the roots), so the full DAG appears in the UI immediately rather than progressively as tasks become runnable.
Task execution policy:
- Sync-only tasks: run via run()
- Async-only tasks: run via asyncio.run(run_aio()). (Does not work if called
from within an existing event loop.)
- Dual tasks: run via run() if dual_run_default=="sync" (default), else
(dual_run_default=="async") via asyncio.run(run_aio()).
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
registry
|
Registry for tracking builds
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
dual_run_default
|
For dual tasks, prefer sync or async execution
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution for "exactly once" semantics across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
build_sequential_aio
async
¶
build_sequential_aio(
tasks,
registry=None,
fail_mode=FAIL_FAST,
sync_run_default="blocking",
resume_build_id=None,
global_lock_manager=None,
global_lock_config=None,
register_all=False,
on_registry_failure="raise",
)
Async API for building tasks sequentially.
This is intended primarily for debugging and testing.
Tasks are registered with the registry as they are discovered (in deterministic DFS order from the roots), so the full DAG appears in the UI immediately rather than progressively as tasks become runnable.
Task execution policy:
- Sync-only tasks: runs blocking via run() in main event loop if
sync_run_default=="blocking" (default), else (sync_run_default=="thread")
in thread pool.
- Async-only tasks: run via await run_aio().
- Dual tasks: run via await run_aio().
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
registry
|
Registry for tracking builds
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
sync_run_default
|
For sync-only tasks, block or use thread pool
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution for "exactly once" semantics across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
namespace
¶
Set the task namespace for the module and any submodules.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace to set for the module.
TYPE:
|
scope
|
The module scope, typically passed as
TYPE:
|
Usage:
```python import stardag as sd sd.namespace("my_custom_namespace", name)
class MyNamespacedTask(sd.Task[int]): a: int
def run(self):
self._save(self.a)
assert MyNamespacedTask.get_namespace() == "my_custom_namespace"
auto_namespace
¶
Set the task namespace for the module to the module import path.
| PARAMETER | DESCRIPTION |
|---|---|
scope
|
The module scope, typically passed as
TYPE:
|
Usage:
get_file_target
¶
Get a file target for the given relative path.
Build Module¶
build
¶
Build module for stardag.
This module provides functions and classes for building task DAGs.
Primary build functions: - build(): Concurrent build, recommended for real workloads from a sync context - build_aio(): Async concurrent build, recommended for real workloads from an async context or already running event loop - build_sequential(): Sync sequential build (for debugging) - build_sequential_aio(): Async sequential build (for debugging)
Task executor: - HybridConcurrentTaskExecutor: Routes tasks to async/thread/process pools
Interfaces: - TaskExecutorABC: Abstract base class for custom task executors - ExecutionModeSelector: Protocol for custom execution mode selection
Global concurrency locking: - GlobalConcurrencyLockManager: Protocol for distributed lock implementations - LockHandle: Protocol for lock handles (async context manager) - GlobalLockConfig: Configuration for global locking behavior
BuildSummary
dataclass
¶
Summary of a build execution.
raise_on_failure
¶
__repr__
¶
Return a human-readable summary of the build.
Source code in stardag/build/_base.py
BuildExitStatus
¶
Bases: StrEnum
FailMode
¶
Bases: StrEnum
How to handle task failures during build.
| ATTRIBUTE | DESCRIPTION |
|---|---|
FAIL_FAST |
Stop the build at the first task failure.
|
CONTINUE |
Continue executing all tasks whose dependencies are met, even if some tasks have failed.
|
HybridConcurrentTaskExecutor
¶
HybridConcurrentTaskExecutor(
execution_mode_selector=None,
max_async_workers=10,
max_thread_workers=10,
max_process_workers=None,
)
Bases: TaskExecutorABC
Task executor with async, thread, and process pools.
Routes tasks to appropriate execution context based on ExecutionModeSelector. Handles generator suspension for dynamic dependencies.
Note: This executor does not handle registry calls - those are managed by the build() function. The executor only executes tasks and returns results.
For routing tasks to different executors (e.g., some to Modal, some local), use RoutedTaskExecutor to compose multiple executors.
Alternative: For fully async multiprocessing without thread pools, one could implement an AIOMultiprocessingTaskExecutor using libraries like aiomultiprocess.
| PARAMETER | DESCRIPTION |
|---|---|
execution_mode_selector
|
Callable to select execution mode per task.
TYPE:
|
max_async_workers
|
Maximum concurrent async tasks (semaphore-based).
TYPE:
|
max_thread_workers
|
Maximum concurrent thread pool workers.
TYPE:
|
max_process_workers
|
Maximum concurrent process pool workers.
TYPE:
|
Source code in stardag/build/_concurrent.py
setup
async
¶
Initialize worker pools.
Source code in stardag/build/_concurrent.py
teardown
async
¶
Shutdown worker pools.
Source code in stardag/build/_concurrent.py
submit
async
¶
Execute a task and return result.
Note: This method does not make any registry calls. The build function is responsible for calling start_task, complete_task, and fail_task.
Source code in stardag/build/_concurrent.py
TaskExecutorABC
¶
Bases: ABC
Abstract base for task executors.
Receives tasks and executes them according to some policy. The executor is responsible for: - Executing tasks in the appropriate context (async/thread/process) - Handling generator suspension for dynamic dependencies
The executor is NOT responsible for: - Dependency resolution - handled by build() - Registry calls (start_task, complete_task, etc.) - handled by build()
submit
abstractmethod
async
¶
Submit a task for execution.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
The task to execute.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None | TaskStruct | TaskExecutionError
|
|
None | TaskStruct | TaskExecutionError
|
|
None | TaskStruct | TaskExecutionError
|
|
Source code in stardag/build/_base.py
setup
abstractmethod
async
¶
teardown
abstractmethod
async
¶
cancel
async
¶
Best-effort cancel an in-flight task.
Default: no-op. The build loop also calls asyncio.Task.cancel()
on the future wrapping submit(), which propagates as
asyncio.CancelledError into cooperative awaitables (async
tasks, modal.Function.remote.aio). Override this for executors
that need explicit teardown beyond asyncio cooperation (e.g.
cancelling a tracked remote handle).
Effectiveness depends on the executor and how it implements
teardown(). For example, HybridConcurrentTaskExecutor
cannot reliably terminate thread- or process-pool work from
Python, AND its teardown() calls shutdown(wait=True) —
so the build will block until the underlying thread/subprocess
finishes. Async-only tasks and Modal calls do propagate the
cancellation cooperatively and unblock the build promptly.
Source code in stardag/build/_base.py
build
¶
build(
tasks,
task_executor=None,
fail_mode=FAIL_FAST,
registry=None,
max_concurrent_discover=50,
global_lock_manager=None,
global_lock_config=None,
resume_build_id=None,
register_all=False,
on_registry_failure="raise",
)
Build tasks concurrently (sync wrapper for build_aio).
This is the recommended entry point for building tasks from synchronous code. Wraps the async build_aio() function.
Note
This function cannot be called from within an already running event loop.
If you're in an async context (e.g., inside an async function, or using
frameworks like Playwright, FastAPI, etc.), use await build_aio() instead.
Source code in stardag/build/_concurrent.py
build_aio
async
¶
build_aio(
tasks,
task_executor=None,
fail_mode=FAIL_FAST,
registry=None,
max_concurrent_discover=50,
global_lock_manager=None,
global_lock_config=None,
resume_build_id=None,
register_all=False,
on_registry_failure="raise",
)
Build tasks concurrently using hybrid async/thread/process execution.
This is the main build function for production use. It: - Discovers all tasks in the DAG(s) and registers each one with the registry as soon as it's discovered (so the full DAG is visible in the UI immediately, not progressively as tasks become runnable) - Schedules tasks for execution when dependencies are met - Handles dynamic dependencies via generator suspension - Supports multiple root tasks (built concurrently) - Routes tasks to async/thread/process based on ExecutionModeSelector - Manages all registry interactions (register/start/complete/fail task) - Optionally uses global concurrency locks for distributed execution
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
task_executor
|
TaskExecutor for executing tasks (default: HybridConcurrentTaskExecutor). Use RoutedTaskExecutor to route tasks to different executors (e.g., Modal).
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
registry
|
Registry for tracking builds (default: from registry_provider)
TYPE:
|
max_concurrent_discover
|
Maximum concurrent completion checks during DAG discovery. Higher values speed up discovery for large DAGs with remote targets.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution to ensure exactly-once execution across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
Source code in stardag/build/_concurrent.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 | |
build_sequential
¶
build_sequential(
tasks,
registry=None,
fail_mode=FAIL_FAST,
dual_run_default="sync",
resume_build_id=None,
global_lock_manager=None,
global_lock_config=None,
register_all=False,
on_registry_failure="raise",
)
Sync API for building tasks sequentially.
This is intended primarily for debugging and testing.
Tasks are registered with the registry as they are discovered (in deterministic DFS order from the roots), so the full DAG appears in the UI immediately rather than progressively as tasks become runnable.
Task execution policy:
- Sync-only tasks: run via run()
- Async-only tasks: run via asyncio.run(run_aio()). (Does not work if called
from within an existing event loop.)
- Dual tasks: run via run() if dual_run_default=="sync" (default), else
(dual_run_default=="async") via asyncio.run(run_aio()).
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
registry
|
Registry for tracking builds
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
dual_run_default
|
For dual tasks, prefer sync or async execution
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution for "exactly once" semantics across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
Source code in stardag/build/_sequential.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
build_sequential_aio
async
¶
build_sequential_aio(
tasks,
registry=None,
fail_mode=FAIL_FAST,
sync_run_default="blocking",
resume_build_id=None,
global_lock_manager=None,
global_lock_config=None,
register_all=False,
on_registry_failure="raise",
)
Async API for building tasks sequentially.
This is intended primarily for debugging and testing.
Tasks are registered with the registry as they are discovered (in deterministic DFS order from the roots), so the full DAG appears in the UI immediately rather than progressively as tasks become runnable.
Task execution policy:
- Sync-only tasks: runs blocking via run() in main event loop if
sync_run_default=="blocking" (default), else (sync_run_default=="thread")
in thread pool.
- Async-only tasks: run via await run_aio().
- Dual tasks: run via await run_aio().
| PARAMETER | DESCRIPTION |
|---|---|
tasks
|
List of root tasks to build (and their dependencies) or a single root task. |
registry
|
Registry for tracking builds
TYPE:
|
fail_mode
|
How to handle task failures
TYPE:
|
sync_run_default
|
For sync-only tasks, block or use thread pool
TYPE:
|
resume_build_id
|
Optional build ID to resume. If provided, continues tracking events under this existing build instead of starting a new one.
TYPE:
|
global_lock_manager
|
Global concurrency lock manager for distributed builds. If provided with global_lock_config.enabled=True, tasks will acquire locks before execution for "exactly once" semantics across processes.
TYPE:
|
global_lock_config
|
Configuration for global locking behavior.
TYPE:
|
register_all
|
If True, discovery continues recursing into dependencies of already-complete tasks. This ensures all tasks in the DAG get registered in the registry (useful for complete DAG visualization). Default False for performance — skipping complete subgraphs avoids unnecessary I/O.
TYPE:
|
on_registry_failure
|
How to handle registry call failures. "raise" (default) propagates the exception; "warn" logs a warning and continues.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuildSummary
|
BuildSummary with status, task counts, and build_id |
Source code in stardag/build/_sequential.py
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | |
Target Module¶
target
¶
target_factory_provider
module-attribute
¶
target_factory_provider = resource_provider(
type_=TargetFactory, default_factory=TargetFactory
)
FileSystemTarget
¶
Bases: Target, Protocol
Minimal base protocol for filesystem-backed targets.
Both FileTarget (file-oriented) and DirectoryTarget (directory-oriented) implement this protocol.
FileTarget
¶
Bases: _FileTargetGeneric[bytes], Protocol
A file-oriented filesystem target with open/read/write capabilities.
Inherits all file I/O methods from _FileTargetGeneric:
open(), proxy_path(), exists(), and their async variants.
Concrete implementations: LocalFileTarget, RemoteFileTarget,
InMemoryFileTarget.
DirectoryTarget
¶
Bases: FileSystemTarget
A target representing a directory of file targets.
Manages a collection of sub-targets (files) under a common URI prefix,
with a flag file to track completion. Sub-targets are created via
get_sub_target() or the / operator.
Source code in stardag/target/_base.py
exists_aio
async
¶
mark_done_aio
async
¶
Async version of mark_done().
Source code in stardag/target/_base.py
LoadableSaveableFileSystemTarget
¶
Bases: LoadableSaveableTarget[LoadedT], FileSystemTarget, Generic[LoadedT], Protocol
A filesystem target (file or directory) that supports load/save.
This is the return type of Task.target(). It provides:
- load() -> LoadedT and save(obj: LoadedT) (from LoadableSaveableTarget)
- uri: str and exists() -> bool (from FileSystemTarget)
LocalFileTarget
¶
TargetFactory
¶
Source code in stardag/target/_factory.py
get_file_target
¶
Get a file target.
| PARAMETER | DESCRIPTION |
|---|---|
relpath
|
The path to the target, relative to the configured root path for
TYPE:
|
target_root_key
|
The key to the target root to use.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
FileTarget
|
A file target. |
Source code in stardag/target/_factory.py
get_directory_target
¶
Get a directory target.
| PARAMETER | DESCRIPTION |
|---|---|
relpath
|
The path to the target, relative to the configured root path for
TYPE:
|
target_root_key
|
The key to the target root to use.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DirectoryTarget
|
A directory target. |
Source code in stardag/target/_factory.py
get_path
¶
Get the full (/"absolute") path (/"URI") to the target.
Source code in stardag/target/_factory.py
Registry Module¶
registry
¶
Task registry module for stardag.
This module provides registry implementations for tracking task execution. The main classes are:
- RegistryABC: Abstract base class defining the registry interface
- APIRegistry: Registry that communicates with the stardag-api service
- NoOpRegistry: A do-nothing registry (default when unconfigured)
- registry_provider: Resource provider for getting the configured registry
- RegistryGlobalConcurrencyLockManager: GlobalConcurrencyLockManager using Registry API
- RegistryLockHandle: LockHandle implementation with automatic TTL renewal
registry_provider
module-attribute
¶
registry_provider = resource_provider(
RegistryABC, init_registry
)
APIRegistry
¶
Bases: RegistryABC
Registry that stores task information via the stardag-api REST service.
This registry is stateless with respect to build_id - the build_id is passed explicitly to all methods that need it. This allows a single registry instance to be reused across multiple builds (via registry_provider).
Usage
build_id = await registry.build_start_aio(root_tasks=tasks) await registry.task_register_aio(build_id, task) await registry.task_start_aio(build_id, task)
... execute task ...¶
await registry.task_complete_aio(build_id, task) await registry.build_complete_aio(build_id)
Authentication: - API key can be provided directly or via STARDAG_API_KEY env var - JWT token from browser login (stored in registry credentials)
Configuration is loaded from the central config module (stardag.config).
Source code in stardag/registry/_api_registry.py
async_client
property
¶
Lazy-initialized async HTTP client with retry transport.
The client is recreated if the event loop changes, which can happen when running in frameworks like Prefect that create new event loops for task execution.
build_start
¶
Start a new build and return its ID.
Source code in stardag/registry/_api_registry.py
build_resume
¶
Mark an existing build as resumed.
Emits a BUILD_RESUMED event server-side so a build that previously terminated (FAILED / COMPLETED / CANCELLED / EXIT_EARLY) flips back to RUNNING. The endpoint is new in the post-resume API; on older servers the request 404s with FastAPI's missing-route body, which we swallow with a warning so the SDK keeps working against an un-upgraded registry. Resource-level 404s (build does not exist) are re-raised.
Source code in stardag/registry/_api_registry.py
build_complete
¶
Mark a build as completed.
Source code in stardag/registry/_api_registry.py
build_fail
¶
Mark a build as failed.
Source code in stardag/registry/_api_registry.py
build_cancel
¶
Cancel a build.
Source code in stardag/registry/_api_registry.py
build_exit_early
¶
Mark a build as exited early.
Source code in stardag/registry/_api_registry.py
task_register
¶
Register a task within a build.
Source code in stardag/registry/_api_registry.py
task_register_bulk
¶
Bulk-register tasks via the /tasks/bulk endpoint.
Falls back to per-task task_register if the API doesn't
support the endpoint (older deployments) — same backwards-compat
pattern as task_add_dependencies.
Raises ValueError if the batch exceeds
_MAX_BULK_REGISTER_TASKS (mirrors the server cap). The build
engine chunks above this method; external callers of
APIRegistry get an explicit client-side error rather than a
400 from the server.
Passes ?id_only=true so the server returns only the
{id, task_id} mapping rather than echoing back full
TaskResponse rows we'd discard anyway. Cuts response size
by ~10× for batches with rich task_data.
Source code in stardag/registry/_api_registry.py
task_start
¶
Mark a task as started.
Caller must have already registered the task (via task_register or
as a side effect of a parent's static-deps reconciliation). The /start
endpoint will 404 otherwise.
Source code in stardag/registry/_api_registry.py
task_complete
¶
Mark a task as completed.
Source code in stardag/registry/_api_registry.py
task_fail
¶
Mark a task as failed.
Source code in stardag/registry/_api_registry.py
task_suspend
¶
Mark a task as suspended (waiting for dynamic dependencies).
Source code in stardag/registry/_api_registry.py
task_add_dependencies
¶
Record dependency edges for a task.
Backward-compat: an older Registry API that lacks the
/dependencies endpoint returns FastAPI's default 404 with the
generic "Not Found" detail. We swallow that specific response
with a warning so builds don't break on version skew. All other
404s (e.g. our endpoint's explicit "Build not found" or
"Task … not registered …" responses) re-raise normally.
Source code in stardag/registry/_api_registry.py
task_resume
¶
Mark a task as resumed (dynamic dependencies completed).
Source code in stardag/registry/_api_registry.py
task_cancel
¶
Cancel a task.
Source code in stardag/registry/_api_registry.py
task_skip
¶
Skip a task whose dependency failed or was cancelled.
Backward-compat: an older Registry API that lacks the /skip
endpoint returns FastAPI's default 404 with the generic
"Not Found" detail. We swallow that specific response with a
warning so a new SDK against an old API doesn't fail builds on
every fail-fast / blocked-dep path. All other 404s (e.g.
"Build not found") re-raise normally.
Source code in stardag/registry/_api_registry.py
task_waiting_for_lock
¶
Record that a task is waiting for a global lock.
Source code in stardag/registry/_api_registry.py
task_upload_artifacts
¶
Upload artifacts for a completed task.
Source code in stardag/registry/_api_registry.py
task_get_metadata
¶
Get metadata for a registered task.
| PARAMETER | DESCRIPTION |
|---|---|
task_id
|
The UUID of the task to get metadata for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TaskMetadata
|
A TaskMetadata object containing task metadata. |
Source code in stardag/registry/_api_registry.py
close
¶
aclose
async
¶
build_start_aio
async
¶
Async version - start a new build and return its ID.
Source code in stardag/registry/_api_registry.py
build_resume_aio
async
¶
Async version - mark an existing build as resumed.
See :meth:build_resume for the backward-compat 404 handling.
Source code in stardag/registry/_api_registry.py
build_complete_aio
async
¶
Async version - mark a build as completed.
Source code in stardag/registry/_api_registry.py
build_fail_aio
async
¶
Async version - mark a build as failed.
Source code in stardag/registry/_api_registry.py
build_cancel_aio
async
¶
Async version - cancel a build.
Source code in stardag/registry/_api_registry.py
build_exit_early_aio
async
¶
Async version - mark build as exited early.
Source code in stardag/registry/_api_registry.py
task_register_aio
async
¶
Async version - register a task within a build.
Source code in stardag/registry/_api_registry.py
task_register_bulk_aio
async
¶
Async bulk-register via /tasks/bulk (one HTTP call instead of N).
Falls back to per-task task_register_aio if the API doesn't
support the endpoint (older deployments).
Raises ValueError if the batch exceeds
_MAX_BULK_REGISTER_TASKS (mirrors the server cap). The build
engine chunks above this method; external callers get an
explicit client-side error rather than a 400 from the server.
Passes ?id_only=true so the server returns only the
{id, task_id} mapping rather than echoing full TaskResponse
rows that we discard. Cuts response size by ~10× for batches
with rich task_data.
Source code in stardag/registry/_api_registry.py
task_start_aio
async
¶
Async version - mark a task as started.
Caller must have already registered the task (via task_register_aio
or as a side effect of a parent's static-deps reconciliation). The
/start endpoint will 404 otherwise.
Source code in stardag/registry/_api_registry.py
task_complete_aio
async
¶
Async version - mark a task as completed.
Source code in stardag/registry/_api_registry.py
task_fail_aio
async
¶
Async version - mark a task as failed.
Source code in stardag/registry/_api_registry.py
task_suspend_aio
async
¶
Async version - mark a task as suspended.
Source code in stardag/registry/_api_registry.py
task_add_dependencies_aio
async
¶
Async version - record dependency edges for a task.
Same backward-compat behavior as the sync version: only swallow
the specific "missing route" 404 (FastAPI default "Not Found");
re-raise genuine resource-not-found 404s.
Source code in stardag/registry/_api_registry.py
task_resume_aio
async
¶
Async version - mark a task as resumed.
Source code in stardag/registry/_api_registry.py
task_cancel_aio
async
¶
Async version - cancel a task.
Source code in stardag/registry/_api_registry.py
task_skip_aio
async
¶
Async version - skip a task whose dep failed or was cancelled.
See :meth:task_skip for the backward-compat 404 handling.
Source code in stardag/registry/_api_registry.py
task_waiting_for_lock_aio
async
¶
Async version - record that task is waiting for global lock.
Source code in stardag/registry/_api_registry.py
task_upload_artifacts_aio
async
¶
Async version - upload artifacts for a completed task.
Source code in stardag/registry/_api_registry.py
task_get_metadata_aio
async
¶
Async version of task_get_metadata.
Source code in stardag/registry/_api_registry.py
RegistryABC
¶
Abstract base class for task registries.
A registry tracks task execution within builds. Implementations must
provide at least the task_register method. All other methods have default
no-op implementations for backwards compatibility.
The registry is stateless with respect to build_id - the build_id is passed explicitly to all methods that need it. This allows a single registry instance to be reused across multiple builds.
Method naming convention:
- Build methods: build_
build_start
¶
Start a new build session.
Called at the beginning of a build. Returns a build ID.
| PARAMETER | DESCRIPTION |
|---|---|
root_tasks
|
The root tasks being built
TYPE:
|
description
|
Optional description of the build
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UUID
|
Build ID (UUID) for the new build session. |
Source code in stardag/registry/_base.py
build_resume
¶
Mark an existing build as resumed.
Called when sd.build(resume_build_id=...) reuses an existing
build (potentially in a terminal state) instead of starting a new
one. The registry should record a BUILD_RESUMED event so the
build flips back to RUNNING and the UI can surface a
"running (resumed)" affordance.
Default implementation is a no-op so older registry backends keep working unchanged.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID being resumed.
TYPE:
|
Source code in stardag/registry/_base.py
build_complete
¶
Mark a build as completed successfully.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
build_fail
¶
Mark a build as failed.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
error_message
|
Optional error message describing the failure.
TYPE:
|
Source code in stardag/registry/_base.py
build_cancel
¶
Cancel a build.
Called when a build is explicitly cancelled by the user.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
build_exit_early
¶
Mark a build as exited early.
Called when all remaining tasks are running in other builds and this build should stop waiting.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
reason
|
Optional reason for exiting early.
TYPE:
|
Source code in stardag/registry/_base.py
task_register
abstractmethod
¶
Register a task as pending/scheduled.
This is called when a task is about to be executed.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task to register.
TYPE:
|
Source code in stardag/registry/_base.py
task_register_bulk
¶
Register many tasks to a build in a single call.
Default implementation falls back to task_register per task —
backends that can batch (e.g. the API registry's bulk endpoint)
should override this to make one HTTP call instead of N.
Order of tasks is significant: the SDK's post-order discover
walk emits deps before parents so that dependency_task_ids
lookups inside the registry resolve to existing rows (no phantom
creation). Backends that process the batch as one transaction
should preserve array order.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
tasks
|
Tasks to register, in registration order.
TYPE:
|
Source code in stardag/registry/_base.py
task_start
¶
Mark a task as started/running.
Called immediately before a task begins execution. The caller is
responsible for having already registered the task in the build —
task_start only emits the started event.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task that is starting.
TYPE:
|
Source code in stardag/registry/_base.py
task_complete
¶
Mark a task as completed successfully.
Called after a task finishes execution without errors.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task that completed.
TYPE:
|
Source code in stardag/registry/_base.py
task_fail
¶
Mark a task as failed.
Called when a task raises an exception during execution.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task that failed.
TYPE:
|
error_message
|
Optional error message describing the failure.
TYPE:
|
Source code in stardag/registry/_base.py
task_suspend
¶
Mark a task as suspended waiting for dynamic dependencies.
Called when a task yields dynamic deps that are not yet complete. The task will remain suspended until its dynamic deps are built.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task that is suspended.
TYPE:
|
Source code in stardag/registry/_base.py
task_add_dependencies
¶
Record dependency edges for a task.
Called by the build system when a task yields dynamic deps — the
edges aren't known at task_register time (static requires()
chain only), so this is how they reach the registry so that the
full DAG renders correctly in the UI.
Registries that can't write to a graph (the in-memory cases) may treat this as a no-op. HTTP-backed implementations should tolerate 404 from older API versions that don't support the endpoint.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The downstream task whose deps are being added.
TYPE:
|
upstream_tasks
|
The yielded deps to record as edges.
TYPE:
|
is_dynamic
|
Marks the edges as dynamic (True by default —
static
TYPE:
|
Source code in stardag/registry/_base.py
task_resume
¶
Mark a task as resumed after dynamic dependencies completed.
Called when a task's dynamic dependencies are complete and the task is ready to continue execution (either by resuming a suspended generator or by re-executing the task).
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task that is resuming.
TYPE:
|
Source code in stardag/registry/_base.py
task_cancel
¶
Cancel a task.
Called when a task is cancelled — by the user, or by the build engine when terminating in-flight siblings on a fail-fast failure.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task to cancel.
TYPE:
|
Source code in stardag/registry/_base.py
task_skip
¶
Mark a task as skipped.
Called when a task will not run because a dependency failed or
was cancelled. Distinct from task_cancel: skipped tasks
never started executing.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task to skip.
TYPE:
|
Source code in stardag/registry/_base.py
task_waiting_for_lock
¶
Record that a task is waiting for a global lock.
Called when a task cannot acquire its lock because another build is holding it.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The task waiting for the lock.
TYPE:
|
lock_owner
|
Optional identifier of who holds the lock.
TYPE:
|
Source code in stardag/registry/_base.py
task_upload_artifacts
¶
Upload artifacts for a completed task.
Called after a task completes successfully if it has artifacts.
| PARAMETER | DESCRIPTION |
|---|---|
build_id
|
The build UUID returned by build_start.
TYPE:
|
task
|
The completed task.
TYPE:
|
artifacts
|
List of artifacts to upload.
TYPE:
|
Source code in stardag/registry/_base.py
task_get_metadata
abstractmethod
¶
Get metadata for a registered task.
| PARAMETER | DESCRIPTION |
|---|---|
task_id
|
The ID of the task to get metadata for.
TYPE:
|
Returns: A TaskMetadata object containing task metadata.
Source code in stardag/registry/_base.py
build_start_aio
async
¶
Async version of build_start.
build_resume_aio
async
¶
build_complete_aio
async
¶
build_fail_aio
async
¶
build_cancel_aio
async
¶
build_exit_early_aio
async
¶
task_register_aio
async
¶
task_register_bulk_aio
async
¶
Async version of task_register_bulk.
Default implementation falls back to task_register_aio per
task. Override for backends that can batch (the API registry
does so with the /tasks/bulk endpoint).
Source code in stardag/registry/_base.py
task_start_aio
async
¶
task_complete_aio
async
¶
task_fail_aio
async
¶
task_suspend_aio
async
¶
task_add_dependencies_aio
async
¶
Async version of task_add_dependencies.
Source code in stardag/registry/_base.py
task_resume_aio
async
¶
task_cancel_aio
async
¶
task_skip_aio
async
¶
task_waiting_for_lock_aio
async
¶
Async version of task_waiting_for_lock.
task_upload_artifacts_aio
async
¶
Async version of task_upload_artifacts.
NoOpRegistry
¶
Bases: RegistryABC
A registry that does nothing.
Used as a default when no registry is configured.
build_start
¶
Configuration¶
config
¶
Centralized configuration for Stardag SDK.
This module provides a unified configuration system that consolidates: - Target factory settings (target roots) - Registry settings (URL, workspace, environment, auth, timeout) - Config context (provenance: which profile/registry name was used)
Configuration is loaded from multiple sources with the following priority: 1. Environment variables (STARDAG_*) 2. Project config (.stardag/config.toml in working directory or parents) 3. User config (~/.stardag/config.toml) 4. Defaults
Usage
from stardag.config import get_config
config = get_config() if config.registry: print(config.registry.url) print(config.target.roots)
Environment Variables (highest priority): STARDAG_PROFILE - Profile name to use (looks up in config.toml) STARDAG_API_URL - Registry API URL override STARDAG_REGISTRY_URL - Deprecated alias for STARDAG_API_URL STARDAG_WORKSPACE_ID - Direct workspace ID override STARDAG_ENVIRONMENT_ID - Direct environment ID override STARDAG_API_KEY - API key for authentication STARDAG_TARGET_ROOTS - JSON dict of target roots (override) STARDAG_NO_REGISTRY - Set to 1/true to force offline/local mode
load_config
¶
Load configuration from all sources.
Priority (highest to lowest): 1. Environment variables (STARDAG_*) 2. Project config (.stardag/config.toml in repo) 3. User config (~/.stardag/config.toml) 4. Defaults
| PARAMETER | DESCRIPTION |
|---|---|
use_project_config
|
Whether to load .stardag/config.toml from project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StardagConfig
|
Fully resolved StardagConfig (actual type is StardagConfig). |
Source code in stardag/config/loader.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |