Skip to content

fly_ruler_core.artifacts ​

本页由 fr-docs-dev gen-api 从源码 docstring 生成,请勿手工编辑;重新生成执行 just api。

模型程序、生成目标与源码工程的文件闭包入口。

产物层统一角色、描述、文件完整性、闭包保存与发布。编译器返回模型或目标程序,执行实例由 runtime.bind 独立创建。open 提供轻量只读视图;read_program 和 read_target/read_project 恢复阶段事实;save 交付可搬迁的完整闭包。

公开成员 ​

名称类型定义位置
SourceProject类fly_ruler_core.artifacts.project
CppInterface类fly_ruler_core.artifacts.project
ProjectDescription类fly_ruler_core.artifacts.project
read_project函数本页
BlockRepresentation类fly_ruler_core.artifacts.generation
EntryOptimization类fly_ruler_core.artifacts.optimization
OptimizationReport类fly_ruler_core.artifacts.optimization
TargetProgram类fly_ruler_core.artifacts.target
TargetDescription类fly_ruler_core.artifacts.target
TargetKind类fly_ruler_core.artifacts.target
ArgumentContract类fly_ruler_core.artifacts.target
EntryContract类fly_ruler_core.artifacts.target
Artifact类本页
ArtifactKind类型别名本页
ArtifactCachePolicy类型别名本页
open函数本页
read_program函数本页
read_target函数本页
save函数本页
ArtifactReader类fly_ruler_core.artifacts.reader
ArtifactFile类本页

定义 ​

read_project ​

python
def read_project(path: str | Path) -> SourceProject

恢复源码工程及其模型事实,不导入原提供者、不重新生成或构建。

参数

名称类型默认值说明
pathstr | Path—工程目录或 manifest.json 路径。

返回

类型说明
SourceProject校验通过的 SourceProject,路径与构建提示对应当前目录。

异常

类型说明
ValueError类型、版本、工程事实或文件闭包不一致。
FileNotFoundError库存声明的文件缺失。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:106

Artifact ​

python
class Artifact

已验证清单及其全部依赖的不可变视图。

参数

名称类型默认值说明
kindArtifactKind—artifact 种类。
keystr—artifact 内容键。
pathPath—artifact 目录。
cache_hitbool—是否来自缓存命中。
filesMapping[ArtifactFile, Path]—文件角色到路径的映射。
dependenciesMapping[str, Artifact]—依赖名到 artifact 的映射。
metadataMapping[str, object]—该 artifact 的元数据。

NOTE

files 是本 artifact 与其依赖暴露文件的并集。存储在加载时拒绝重复角色,因此即使在后端或本地 artifact 上调用 file(ArtifactFile.COMPILED_PLAN) 也没有歧义。dependencies 保留具名图,供需要来源而不是文件的调用方使用。

kind ​

python
kind: ArtifactKind

artifact 种类。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:99

key ​

python
key: str

artifact 内容键。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:101

path ​

python
path: Path

artifact 目录。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:103

cache_hit ​

python
cache_hit: bool

是否来自缓存命中。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:105

files ​

python
files: Mapping[ArtifactFile, Path]

文件角色到路径的映射。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:107

dependencies ​

python
dependencies: Mapping[str, Artifact]

依赖名到 artifact 的映射。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:109

metadata ​

python
metadata: Mapping[str, object]

该 artifact 的元数据。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:111

manifest_path ​

python
manifest_path: Path

返回生成该描述的清单路径。

返回

类型说明
Pathartifact 目录下的 manifest.json。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:127

file ​

python
def file(role: ArtifactFile) -> Path

返回依赖图中该角色对应的唯一文件。

参数

名称类型默认值说明
roleArtifactFile—文件角色。

返回

类型说明
Path该角色对应的文件路径。

异常

类型说明
KeyError依赖图中不存在该文件角色。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:135

dependency ​

python
def dependency(kind: str) -> Artifact

返回指定种类的唯一直接或传递依赖。

参数

名称类型默认值说明
kindstr—目标 artifact 种类。

返回

类型说明
Artifact匹配的依赖 artifact。

异常

类型说明
KeyError依赖图中不存在该种类。
ValueError该种类的依赖多于一个,无法确定唯一结果。

NOTE

清单里的依赖名描述边(例如 backend),而 Artifact.kind 描述节点。按节点种类查询,使中间 artifact 新增不同名的边时公开查询保持稳定。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:154

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:79

ArtifactKind ​

