Skip to content

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 = None

CMake构建并发;不改变目标内容身份。

实现位置: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

编译或工程生成操作中的一次阶段事件。

参数

名称类型默认值说明
stagestr—事件所属阶段。
status_CompilationEventStatus—started、completed、cache_hit、cache_miss、waiting、warning或failed。
elapsed_secondsfloat | NoneNone该阶段耗时(秒),未知时为 None。
messagestr''可读说明,默认空字符串。
detailsMapping[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

编译模型或生成工程保留的结构化结果。

参数

名称类型默认值说明
operationLiteral['compile', 'codegen']—操作种类,编译或代码生成。
namestr—模型名称。
targetstr—目标后端或工程位置。
total_secondsfloat—操作总耗时(秒)。
eventstuple[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