Move component metadata to @gf.cell() decorator kwargs#116
Move component metadata to @gf.cell() decorator kwargs#116pepijndevos wants to merge 2 commits intogdsfactory:mainfrom
Conversation
…kwargs Enables static extraction of component metadata (symbol, ports, models, tags) by gfp2-server via AST parsing, without executing Python. - Add tags, symbol, ports, models kwargs to @gf.cell() for 20 PDK cells - Remove c.info["vlsir"] runtime metadata blocks - Remove unused `model` parameter from function signatures - Use corner files (cornerMOSlv.lib, etc.) with .LIB sections instead of model files directly - Fix rppd port_order bug: ["1", "3", "bn"] -> ["1", "2", "bn"] - Add metadata_guide.md documenting conventions Converted: fet_transistors (4), rf_transistors (4), resistors (3), capacitors (2), bjt_transistors (4), passives (4), antennas (2), bondpads (1). Primitives and fixed.py left as-is (generic SPICE elements and deprecated wrappers respectively). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reviewer's GuideRefactors IHP PDK device cells so that simulation metadata (tags, symbol, ports, models) is declared statically in @gf.cell decorator kwargs instead of runtime c.info['vlsir'] blocks, while also cleaning up unused model parameters, fixing a resistor port_order bug, standardizing on corner .LIB files, and documenting the new metadata conventions. Sequence diagram for metadata extraction from gf_cell decoratorsequenceDiagram
participant GFP2Server
participant SourceRepo
participant ASTParser
participant PythonFile
GFP2Server->>SourceRepo: list_python_files()
SourceRepo-->>GFP2Server: paths_to_cell_modules
loop for_each_cell_module
GFP2Server->>SourceRepo: read_file(path)
SourceRepo-->>GFP2Server: file_contents
GFP2Server->>ASTParser: parse(file_contents)
ASTParser->>PythonFile: build_ast()
PythonFile-->>ASTParser: ast_root
ASTParser->>ASTParser: find_functions_with_decorator(gf.cell)
ASTParser->>ASTParser: read_decorator_kwargs(tags, symbol, ports, models)
ASTParser-->>GFP2Server: CellMetadata(tags, symbol, ports, models)
end
GFP2Server->>GFP2Server: build_device_catalog_from_metadata()
Class diagram for gf_cell decorator metadata structureclassDiagram
class GfCellDecorator {
+list~string~ tags
+string symbol
+Ports ports
+list~ModelSpec~ models
}
class Ports {
+list~string~ top
+list~string~ bottom
+list~string~ left
+list~string~ right
}
class ModelSpec {
+string language
+string name
+string spice_type
+string library
+list~string~ sections
+list~string~ port_order
+dict~string,string~ params
}
class ComponentFactory {
+Component __call__(kwargs)
+dict factory_kwargs
}
class Component {
+dict info
+dict ports
+add_label(text, position, layer)
+add_port(name, center, width, orientation, layer, port_type)
}
GfCellDecorator --> Ports : uses
GfCellDecorator --> ModelSpec : uses
GfCellDecorator --> ComponentFactory : wraps
ComponentFactory --> Component : creates
Component --> ModelSpec : metadata_via_factory_kwargs
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Several model definitions (e.g., LV/HV MOS and RF variants, poly resistors) repeat nearly identical
modelsblocks in the decorators; consider factoring these into shared helpers or constants to avoid drift if a library name, corner list, or parameter expression needs to change later. - Where the old
c.info['vlsir']metadata carried additional non-geometric parameters (e.g., bondpadsize/shape/padtype, resistorm, ESDng), consider adding equivalent entries into the newmodels[].paramsdictionaries so downstream consumers don’t lose information that was previously available.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several model definitions (e.g., LV/HV MOS and RF variants, poly resistors) repeat nearly identical `models` blocks in the decorators; consider factoring these into shared helpers or constants to avoid drift if a library name, corner list, or parameter expression needs to change later.
- Where the old `c.info['vlsir']` metadata carried additional non-geometric parameters (e.g., bondpad `size`/`shape`/`padtype`, resistor `m`, ESD `ng`), consider adding equivalent entries into the new `models[].params` dictionaries so downstream consumers don’t lose information that was previously available.
## Individual Comments
### Comment 1
<location path="ihp/cells/capacitors.py" line_range="651-652" />
<code_context>
layer_topmetal1label=layer_topmetal1label,
- model=model,
)
c.info = cap.info
c.add_ref(cap)
</code_context>
<issue_to_address>
**issue (bug_risk):** rfcmim `c.info["model"]` will still be `"cap_cmim"` instead of `"cap_rfcmim"` after copying from the inner cmim.
Because `c.info = cap.info` copies the inner `cmim` metadata (where `c.info["model"] = "cap_cmim"`), `rfcmim` will advertise the wrong model name. Please reset `c.info["model"]` to `"cap_rfcmim"` after copying to keep the metadata accurate for tools that read `c.info["model"]`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
c.info = cap.info copies cmim's info dict, so model was "cap_cmim" instead of "cap_rfcmim". Reset it after copying. Also update metadata_guide.md with a note about wrapper cells. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ThomasPluck
left a comment
There was a problem hiding this comment.
Okay in order for this, we need to fix gdsfactory upstream to allow for arb @gf.cell decorators (issue: gdsfactory/gdsfactory#4452) - let's track this and merge with the latest version.
|
Yes makes sense I've made it a draft because this needs testing on all sides |
|
oh, we should also discover the sax model and add it as an explicit link |
Summary
c.info["vlsir"]blocks to static@gf.cell()decorator kwargs, enabling extraction via AST parsing without executing Python["1", "3", "bn"]→["1", "2", "bn"](matching actual.subckt rppd 1 2 bn).LIBsections (e.g.cornerMOSlv.libwithmos_tt,mos_ss, etc.) instead of model files directlymodelparameter from function signaturesmetadata_guide.mddocumenting conventionsTest plan
@gf.cell()accepts unknown kwargs without error (gdsfactory passes them through asfactory_kwargs)nmos(),rsil(),npn13G2())tags,symbol,ports,modelsfromfactory_kwargs🤖 Generated with Claude Code
Summary by Sourcery
Move IHP PDK device metadata from runtime component info to static @gf.cell decorator annotations for AST-based extraction.
New Features:
Bug Fixes:
Enhancements: