Fabll API创建
- 作者仓库星标 3,367
- 许可证 MIT
- 作者仓库 atopile
FabLL (Fabric Low Level) Module
fabll (primarily src/faebryk/core/node.py) is the high-level Python API for defining and working with hardware components. It bridges the gap between Python classes and the underlying TypeGraph and instance graph.
Quick Start
import faebryk.core.faebrykpy as fbrk
import faebryk.core.graph as graph
import faebryk.core.node as fabll
g = graph.GraphView.create()
tg = fbrk.TypeGraph.create(g=g)
class _App(fabll.Node):
pass
app = _App.bind_typegraph(tg=tg).create_instance(g=g)
Relevant Files
src/faebryk/core/node.py(Node/Traits/fields, type registration, binding/instantiation helpers)src/faebryk/core/faebrykpy.py(edge types used by FabLL under the hood)src/faebryk/core/graph.py(GraphView wrapper used by instances)
Dependants (Call Sites)
- Library (
src/faebryk/library/): Every component (Resistor, Capacitor, etc.) inherits fromNode. - Compiler: Generates
Nodesubclasses dynamically fromatofiles. - Solvers: Operate on
Nodeinstances to extract parameters and constraints.
How to Work With / Develop / Test
Core Concepts
- Nodes are wrappers over graph instances: a
fabll.Nodeis constructed with agraph.BoundNode. - Declaration via class attributes:
- structural children:
SomeType.MakeChild(...) - trait attachments:
Traits.MakeEdge(SomeTrait.MakeChild().put_on_type())(or similar)
- structural children:
- Binding:
- type binding:
MyType.bind_typegraph(tg) - instance creation:
.create_instance(g)
- type binding:
- Type identifiers:
- library types (
faebryk.library.*) intentionally have short identifiers (class name) for ato imports - non-library types include a module-derived suffix; type IDs must be unique (enforced in
Node._register_type)
- library types (
Development Workflow
- Prefer adding behavior as a Trait rather than deepening class hierarchies.
- If you need a new structural relation/field kind, it lives in
src/faebryk/core/node.py(field system). - Keep an eye on invariants enforced at class creation time (metaclass +
__init_subclass__).
Testing
- Core tests:
ato dev test --llm test/core/test_node.py -qandato dev test --llm test/library/test_traits.py -q
Best Practices
- Prefer Traits: Don't add methods to
Nodesubclasses if they can be a Trait. This allows them to be applied to different component families. - Avoid deep inheritance: FabLL enforces single-level subclassing for node types (
Node.__init_subclass__). - Type-safe traversal: when you must traverse trait edges manually, prefer
EdgeTrait.traverse(trait_type=...).
Internals & Runtime Behavior
Instantiation & Lifecycle
- Don’t call
MyNode()with no args: instances are created from a bound type viabind_typegraph(...).create_instance(...). - TypeGraph context is required:
import faebryk.core.graph as graph import faebryk.core.faebrykpy as fbrk g = graph.GraphView.create() tg = fbrk.TypeGraph.create(g=g) inst = MyNode.bind_typegraph(tg).create_instance(g=g) - Single-level subclassing invariant:
Node.__init_subclass__forbids “deeper than one level” inheritance for node types.
Trait Implementation
- Traits are Nodes: Traits are not just Python mixins; they are
Nodesubclasses that typically contain anImplementsTraitedge. - Trait Definition:
class MyTrait(Node): is_trait = Traits.MakeEdge(ImplementsTrait.MakeChild().put_on_type()) - Resolution: Use
node_instance.get_trait(TraitType)to retrieve a trait instance. This performs a graph traversal.
Performance & Memory
- Type Creation: Creating a type involves significant overhead (executing fields, resolving dependencies). Once created, instantiating instances is faster but still involves allocation in the Zig backend.
- Tree Structure: Nodes are linked via
EdgeComposition.add_childcreates this edge. Large trees (10k+ nodes) should be constructed carefully to avoid Python loop overhead; the underlying graph is efficient, but Python interactions cost time.
- 流狐分类
- 通用
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @atopile · MIT
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- macOS · Linux · Windows
- 底层运行要求
- Node.js · Python
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Quick Start
Quick Start
Development Workflow
Prefer adding behavior as a Trait rather than deepening class hierarchies. If you need a new structural relation/field kind, it lives in src/faebryk/core/node.py (field system). Keep an eye on invariants enforced at class creation time (metaclass +…
# FabLL (Fabric Low Level) Module
`fabll` (primarily `src/faebryk/core/node.py`) is the high-level Python API for defining and working with hardware components. It bridges the gap between Python classes and the underlying `TypeGraph` and instance graph.
## Quick Start
```python
import faebryk.core.faebrykpy as fbrk
import faebryk.core.graph as graph
import faebryk.core.node as fabll
g = graph.GraphView.create()
tg = fbrk.TypeGraph.create(g=g)
class _App(fabll.Node):
pass
app = _App.bind_typegraph(tg=tg).create_instance(g=g)
```
## Relevant Files
- `src/faebryk/core/node.py` (Node/Traits/fields, type registration, binding/instantiation helpers)
- `src/faebryk/core/faebrykpy.py` (edge types used by FabLL under the hood)
- `src/faebryk/core/graph.py` (GraphView wrapper used by instances)
## Dependants (Call Sites)
- **Library (`src/faebryk/library/`)**: Every component (Resistor, Capacitor, etc.) inherits from `Node`.
- **Compiler**: Generates `Node` subclasses dynamically from `ato` files.
- **Solvers**: Operate on `Node` instances to extract parameters and constraints.
## How to Work With / Develop / Test
### Core Concepts
- **Nodes are wrappers over graph instances**: a `fabll.Node` is constructed with a `graph.BoundNode`.
- **Declaration via class attributes**:
- structural children: `SomeType.MakeChild(...)`
- trait attachments: `Traits.MakeEdge(SomeTrait.MakeChild().put_on_type())` (or similar)
- **Binding**:
- type binding: `MyType.bind_typegraph(tg)`
- instance creation: `.create_instance(g)`
- **Type identifiers**:
- library types (`faebryk.library.*`) intentionally have short identifiers (class name) for ato imports
- non-library types include a module-derived suffix; type IDs must be unique (enforced in `Node._register_type`)
… 证据边界与执行链路
作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Quick Start → Relevant Files → Dependants (Call Sites) → How to Work With / Develop / Test → Core Concepts → Development Workflow
要点 -> Library (src/faebryk/library/) · Compiler · Solvers · Nodes are wrappers over graph instances · Declaration via class attributes · Binding · Type identifiers · Prefer Traits
文件/命令 -> fabll · src/faebryk/core/node.py · TypeGraph · src/faebryk/core/faebrykpy.py · src/faebryk/core/graph.py · src/faebryk/library/ · Node · ato
内容 SHA-256 -> 082d2390334e
方法与流程
适用与边界
原文中的明确线索
fabll、src/faebryk/core/node.py、TypeGraph、src/faebryk/core/faebrykpy.py、src/faebryk/core/graph.py、src/faebryk/library/、Node、ato