fly_ruler_core.artifacts
本页由
fr-docs-dev gen-api从源码 docstring 生成,请勿手工编辑;重新生成执行just api。
模型程序、生成目标与源码工程的文件闭包入口。
产物层统一角色、描述、文件完整性、闭包保存与发布。编译器返回模型或目标程序,执行实例由 runtime.bind 独立创建。open 提供轻量只读视图;read_program 和 read_target 恢复阶段事实;save 交付可搬迁的完整闭包。
公开成员
定义
Artifact
python
class Artifact已验证清单及其全部依赖的不可变视图。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
kind | ArtifactKind | — | artifact 种类。 |
key | str | — | artifact 内容键。 |
path | Path | — | artifact 目录。 |
cache_hit | bool | — | 是否来自缓存命中。 |
files | Mapping[ArtifactFile, Path] | — | 文件角色到路径的映射。 |
dependencies | Mapping[str, Artifact] | — | 依赖名到 artifact 的映射。 |
metadata | Mapping[str, object] | — | 该 artifact 的元数据。 |
NOTE
files 是本 artifact 与其依赖暴露文件的并集。存储在加载时拒绝重复角色,因此即使在后端或本地 artifact 上调用 file(ArtifactFile.COMPILED_PLAN) 也没有歧义。dependencies 保留具名图,供需要来源而不是文件的调用方使用。
kind
python
kind: ArtifactKindartifact 种类。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:114
key
python
key: strartifact 内容键。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:116
path
python
path: Pathartifact 目录。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:118
cache_hit
python
cache_hit: bool是否来自缓存命中。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:120
files
python
files: Mapping[ArtifactFile, Path]文件角色到路径的映射。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:122
dependencies
python
dependencies: Mapping[str, Artifact]依赖名到 artifact 的映射。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:124
metadata
python
metadata: Mapping[str, object]该 artifact 的元数据。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:126
manifest_path
python
manifest_path: Path返回生成该描述的清单路径。
返回
| 类型 | 说明 |
|---|---|
Path | artifact 目录下的 manifest.json。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:142
file
python
def file(role: ArtifactFile) -> Path返回依赖图中该角色对应的唯一文件。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
role | ArtifactFile | — | 文件角色。 |
返回
| 类型 | 说明 |
|---|---|
Path | 该角色对应的文件路径。 |
异常
| 类型 | 说明 |
|---|---|
KeyError | 依赖图中不存在该文件角色。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:150
dependency
python
def dependency(kind: str) -> Artifact返回指定种类的唯一直接或传递依赖。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
kind | str | — | 目标 artifact 种类。 |
返回
| 类型 | 说明 |
|---|---|
Artifact | 匹配的依赖 artifact。 |
异常
| 类型 | 说明 |
|---|---|
KeyError | 依赖图中不存在该种类。 |
ValueError | 该种类的依赖多于一个,无法确定唯一结果。 |
NOTE
清单里的依赖名描述边(例如 backend),而 Artifact.kind 描述节点。按节点种类查询,使中间 artifact 新增不同名的边时公开查询保持稳定。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:169
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:94
ArtifactKind
python
type ArtifactKind = Literal['system', 'plan', 'program', 'native', 'project', 'bundle', 'model-program', 'target-program', 'source-project']artifact 种类字面量。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:17
ArtifactCachePolicy
python
type ArtifactCachePolicy = Literal['reuse', 'refresh', 'readonly']缓存策略字面量。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:29
open
python
def open(path: str | Path) -> ArtifactReader打开轻量只读产物视图。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
path | str | Path | — | 当前格式产物目录或manifest.json路径。 |
返回
| 类型 | 说明 |
|---|---|
ArtifactReader | 只消费请求文件、不加载执行引擎的读取器。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:52
read_program
python
def read_program(path: str | Path) -> ModelProgram从闭合产物恢复模型计划、设置与资源,不绑定运行后端。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
path | str | Path | — | 模型、目标或工程产物目录或manifest.json。 |
返回
| 类型 | 说明 |
|---|---|
ModelProgram | 不依赖原始Python模型构造函数的ModelProgram。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:64
read_target
python
def read_target(path: str | Path) -> TargetProgram恢复确定目标的文件闭包与模型事实。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
path | str | Path | — | 保存的目标目录或 manifest.json 路径。 |
返回
| 类型 | 说明 |
|---|---|
TargetProgram | 已校验的目标程序及其模型事实;执行函数由 runtime.bind 另行绑定。 |
异常
| 类型 | 说明 |
|---|---|
ValueError | 产物不是受支持的目标,或声明的文件损坏。 |
FileNotFoundError | 闭包中声明的文件缺失。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:78
save
python
def save(value: ModelProgram | TargetProgram[object], *, output_dir: str | Path, overwrite: bool = False) -> Path将模型或目标文件闭包原子保存到可搬迁目录。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
value | ModelProgram | TargetProgram[object] | — | ModelProgram或TargetProgram,不接受当前运行状态。 |
output_dir | str | Path | — | 完整产物输出目录。 |
overwrite | bool | False | 是否替换非空输出目录。 |
返回
| 类型 | 说明 |
|---|---|
Path | 保存目录的绝对路径。 |
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:96
ArtifactFile
python
class ArtifactFile(StrEnum)artifact 存储发布文件的稳定角色。
SYSTEM_IR
python
SYSTEM_IR = 'system_ir'系统 IR 定义。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:36
ASSETS
python
ASSETS = 'assets'外置载荷压缩包。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:38
COMPILED_PLAN
python
COMPILED_PLAN = 'compiled_plan'序列化后的编译计划。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:40
PREPARED_RESOURCES
python
PREPARED_RESOURCES = 'prepared_resources'后端无关的资源数学准备结果。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:42
PLAN_SUMMARY
python
PLAN_SUMMARY = 'plan_summary'计划摘要与维度信息。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:44
BACKEND_SOURCE
python
BACKEND_SOURCE = 'backend_source'生成的后端源码。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:46
LAYOUT
python
LAYOUT = 'layout'状态与输入布局说明。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:48
CASADI_FUNCTION_GRAPH
python
CASADI_FUNCTION_GRAPH = 'casadi_function_graph'统一序列化的 CasADi 入口集合,保留各入口之间的共享函数身份。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:50
CONTINUOUS_FUNCTION
python
CONTINUOUS_FUNCTION = 'continuous_function'连续部分函数。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:52
DISCRETE_FUNCTION
python
DISCRETE_FUNCTION = 'discrete_function'离散部分函数。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:54
CONSTRAIN_FUNCTION
python
CONSTRAIN_FUNCTION = 'constrain_function'约束函数。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:56
OBSERVE_FUNCTION
python
OBSERVE_FUNCTION = 'observe_function'纯观测 CasADi 函数。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:58
FLOW_FUNCTION
python
FLOW_FUNCTION = 'flow_function'可变时长连续流函数。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:60
NATIVE_MODULE
python
NATIVE_MODULE = 'native_module'编译好的本地模块。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:62
NATIVE_RESOURCE_DESCRIPTION
python
NATIVE_RESOURCE_DESCRIPTION = 'native_resource_description'native只读资源布局、模式与ABI描述。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:64
NATIVE_RESOURCES
python
NATIVE_RESOURCES = 'native_resources'C++初始化读取的模型绑定NPZ。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:66
NATIVE_RESOURCE_BUILD
python
NATIVE_RESOURCE_BUILD = 'native_resource_build'资源adapter及二进制对象的可重建输入归档。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:68
GENERATED_C_SOURCE
python
GENERATED_C_SOURCE = 'generated_c_source'生成的 C 源码。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:70
GENERATED_C_UNITS
python
GENERATED_C_UNITS = 'generated_c_units'C 编译单元、内部头文件与依赖计划的可搬迁源码归档。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:72
GENERATED_C_HEADER
python
GENERATED_C_HEADER = 'generated_c_header'生成的 C 头文件。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:74
WRAPPER_SOURCE
python
WRAPPER_SOURCE = 'wrapper_source'本地模块包装源码。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:76
CMAKE_PROJECT
python
CMAKE_PROJECT = 'cmake_project'CMake 工程文件。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:78
PROJECT_INVENTORY
python
PROJECT_INVENTORY = 'project_inventory'生成工程文件的相对路径、大小和内容校验清单。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:80
DEPLOYMENT_INFO
python
DEPLOYMENT_INFO = 'deployment_info'部署 ABI 的维度与资源条件描述。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:82
MODEL_INFO
python
MODEL_INFO = 'model_info'模型元信息。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:84
README
python
README = 'readme'产物说明文档。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:86
CONFIGURE_LOG
python
CONFIGURE_LOG = 'configure_log'配置阶段日志。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:88
BUILD_LOG
python
BUILD_LOG = 'build_log'构建阶段日志。
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:90
实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:33