fly_ruler_core.operation
本页由
fr-docs-dev gen-api从源码 docstring 生成,请勿手工编辑;重新生成执行just api。
后端编译与第二阶段代码生成的结构化进度事件。
FlyRuler 首先是库,因此除非调用方显式开启,编译必须保持安静。同时,大型飞行器模型的单次无差别停顿是不可接受的:用户需要知道进程是在等待 artifact 锁、编译 Rust 计划、下沉后端、重建 CasADi 函数,还是调用本地工具链。
本模块为这些阶段提供共享数据模型与终端渲染器。数值与编译模块上报有类型的事件,不直接打印。因此即使禁用终端输出,CompilationReport 仍然可用,并为未来的 IDE 与图集成提供稳定的耗时和缓存信息。
公开成员
| 名称 | 类型 | 定义位置 |
|---|---|---|
OperationContext | 类 | 本页 |
CompilationEvent | 类 | 本页 |
CompilationReport | 类 | 本页 |
CompilationVerbosity | 类型别名 | 本页 |
定义
OperationContext
python
class OperationContext(store: Path | None = None, cache: Literal['reuse', 'refresh', 'readonly'] = 'reuse', verbosity: CompilationVerbosity = 'quiet', color: bool = True, parallel_jobs: int | None = None, build_verbose: bool = False, stream_output: bool = True)单次操作的显式存储、缓存策略和报告设置。
store
python
store: Path | None = None可写缓存根;None表示由操作持有临时工作目录。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:276
cache
python
cache: Literal['reuse', 'refresh', 'readonly'] = 'reuse'复用、重建或只读;只读必须给出显式store。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:278
verbosity
python
verbosity: CompilationVerbosity = 'quiet'编译事件的终端报告详细程度。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:280
color
python
color: bool = True是否启用终端报告颜色。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:282
parallel_jobs
python
parallel_jobs: int | None = NoneCMake构建并发;不改变目标内容身份。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:285
build_verbose
python
build_verbose: bool = False是否记录实际编译与链接命令。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:287
stream_output
python
stream_output: bool = True是否同步CMake输出;完整日志仍保存。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:289
__init__
python
def __init__(store: Path | None = None, cache: Literal['reuse', 'refresh', 'readonly'] = 'reuse', verbosity: CompilationVerbosity = 'quiet', color: bool = True, parallel_jobs: int | None = None, build_verbose: bool = False, stream_output: bool = True) -> None实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:272
CompilationEvent
python
class CompilationEvent编译或工程生成操作中的一次阶段事件。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
stage | str | — | 事件所属阶段。 |
status | _CompilationEventStatus | — | started、completed、cache_hit、cache_miss、waiting、warning或failed。 |
elapsed_seconds | float | None | None | 该阶段耗时(秒),未知时为 None。 |
message | str | '' | 可读说明,默认空字符串。 |
details | Mapping[str, str | int | float | bool] | dict() | 附加的标量细节,默认空字典。 |
stage
python
stage: str事件所属阶段。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:77
status
python
status: _CompilationEventStatus阶段开始、完成、缓存命中/缺失、等待、告警或失败状态。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:79
elapsed_seconds
python
elapsed_seconds: float | None = None该阶段耗时(秒),未知时为 None。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:81
message
python
message: str = ''可读说明。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:83
details
python
details: Mapping[str, str | int | float | bool] = field(default_factory=dict)附加的标量细节。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:85
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:65
CompilationReport
python
class CompilationReport编译模型或生成工程保留的结构化结果。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
operation | Literal['compile', 'codegen'] | — | 操作种类,编译或代码生成。 |
name | str | — | 模型名称。 |
target | str | — | 目标后端或工程位置。 |
total_seconds | float | — | 操作总耗时(秒)。 |
events | tuple[CompilationEvent, ...] | — | 按发生顺序记录的事件元组。 |
operation
python
operation: Literal['compile', 'codegen']操作种类。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:105
name
python
name: str模型名称。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:107
target
python
target: str目标后端或工程位置。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:109
total_seconds
python
total_seconds: float操作总耗时(秒)。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:111
events
python
events: tuple[CompilationEvent, ...]按发生顺序记录的事件元组。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:113
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:93
CompilationVerbosity
python
type CompilationVerbosity = Literal['quiet', 'summary', 'detailed', 'debug']编译输出详细程度,决定哪些事件被打印。
实现位置:packages/fly_ruler/python/fly_ruler_core/operation.py:33