gdsfactoryplus
¶
GDSFactoryplus python library.
Modules:
| Name | Description |
|---|---|
bbox |
Generate cell bbox. |
cli |
GDSFactory+ CLI. |
cli_test |
Test Component Builds. |
core |
Core GDSFactory+ utilities. |
export_spice |
Uses VLSIRTools to convert from Klayout's DB Netlist to common spice formats. |
freeze |
Freeze a python cell as schematic netlist. |
from_yaml_gen_patch |
Patch for gdsfactory's from_yaml_gen._generate_placement_code. |
gdsfactoryplus |
A Python module implemented in Rust. |
generate_svg |
Generate SVG from cell. |
layer_stack |
Extract layer stack as json. |
logger |
GDSFactory+ Logger. |
models |
GDSFactory+ Pydantic models. |
project |
Find the GDSFactory+ project folder. |
registry |
Server registry for tracking active GDSFactory+ instances. |
serve |
GDSFactory+ Server. |
settings |
Parse the GDSFactory+ settings. |
show |
General Show function. |
show3d |
3D viewer. |
show_cell |
Show a python object in a vscode panel. |
sim |
Simulation API. |
version |
Simply the GDSFactory+ version. |
Classes:
| Name | Description |
|---|---|
ComponentAsDefaultArgError |
Raised when a cell function has a Component instance as a default argument. |
DanglingPortWarning |
Emitted when SPICE export encounters dangling instance ports. |
ElectricalOrphanError |
Raised when an electrical port is dangling and not grouped into a |
FrozenPdk |
A frozen PDK that prevents modification of its attributes. |
SelfReferenceError |
Raised when a schematic references itself as an instance. |
ServerInfo |
Information about a running GDSFactory+ server. |
ServerRegistry |
Registry for tracking active GDSFactory+ servers. |
UnresolvedComponentWarning |
Emitted when a sub-component or its netlist cannot be resolved. |
Functions:
| Name | Description |
|---|---|
activate_pdk_by_name |
Activate a PDK by name (deprecated). |
add_components |
Add multiple components to the database simultaneously. |
add_factories |
Add multiple factories to the database. |
add_models |
Add multiple models to the database. |
apply_from_yaml_gen_patch |
Monkey-patch gdsfactory's from_yaml_gen module. |
build_by_names |
Build multiple GDS cells by names. |
cancel_build |
Signal the current build loop to stop after the current component. |
check_conn |
Run connectivity check on the given GDS file. |
check_drc |
Run DRC check on the given GDS file. |
clear_caches |
Clear cached PDK objects so they are reloaded on next access. |
clear_cells_from_cache |
Clear cells from cache by factory names. |
clear_simulation_results |
Clear simulation results with optional filters. |
cli_environment |
Get a CLI environment. |
create_callgraph |
Create a directed graph from the call graph data. |
default_lib_paths |
Return default library paths. |
delete_simulation_result |
Delete a simulation result by its ID. |
extract_function_arguments |
Extract function arguments and serialize them as JSON. |
find_models |
Find all models in the current project. |
find_partial_definition |
Find a partial function definition. |
find_project_dir |
Find the GDSFactory+ project folder. |
find_simulation_result |
Find a cached simulation result by its identity fields. |
freeze_recursive |
Freeze a python cell as a recursive (hierarchical) netlist. |
generate_multipolygon |
Generate a MultiPolygon from a component. |
get_all_factories |
Get all factory records from the database. |
get_all_factory_names |
Get all factory names from the database. |
get_all_models |
Get all model records from the database. |
get_base_pdk |
Get the base PDK, which is the generic PDK. |
get_base_schema |
Get base netlist schema. |
get_build_dir |
Get the build directory. |
get_cells_from_regex |
Find all cells in a python file decorated with @cell using a regex. |
get_components_by_factories |
Get all component records belonging to specific factories. |
get_db_path |
Get the path to the database. |
get_factories_by_components |
Get factory records for multiple components. |
get_factories_by_idxs |
Get factory records by their kcl indices. |
get_factories_by_name |
Get multiple factory records by their names. |
get_factories_by_source |
Get factory names for each given source file. |
get_factory_sources_by_name |
Get source file paths for multiple factories by their names. |
get_gds_dir |
Get the output GDS directory. |
get_graph_data |
Get the raw call graph data, caching the result. |
get_layer_properties |
Get the LYP layer properties file for the active PDK, generating if needed. |
get_layer_stack |
Get the layerstack JSON file for the active PDK, generating if needed. |
get_log_dir |
Get the log directory. |
get_logger |
Get the GDSFactory+ logger. |
get_model_sources_by_name |
Get source file paths for multiple models by their factory names. |
get_models_by_name |
Get multiple model records by their factory names. |
get_netlist_schema |
Get the schema for a specific netlist. |
get_pdk |
Import a PDK by name. |
get_pdk_name |
Get the name of the pdk used in the project. |
get_pics_dir |
Get the PICs directory. |
get_ports |
Get the ports from a component. |
get_project_dir |
Get the project root directory. |
get_project_name |
Get the name of the project. |
get_registry_path |
Get the path to the server registry file. |
get_runtime_factories_dependency_graph |
Get a dependency graph for multiple factories. |
get_runtime_factory_dependencies |
Get the dependencies of a factory. |
get_settings |
Get the gdsfactoryplus settings. |
get_sim_x |
Get the simulation x-axis specification (wavelength or frequency). |
get_simulation_file_path |
Get the file path for a simulation result. |
get_simulations_dir |
Get the simulations directory for storing simulation results. |
get_static_records |
Get static records from a call graph. |
get_svg |
Get the (possible cached) svg for a cell. |
get_wls |
Get the wavelengths used in the project (deprecated, use get_sim_x instead). |
get_ws_port |
Get the websocket port. |
ignore_prints |
Ignore any output to stdout or stderr. |
ignored_paths |
Get paths to ignore. |
import_modules |
Import all modules from a given directory. |
import_path |
Import a module from a given path. |
import_picyml |
Import a yaml file as a module. |
init |
Initialize Datadog error tracking. |
invalidate_graph_cache |
Invalidate the cached call graph data. |
is_a_pdk |
Check if the settings are for a pdk or a project. |
lazy_import |
Lazily import a module. |
lazy_setattr |
Lazily set an attribute on a LazyModule. |
list_simulation_results |
List simulation results with optional filters. |
load_simulation_result |
Load a simulation result by its ID. |
maybe_find_project_dir |
Maybe find the GDSFactory+ project folder. |
merge_rdb_strings |
Merge RDB Strings. |
none |
Serialize as None. |
parse_oc_spice |
Parse OC spice. |
ping_server |
Ping the vscode websocket server to check if it's alive. |
plot_callgraph |
Plot a call graph. |
print_to_file |
Print content to a file. |
register_cells |
Register PDK cells. |
register_models |
Register all models in the current project. |
remove_components |
Remove multiple components from the database simultaneously. |
remove_components_by_factories |
Remove all components belonging to specific factories from the database. |
remove_factories |
Remove multiple factories and all their child components from the database. |
remove_factories_by_source |
Remove factories from the database by their source. |
remove_models |
Remove multiple models from the database. |
reset_timestamps |
Reset the timestamps of all factories to the current time. |
resolve_modname |
Resolve the module name from a given path. |
save_simulation_result |
Save a simulation result to file. |
send_message |
Send a message to vscode. |
set_all_factories_has_model |
Set the has_model field for all factories in the database. |
set_factories_has_model_by_names |
Set the has_model field for multiple factories by their names. |
set_factories_status_by_names |
Modify the status of multiple factories by their names. |
set_ws_port |
Set the websocket port (from CLI --ws-port argument). |
shutdown |
Shut down Datadog error tracking, flushing remaining events. |
sync_from_kcl |
Sync all cells from gf.kcl into the components table of the database. |
track_error |
Track an error with Datadog. |
track_warning |
Track a warning with Datadog. |
try_func |
Try to execute a function and return the result. |
unlazy |
Get the underlying object of a lazy import. |
update_factories |
Atomically add/replace and remove factories in a single transaction. |
validate_access |
Validates the API key and returns the license information. |
ComponentAsDefaultArgError
¶
Bases: Exception
Raised when a cell function has a Component instance as a default argument.
DanglingPortWarning
¶
Bases: UserWarning
Emitted when SPICE export encounters dangling instance ports.
A dangling port is one that is neither connected to another instance nor exposed as an external port of its parent component.
Optical ports: A dangling optical port models a free boundary condition — physically, a cleaved facet with ~30% Fresnel reflection. The netlist is generated with a placeholder signal; the port is physically meaningful.
Electrical ports (in a Pin): A dangling electrical port that belongs to
a gf.Pin produces a floating net in the SPICE netlist. The netlist is
still valid but the simulator may warn about the undriven node.
Can be suppressed with::
warnings.filterwarnings("ignore", category=DanglingPortWarning)
ElectricalOrphanError
¶
Bases: ValueError
Raised when an electrical port is dangling and not grouped into a gf.Pin.
GDSFactory Ports are layout terminals — attachment sites for routing
polygons. From a SPICE perspective, the logical signal connects per
pin (a gf.Pin that groups one or more Ports). An electrical Port
that is neither connected nor part of any Pin is an orphan: it has no
logical signal identity and cannot be represented in the netlist.
Group the port into a Pin with component.create_pin(ports=[...]) or
connect it to another instance.
FrozenPdk
¶
Bases: Pdk
A frozen PDK that prevents modification of its attributes.
SelfReferenceError
¶
Bases: Exception
Raised when a schematic references itself as an instance.
ServerInfo
¶
ServerInfo(
port: int,
pid: int,
project_path: str,
project_name: str,
pdk: str | None = None,
ws_port: int | None = None,
started_at: str | None = None,
last_heartbeat: str | None = None,
)
Information about a running GDSFactory+ server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
HTTP server port |
required |
pid
|
int
|
Process ID |
required |
project_path
|
str
|
Absolute path to project directory |
required |
project_name
|
str
|
Human-readable project name |
required |
pdk
|
str | None
|
PDK name (optional) |
None
|
ws_port
|
int | None
|
WebSocket port for VS Code extension (optional) |
None
|
started_at
|
str | None
|
ISO timestamp when server started |
None
|
last_heartbeat
|
str | None
|
ISO timestamp of last heartbeat |
None
|
Methods:
| Name | Description |
|---|---|
from_dict |
Create from dictionary. |
is_alive |
Check if the server process is still running. |
to_dict |
Convert to dictionary. |
is_alive
¶
Check if the server process is still running.
Returns:
| Type | Description |
|---|---|
bool
|
True if process exists, False otherwise |
ServerRegistry
¶
Registry for tracking active GDSFactory+ servers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry_path
|
Path | None
|
Optional custom path to registry file |
None
|
Methods:
| Name | Description |
|---|---|
get_server |
Get server info by port. |
get_server_by_project |
Get server info by project name. |
list_servers |
List all registered servers. |
register_server |
Register a new server or update existing entry. |
unregister_server |
Unregister a server by port. |
update_heartbeat |
Update the last heartbeat timestamp for a server. |
get_server
¶
get_server(port: int) -> ServerInfo | None
Get server info by port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
Port number |
required |
Returns:
| Type | Description |
|---|---|
ServerInfo | None
|
ServerInfo if found and alive, None otherwise |
get_server_by_project
¶
get_server_by_project(project_name: str) -> ServerInfo | None
Get server info by project name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
Project name or path |
required |
Returns:
| Type | Description |
|---|---|
ServerInfo | None
|
ServerInfo if found and alive, None otherwise |
list_servers
¶
list_servers(*, include_dead: bool = False) -> list[ServerInfo]
List all registered servers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_dead
|
bool
|
Include servers with dead processes |
False
|
Returns:
| Type | Description |
|---|---|
list[ServerInfo]
|
List of ServerInfo objects |
register_server
¶
register_server(server_info: ServerInfo) -> None
Register a new server or update existing entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_info
|
ServerInfo
|
Server information to register |
required |
unregister_server
¶
Unregister a server by port.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
Port of server to unregister |
required |
update_heartbeat
¶
Update the last heartbeat timestamp for a server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
Port of server to update |
required |
UnresolvedComponentWarning
¶
Bases: UserWarning
Emitted when a sub-component or its netlist cannot be resolved.
Triggered by failures during hierarchy traversal:
- component.get_netlist() raises (e.g. unknown PDK layer): the component
is treated as an opaque leaf and only its declared ports are exposed.
- gf.get_component(factory, **settings) raises during recursion: the
sub-component's .SUBCKT is never emitted; instance lines that reference
it will fail at HSPICE parse time.
- gf.get_component(...) raises during instance construction: the instance
is dropped from the parent .SUBCKT; nets that referenced it will appear
floating.
Distinct from :class:DanglingPortWarning, which signals that the user's
design itself has unconnected ports. Resolution failures usually point at a
PDK or environment issue rather than a design issue.
Can be suppressed with::
warnings.filterwarnings("ignore", category=UnresolvedComponentWarning)
Or escalated to an error with::
warnings.filterwarnings("error", category=UnresolvedComponentWarning)
activate_pdk_by_name
¶
Activate a PDK by name (deprecated).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the PDK to activate. (deprecated, will be ignored) |
required |
Returns:
| Type | Description |
|---|---|
Pdk
|
gf.Pdk: The activated PDK object. |
add_components
¶
Add multiple components to the database simultaneously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
ComponentRecord
|
ComponentRecord objects containing component information. |
()
|
add_factories
¶
Add multiple factories to the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
FactoryRecord
|
FactoryRecord objects containing factory information. |
()
|
update_last_modified
|
bool
|
If True, updates the last_updated timestamp to current time. If False, preserves existing timestamp or uses default. |
True
|
add_models
¶
Add multiple models to the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
ModelRecord
|
ModelRecord objects containing model information. |
()
|
apply_from_yaml_gen_patch
¶
Monkey-patch gdsfactory's from_yaml_gen module.
build_by_names
¶
Build multiple GDS cells by names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
List of cell names to build. |
()
|
with_metadata
|
bool
|
Whether to include metadata in the GDS files. |
True
|
cancel_build
¶
Signal the current build loop to stop after the current component.
check_conn
¶
Run connectivity check on the given GDS file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
path to the GDS file to run the check on. |
required |
verbose
|
bool
|
if True, print status messages to stderr. |
True
|
check_drc
¶
check_drc(
path: str | Path,
pdk: str = SETTINGS["drc"]["pdk"] or SETTINGS["pdk"]["name"],
process: str = SETTINGS["drc"]["process"],
timeout: int = SETTINGS["drc"]["timeout"],
host: str = SETTINGS["drc"]["host"],
api_key: str = SETTINGS["api"]["key"],
*,
verbose: bool = True,
) -> str
Run DRC check on the given GDS file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
path to the GDS file to run the check on. |
required |
pdk
|
str
|
PDK to use for the check. |
SETTINGS['drc']['pdk'] or SETTINGS['pdk']['name']
|
process
|
str
|
the drc rules might be slightly different depending on the process |
SETTINGS['drc']['process']
|
timeout
|
int
|
timeout in seconds for the check (DRC only). |
SETTINGS['drc']['timeout']
|
host
|
str
|
api host (DRC only). |
SETTINGS['drc']['host']
|
api_key
|
str
|
the api key (DRC only). |
SETTINGS['api']['key']
|
verbose
|
bool
|
if True, print status messages to stderr. |
True
|
Note
the connectivity check runs locally, so for this check the api
parameters timeout, host, api_key will be ignored.
clear_cells_from_cache
¶
Clear cells from cache by factory names.
clear_simulation_results
¶
clear_simulation_results(
*,
component_name: str | None = None,
factory_name: str | None = None,
simulation_type: str | None = None,
pdk_name: str | None = None,
) -> int
Clear simulation results with optional filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str | None
|
Filter by component name. |
None
|
factory_name
|
str | None
|
Filter by factory name. |
None
|
simulation_type
|
str | None
|
Filter by simulation type. |
None
|
pdk_name
|
str | None
|
Filter by PDK name. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Number of results deleted. |
cli_environment
¶
Get a CLI environment.
create_callgraph
¶
create_callgraph(
graph_data: dict | None = None, /, *, lib_paths: dict[str, Path] | None = None
) -> DiGraph
Create a directed graph from the call graph data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph_data
|
dict | None
|
Optional pre-generated call graph data. |
None
|
lib_paths
|
dict[str, Path] | None
|
module name -> library path mapping of all relevant python libraries. |
None
|
delete_simulation_result
¶
Delete a simulation result by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_id
|
str
|
The unique simulation ID. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the result was deleted, False otherwise. |
extract_function_arguments
¶
Extract function arguments and serialize them as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to extract arguments from. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
JSON string in format {argument_name: default_value} or None if extraction fails. |
dict
|
Arguments without defaults have None as default. |
dict
|
args and *kwargs are ignored. |
find_models
¶
Find all models in the current project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lib_paths
|
dict[str, Path] | None
|
module name -> library path mapping of all relevant python libraries. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ModelRecord]
|
dict[str, ModelRecord]: mapping of model names to their records. |
find_partial_definition
¶
Find a partial function definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
partial_name
|
str
|
Name of the partial function to find. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to the file containing the partial definition, or None if not found. |
find_project_dir
¶
Find the GDSFactory+ project folder.
Returns:
| Type | Description |
|---|---|
Path
|
The path to the GDSFactory+ project folder. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
if no project dir is found. |
find_simulation_result
¶
find_simulation_result(
*,
component_name: str,
factory_name: str,
component_settings: dict[str, Any],
model_parameters: dict[str, Any],
hyperparameters: SimulationHyperparameters,
simulation_type: SimulationType,
) -> StoredSimulationResult | None
Find a cached simulation result by its identity fields.
This computes the deterministic ID from the inputs and looks up the corresponding result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str
|
Name of the component. |
required |
factory_name
|
str
|
Name of the factory. |
required |
component_settings
|
dict[str, Any]
|
Component settings dictionary. |
required |
model_parameters
|
dict[str, Any]
|
Model parameters dictionary. |
required |
hyperparameters
|
SimulationHyperparameters
|
Simulation hyperparameters. |
required |
simulation_type
|
SimulationType
|
Type of simulation. |
required |
Returns:
| Type | Description |
|---|---|
StoredSimulationResult | None
|
StoredSimulationResult if found, None otherwise. |
freeze_recursive
¶
Freeze a python cell as a recursive (hierarchical) netlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell_name
|
str
|
name of the cell to freeze. |
required |
**kwargs
|
Any
|
the keyword arguments to create the cell with. |
{}
|
generate_multipolygon
¶
Generate a MultiPolygon from a component.
get_all_factories
¶
Get all factory records from the database.
Returns:
| Type | Description |
|---|---|
dict[str, FactoryRecord]
|
Dict mapping factory names to their FactoryRecord objects. |
get_all_factory_names
¶
Get all factory names from the database.
get_all_models
¶
Get all model records from the database.
Returns:
| Type | Description |
|---|---|
dict[str, ModelRecord]
|
Dict mapping factory names to their ModelRecord objects. |
get_base_pdk
cached
¶
get_base_pdk() -> Pdk | FrozenPdk
Get the base PDK, which is the generic PDK.
Returns:
| Type | Description |
|---|---|
Pdk | FrozenPdk
|
gf.Pdk: The base PDK object. |
get_cells_from_regex
¶
Find all cells in a python file decorated with @cell using a regex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the path to the python file. |
required |
get_components_by_factories
¶
Get all component records belonging to specific factories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory_names
|
str
|
Names of the factories to get components for. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, list[ComponentRecord]]
|
List of ComponentRecords that belong to the specified factories. |
get_factories_by_components
¶
Get factory records for multiple components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
str
|
Names of components to get factories for. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, FactoryRecord]
|
List of FactoryRecord objects for the components' factories. |
dict[str, FactoryRecord]
|
Components with missing factories are skipped. |
get_factories_by_idxs
¶
Get factory records by their kcl indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idxs
|
int
|
KCL indices of the factories. |
()
|
Returns:
| Type | Description |
|---|---|
dict[int, FactoryRecord]
|
List of FactoryRecord objects for the factories. Skips any not found. |
get_factories_by_name
¶
Get multiple factory records by their names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to get. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, FactoryRecord]
|
Dict mapping factory names to their FactoryRecord objects. |
dict[str, FactoryRecord]
|
Raises ValueError if any factory not found. |
get_factories_by_source
¶
Get factory names for each given source file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
Path | str
|
Source file paths to match factories. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
Dict mapping each source path (as relative string) to a list of |
dict[str, list[str]]
|
factory names using that source. |
get_factory_sources_by_name
¶
Get source file paths for multiple factories by their names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to get sources for. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Dict mapping factory names to their source file paths. |
dict[str, Path]
|
Source paths are relative to project root, or None if not found. |
get_graph_data
¶
Get the raw call graph data, caching the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lib_paths
|
dict[str, Path] | None
|
module name -> library path mapping. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
The raw call graph dictionary from generate_call_graph. |
get_layer_properties
¶
Get the LYP layer properties file for the active PDK, generating if needed.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the LYP file. |
get_layer_stack
¶
Get the layerstack JSON file for the active PDK, generating if needed.
Returns:
| Type | Description |
|---|---|
Path
|
Path to the layerstack JSON file. |
get_model_sources_by_name
¶
Get source file paths for multiple models by their factory names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to get model sources for. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Dict mapping factory names to their source file paths. |
dict[str, Path]
|
Source paths are relative to project root, or None if not found. |
get_models_by_name
¶
Get multiple model records by their factory names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to get models for. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, ModelRecord]
|
Dict mapping factory names to their ModelRecord objects. |
dict[str, ModelRecord]
|
Raises ValueError if any model not found. |
get_netlist_schema
¶
Get the schema for a specific netlist.
get_pdk
¶
Import a PDK by name.
Returns:
| Type | Description |
|---|---|
Pdk
|
gf.Pdk: The imported PDK object. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the specified PDK cannot be found. |
get_ports
¶
Get the ports from a component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comp
|
str
|
Name of the component to get ports from. |
required |
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dictionary mapping port names to their directions. |
get_registry_path
¶
Get the path to the server registry file.
Returns:
| Type | Description |
|---|---|
Path
|
Path to ~/.gdsfactory/server-registry.json |
get_runtime_factories_dependency_graph
¶
Get a dependency graph for multiple factories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to build the dependency graph for. |
()
|
Returns:
| Type | Description |
|---|---|
DiGraph
|
NetworkX DiGraph with factory dependencies. Edges represent dependencies |
DiGraph
|
where an edge from A to B means A depends on B (B is a child of A). |
get_runtime_factory_dependencies
¶
Get the dependencies of a factory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the factory to get dependencies for. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[str]]
|
Tuple of lists of factory names: (parents, children) |
get_settings
cached
¶
Get the gdsfactoryplus settings.
Returns a dict with the merged settings from: 1. Environment variables (GFP_*) 2. pyproject.toml ([tool.gdsfactoryplus]) 3. ~/.gdsfactory/gdsfactoryplus.toml
get_simulation_file_path
¶
Get the file path for a simulation result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_type
|
str
|
Type of simulation (e.g., "sax", "femwell"). |
required |
component_name
|
str
|
Name of the component. |
required |
simulation_id
|
str
|
The simulation ID. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the simulation result file. |
get_simulations_dir
¶
Get the simulations directory for storing simulation results.
get_static_records
¶
get_static_records(
G: DiGraph | None = None, /, *, paths: Iterable[Path] = ()
) -> dict[str, FactoryRecord]
Get static records from a call graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
DiGraph | None
|
the call graph to extract records from (will be generated if not given). |
None
|
paths
|
Iterable[Path]
|
list of paths to filter the records by. If empty, reutrns all records. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, FactoryRecord]
|
A dictionary mapping factory names to their corresponding FactoryRecord. |
get_svg
cached
¶
Get the (possible cached) svg for a cell.
get_wls
¶
Get the wavelengths used in the project (deprecated, use get_sim_x instead).
get_ws_port
¶
Get the websocket port.
Returns the port set via set_ws_port(), or None if not set.
ignore_prints
¶
Ignore any output to stdout or stderr.
import_modules
¶
import_modules(
*, reload: bool = False, paths: Iterable[Path] = (), from_project: bool = True
) -> tuple[dict[Path, ModuleType], dict[Path, tuple[str, Exception]]]
Import all modules from a given directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reload
|
bool
|
If True, reloads the modules if they are already imported. |
False
|
paths
|
Iterable[Path]
|
An iterable of paths of specific files to import. If empty, all Python files in the pics_dir will be imported. |
()
|
from_project
|
bool
|
If True, only imports modules from the project directory. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[dict[Path, ModuleType], dict[Path, tuple[str, Exception]]]
|
list[ModuleType]: A list of imported modules. |
Raises:
| Type | Description |
|---|---|
NotADirectoryError
|
If the given path is not a directory. |
import_path
¶
Import a module from a given path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the module or package. |
required |
reload
|
bool
|
If True, reloads the module if it is already imported. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
ModuleType |
ModuleType
|
The imported module. |
import_picyml
¶
Import a yaml file as a module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the path to the yaml file. |
required |
module_name
|
str | None
|
the name of the module to create (if not given, derive from path). |
None
|
reload
|
bool
|
whether to reload the module if it was already imported. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
ModuleType |
ModuleType
|
The imported module. |
init
¶
Initialize Datadog error tracking.
Resolves the environment from settings, reads the extension version, and starts a periodic flush timer.
invalidate_graph_cache
¶
Invalidate the cached call graph data.
Must be called when source files are added, removed, or modified
so that the next create_callgraph call rescans the project.
lazy_setattr
¶
Lazily set an attribute on a LazyModule.
list_simulation_results
¶
list_simulation_results(
*,
component_name: str | None = None,
factory_name: str | None = None,
simulation_type: str | None = None,
pdk_name: str | None = None,
status: str | None = None,
) -> list[StoredSimulationResult]
List simulation results with optional filters.
Scans the filesystem for simulation result files and filters them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str | None
|
Filter by component name. |
None
|
factory_name
|
str | None
|
Filter by factory name. |
None
|
simulation_type
|
str | None
|
Filter by simulation type. |
None
|
pdk_name
|
str | None
|
Filter by PDK name. |
None
|
status
|
str | None
|
Filter by status. |
None
|
Returns:
| Type | Description |
|---|---|
list[StoredSimulationResult]
|
List of matching StoredSimulationResult objects. |
load_simulation_result
¶
Load a simulation result by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation_id
|
str
|
The unique simulation ID. |
required |
Returns:
| Type | Description |
|---|---|
StoredSimulationResult | None
|
StoredSimulationResult if found, None otherwise. |
maybe_find_project_dir
¶
Maybe find the GDSFactory+ project folder.
Returns:
| Type | Description |
|---|---|
Path | None
|
The path to the GDSFactory+ project folder or None if not found. |
parse_oc_spice
¶
parse_oc_spice(
path_or_buf: str | Path,
settings_keymap: dict[str, Any] | None = None,
component_map: dict[str, Any] | None = None,
**kwargs: Any,
) -> dict[str, Any]
Parse OC spice.
ping_server
¶
Ping the vscode websocket server to check if it's alive.
Sends a ping message and waits for a pong response. Returns None if no websocket port is configured (health checks disabled). Returns True if the server responds, False otherwise.
plot_callgraph
¶
Plot a call graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
DiGraph
|
the call graph to plot |
required |
prog
|
str
|
the graphviz program to use for layout (e.g., 'neato', 'dot') |
'neato'
|
show
|
bool
|
whether to show the plot |
True
|
register_cells
¶
Register PDK cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Iterable[Path]
|
Paths to Python modules containing PDK cells. If empty, it will import all modules. |
()
|
reload
|
bool
|
Whether to reload the modules we're importing from. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[str]]
|
tuple[list[str], list[str]]: - List of names of newly registered cells. - List of names of deleted cells. |
register_models
¶
register_models(
G: DiGraph | None = None, /, *, reload: bool = True
) -> tuple[list[str], list[str]]
Register all models in the current project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
DiGraph | None
|
(optional) the call graph to extract factory dependencies from. |
None
|
reload
|
bool
|
Whether to reload the modules containing the models. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[str]]
|
tuple[list[str], list[str]]: - List of names of newly registered models. - List of names of deleted models. |
remove_components
¶
Remove multiple components from the database simultaneously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
List of component names to remove. |
()
|
remove_components_by_factories
¶
Remove all components belonging to specific factories from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factory_names
|
str
|
Names of factories whose components should be removed. |
()
|
remove_factories
¶
Remove multiple factories and all their child components from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to remove. |
()
|
remove_factories_by_source
¶
Remove factories from the database by their source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sources
|
Path | str
|
Source file paths to match factories for removal. |
()
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of factory names that were removed. |
remove_models
¶
Remove multiple models from the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the models to remove. |
()
|
reset_timestamps
¶
Reset the timestamps of all factories to the current time.
save_simulation_result
¶
save_simulation_result(
*,
component_name: str,
factory_name: str,
component_settings: dict[str, Any],
model_parameters: dict[str, Any],
hyperparameters: SimulationHyperparameters,
simulation_type: SimulationType,
result: SerializedSimulationResult,
wavelengths: list[float],
execution_time_seconds: float,
status: SimulationStatus = "success",
error_message: str = "",
pdk_version: str = "",
) -> StoredSimulationResult
Save a simulation result to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_name
|
str
|
Name of the component. |
required |
factory_name
|
str
|
Name of the factory. |
required |
component_settings
|
dict[str, Any]
|
Component settings dictionary. |
required |
model_parameters
|
dict[str, Any]
|
Model parameters dictionary. |
required |
hyperparameters
|
SimulationHyperparameters
|
Simulation hyperparameters. |
required |
simulation_type
|
SimulationType
|
Type of simulation. |
required |
result
|
SerializedSimulationResult
|
Serialized simulation result. |
required |
wavelengths
|
list[float]
|
List of wavelengths used. |
required |
execution_time_seconds
|
float
|
Execution time in seconds. |
required |
status
|
SimulationStatus
|
Status of the simulation ("success" or "error"). |
'success'
|
error_message
|
str
|
Error message if status is "error". |
''
|
pdk_version
|
str
|
Version of the PDK used. |
''
|
Returns:
| Type | Description |
|---|---|
StoredSimulationResult
|
The stored simulation result with computed ID. |
send_message
¶
Send a message to vscode.
Uses the high-performance Rust WebSocket implementation. This function will silently ignore errors and implement a cooldown period to avoid spamming failed connection attempts.
set_all_factories_has_model
¶
Set the has_model field for all factories in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
has_model
|
bool
|
Boolean value to set for the has_model field. |
required |
set_factories_has_model_by_names
¶
Set the has_model field for multiple factories by their names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to modify. |
()
|
has_model
|
bool
|
Boolean value to set for the has_model field. |
required |
set_factories_status_by_names
¶
Modify the status of multiple factories by their names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str
|
Names of the factories to modify. |
()
|
status
|
str
|
New status to set for the factories. |
required |
set_ws_port
¶
Set the websocket port (from CLI --ws-port argument).
sync_from_kcl
¶
Sync all cells from gf.kcl into the components table of the database.
track_error
¶
Track an error with Datadog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception | str
|
The exception or error message string. |
required |
context
|
dict[str, Any] | None
|
Additional context key-value pairs. |
None
|
track_warning
¶
Track a warning with Datadog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Warning message. |
required |
context
|
dict[str, Any] | None
|
Additional context key-value pairs. |
None
|
try_func
¶
try_func(
func: F | None = None,
/,
*,
default: Any = None,
default_factory: Callable | None = None,
) -> F
Try to execute a function and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
F | None
|
The function to execute. |
None
|
default
|
Any
|
Default value to return if the function raises an exception. |
None
|
default_factory
|
Callable | None
|
Optional callable to generate a default value. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
F
|
A wrapped function that returns the result or a default value. |
update_factories
¶
update_factories(
add: list[FactoryRecord], remove: list[str], *, update_last_modified: bool = True
) -> None
Atomically add/replace and remove factories in a single transaction.
This ensures readers never see a state where factories have been removed but not yet re-added.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
add
|
list[FactoryRecord]
|
FactoryRecord objects to add or replace. |
required |
remove
|
list[str]
|
Names of factories to remove. |
required |
update_last_modified
|
bool
|
If True, updates the last_updated timestamp. |
True
|
validate_access
¶
validate_access(
pdk_name: str,
api_key: str = "",
pdk_key: str = "",
*,
check_pdk_access: bool = False,
) -> dict[str, Any]
Validates the API key and returns the license information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdk_name
|
str
|
Name of the PDK to check access for. |
required |
api_key
|
str
|
API key to validate. |
''
|
pdk_key
|
str
|
PDK secret key to validate. |
''
|
check_pdk_access
|
bool
|
Whether to check access to the specified PDK. |
False
|