python
type ArtifactKind = Literal['plan', '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:24

open ​

python
def open(path: str | Path) -> ArtifactReader

打开轻量只读产物视图。

参数

名称类型默认值说明
pathstr | Path—当前格式产物目录或manifest.json路径。

返回

类型说明
ArtifactReader只消费请求文件、不加载执行引擎的读取器。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:62

read_program ​

python
def read_program(path: str | Path) -> ModelProgram

从闭合产物恢复模型计划、设置与资源,不绑定运行后端。

参数

名称类型默认值说明
pathstr | Path—模型、目标或工程产物目录或manifest.json。

返回

类型说明
ModelProgram不依赖原始Python模型构造函数的ModelProgram。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:74

read_target ​

python
def read_target(path: str | Path) -> TargetProgram

恢复确定目标的文件闭包与模型事实。

参数

名称类型默认值说明
pathstr | Path—保存的目标目录或 manifest.json 路径。

返回

类型说明
TargetProgram已校验的目标程序及其模型事实;执行函数由 runtime.bind 另行绑定。

异常

类型说明
ValueError产物不是受支持的目标,或声明的文件损坏。
FileNotFoundError闭包中声明的文件缺失。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:88

save ​

python
def save(value: ModelProgram | TargetProgram[object] | SourceProject, *, output_dir: str | Path, overwrite: bool = False) -> Path

将模型、目标或源码工程文件闭包原子保存到可搬迁目录。

参数

名称类型默认值说明
valueModelProgram | TargetProgram[object] | SourceProject—ModelProgram、TargetProgram 或 SourceProject,不接受当前运行状态。
output_dirstr | Path—完整产物输出目录。
overwriteboolFalse是否替换非空输出目录。

返回

类型说明
Path保存目录的绝对路径。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/__init__.py:124

ArtifactFile ​

python
class ArtifactFile(StrEnum)

artifact 存储发布文件的稳定角色。

SYSTEM_IR ​

python
SYSTEM_IR = 'system_ir'

系统 IR 定义。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:31

ASSETS ​

python
ASSETS = 'assets'

外置载荷压缩包。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:33

COMPILED_PLAN ​

python
COMPILED_PLAN = 'compiled_plan'

序列化后的编译计划。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:35

PREPARED_RESOURCES ​

python
PREPARED_RESOURCES = 'prepared_resources'

后端无关的资源数学准备结果。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:37

PLAN_SUMMARY ​

python
PLAN_SUMMARY = 'plan_summary'

计划摘要与维度信息。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:39

BACKEND_SOURCE ​

python
BACKEND_SOURCE = 'backend_source'

生成的后端源码。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:41

LAYOUT ​

python
LAYOUT = 'layout'

状态与输入布局说明。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:43

CASADI_FUNCTION_GRAPH ​

python
CASADI_FUNCTION_GRAPH = 'casadi_function_graph'

统一序列化的 CasADi 入口集合,保留各入口之间的共享函数身份。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:45

NATIVE_MODULE ​

python
NATIVE_MODULE = 'native_module'

编译好的本地模块。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:47

NATIVE_RESOURCE_DESCRIPTION ​

python
NATIVE_RESOURCE_DESCRIPTION = 'native_resource_description'

native只读资源布局、模式与ABI描述。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:49

NATIVE_RESOURCES ​

python
NATIVE_RESOURCES = 'native_resources'

C++初始化读取的模型绑定NPZ。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:51

NATIVE_RESOURCE_BUILD ​

python
NATIVE_RESOURCE_BUILD = 'native_resource_build'

资源adapter及二进制对象的可重建输入归档。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:53

GENERATED_C_SOURCE ​

python
GENERATED_C_SOURCE = 'generated_c_source'

生成的 C 源码。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:55

GENERATED_C_UNITS ​

python
GENERATED_C_UNITS = 'generated_c_units'

C 编译单元、内部头文件与依赖计划的可搬迁源码归档。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:57

CPP_HEADER ​

python
CPP_HEADER = 'cpp_header'

源码工程的身份限定公共 C++ 模型头文件。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:59

GENERATED_C_HEADER ​

python
GENERATED_C_HEADER = 'generated_c_header'

生成的 C 头文件。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:61

WRAPPER_SOURCE ​

python
WRAPPER_SOURCE = 'wrapper_source'

本地模块包装源码。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:63

CMAKE_PROJECT ​

python
CMAKE_PROJECT = 'cmake_project'

CMake 工程文件。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:65

PROJECT_INVENTORY ​

python
PROJECT_INVENTORY = 'project_inventory'

生成工程文件的相对路径、大小和内容校验清单。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:67

MODEL_INFO ​

python
MODEL_INFO = 'model_info'

模型元信息。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:69

README ​

python
README = 'readme'

产物说明文档。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:71

CONFIGURE_LOG ​

python
CONFIGURE_LOG = 'configure_log'

配置阶段日志。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:73

BUILD_LOG ​

python
BUILD_LOG = 'build_log'

构建阶段日志。

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:75

实现位置:packages/fly_ruler/python/fly_ruler_core/artifacts/types.py:28