配置¶
AstrumConfig 是调度器的集中配置对象。它控制类型检查、数据传输补全、Rich 可视化、日志静默、并发限制和末端任务等待策略。
astrum.config.AstrumConfig
dataclass
¶
AstrumConfig(skip_type_check: bool = False, infer_via_ast: bool = False, strict_topology: bool = False, allow_no_dir_definition: bool = True, auto_sync_dependencies: bool = True, visualize: bool = False, silence_warnings: bool = False, silence: bool = True, concurrency_limit: int | None = None, ignore_tail_task: list[str] = list())
Astrum 调度引擎一站式配置对象。
所有参数均有安全的默认值,用户可按需覆盖。
类型检查 / AST 推断
skip_type_check– 跳过allow_data_model的类型匹配校验。 开启后 DataItem 上的类型约束将不会生效。默认False。infer_via_ast– 在函数缺少返回值注解 (-> type) 时,自动使用 AST 静态分析来推断返回类型。默认False。strict_topology– 严格拓扑校验模式。当True时,如果 data transport 推导出的 from/to 关系没有在TaskData.from_tasks/to_tasks中显式声明就会报错。默认False。
数据传输
allow_no_dir_definition– 允许 DataItem 缺少来源或去向定义。 在使用装饰器模式时通常设为True,因为框架会自动补全;手动模式下 设为False可以捕捉用户遗漏。默认True。auto_sync_dependencies– 自动将 data transport 推导出来的from_tasks关系同步回任务图的dependencies。关闭后需用户 手动声明depends_on。默认True。
可视化
visualize– 在 DAG 构建完成后是否使用 Rich 在终端打印 DAG 树和 Data Transport Matrix。默认False。silence_warnings– 静默自动补全过程中的 DEBUG/WARNING 日志输出 (如 "undeclared relation has been automatically declared")。默认False。
执行引擎
silence– 静默模式。当为True时调度器不输出执行期日志。 默认True。concurrency_limit– 全局并发限制。设为None表示不限制; 设为正整数 N 时,内部自动创建asyncio.Semaphore(N)。默认None。ignore_tail_task– 执行完成后不等待的末端任务列表。默认空列表。
Astrum's one-stop configuration object for the scheduling engine.
All parameters have safe defaults and can be overridden as needed.
Type checking / AST inference
skip_type_check– Skip type matching validation forallow_data_model. When enabled, type constraints on DataItem will not take effect. Defaults toFalse.infer_via_ast– When a function lacks a return value annotation (-> type), automatically use AST static analysis to infer the return type. Defaults toFalse.strict_topology– Strict topology validation mode. WhenTrue, an error is raised if from/to relations inferred by data transport are not explicitly declared inTaskData.from_tasks/to_tasks. Defaults toFalse.
Data transport
allow_no_dir_definition– Allow DataItem to lack source or destination definitions. This is usually set toTruein decorator mode because the framework completes them automatically; in manual mode, setting it toFalsecan catch omissions. Defaults toTrue.auto_sync_dependencies– Automatically syncfrom_tasksrelations inferred by data transport back to the task graph'sdependencies. When disabled, users must manually declaredepends_on. Defaults toTrue.
Visualization
visualize– Whether to use Rich to print the DAG tree and Data Transport Matrix in the terminal after DAG construction completes. Defaults toFalse.silence_warnings– Silence DEBUG/WARNING log output during automatic completion, such as "undeclared relation has been automatically declared". Defaults toFalse.
Execution engine
silence– Silence mode. WhenTrue, the scheduler does not output execution-time logs. Defaults toTrue.concurrency_limit– Global concurrency limit. Set toNonefor no limit; set to a positive integer N to automatically createasyncio.Semaphore(N)internally. Defaults toNone.ignore_tail_task– List of tail tasks not to wait for after execution completes. Defaults to an empty list.
build_semaphore ¶
根据 concurrency_limit 创建信号量对象。
Create a semaphore object according to concurrency_limit.