gdsfactoryplus
¶GDSFactoryplus python library.
Modules:
Name | Description |
---|---|
bbox |
Generate cell bbox. |
cli |
GDSFactory+ CLI. |
cli_test |
Test Component Builds. |
core |
Core GDSFactory+ utilities. |
deduplicate |
Deduplication decorator. |
export_spice |
Uses VLSIRTools to convert from Klayout's DB Netlist to common spice formats. |
freeze |
Freeze a python cell as schematic netlist. |
generate_svg |
Generate SVG from cell. |
logger |
GDSFactory+ Logger. |
models |
GDSFactory+ Pydantic models. |
project |
Find the GDSFactory+ project folder. |
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. |
simulate |
Simulate a factory. |
version |
Simply the GDSFactory+ version. |
Classes:
Name | Description |
---|---|
ApiSettings |
API Settings. |
Arange |
An array range definition. |
DrcSettings |
DRC Settings. |
ExternalSettings |
External Settings. |
FrozenPdk |
A frozen PDK that prevents modification of its attributes. |
GptSettings |
GPT Settings. |
KwebSettings |
Kweb Settings. |
Linspace |
A linear spacing definition. |
LogSettings |
Logging settings. |
PdkSettings |
PDK Settings. |
ProjectSettings |
Settings. |
Settings |
Settings. |
SimSettings |
Simulation Settings. |
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. |
build_by_names |
Build multiple GDS cells by names. |
check_conn |
Run connectivity check on the given GDS file. |
check_drc |
Run DRC check on the given GDS file. |
clear_cells_from_cache |
Clear cells from cache by factory names. |
cli_environment |
Get a CLI environment. |
create_callgraph |
Create a directed graph from the call graph data. |
default_lib_paths |
Return default library paths. |
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. |
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_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_runtime_factories_dependency_graph |
Get a dependency graph for multiple factories. |
get_runtime_factory_dependencies |
Get the dependencies of a factory. |
get_schematic_recnet |
Get a schematic record netlist. |
get_settings |
Get the gdsfactoryplus settings. |
get_static_records |
Get static records from a call graph. |
get_svg |
Get the (possible cached) svg for a cell. |
get_tags_for_cell |
Get tags from a cell. |
get_wls |
Get the wavelengths used in the project. |
get_ws_port |
Get the websocket port from the project directory. |
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. |
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. |
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. |
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. |
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. |
sync_from_kcl |
Sync all cells from gf.kcl into the components table of the database. |
try_func |
Try to execute a function and return the result. |
unlazy |
Get the underlying object of a lazy import. |
validate_access |
Validates the API key and returns the license information. |
ApiSettings
¶
Bases: BaseSettings
API Settings.
Arange
¶
DrcSettings
¶
Bases: BaseSettings
DRC Settings.
ExternalSettings
¶
Bases: BaseSettings
External Settings.
Methods:
Name | Description |
---|---|
validate_axiomatic_api_key |
Get the axiomatic API key from the environment variable. |
FrozenPdk
¶
Bases: Pdk
A frozen PDK that prevents modification of its attributes.
GptSettings
¶
Bases: BaseSettings
GPT Settings.
KwebSettings
¶
Bases: BaseSettings
Kweb Settings.
Linspace
¶
LogSettings
¶
Bases: BaseSettings
Logging settings.
PdkSettings
¶
Bases: BaseSettings
PDK Settings.
ProjectSettings
¶
Bases: BaseSettings
Settings.
Methods:
Name | Description |
---|---|
settings_customise_sources |
Read the [project] section of the pyproject.toml. |
settings_customise_sources
classmethod
¶settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Read the [project] section of the pyproject.toml.
Settings
¶
Bases: BaseSettings
Settings.
Methods:
Name | Description |
---|---|
is_a_pdk |
Check if the settings are for a pdk or a project. |
settings_customise_sources |
Add global gdsfactoryplus.toml and local pyproject.toml to the sources. |
settings_customise_sources
classmethod
¶settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Add global gdsfactoryplus.toml and local pyproject.toml to the sources.
SimSettings
¶
Bases: BaseSettings
Simulation Settings.
activate_pdk_by_name
¶activate_pdk_by_name(name: str) -> Pdk
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_factories(*records: FactoryRecord, update_last_modified: bool = True) -> None
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. |
()
|
build_by_names
¶
check_conn
¶
check_drc
¶check_drc(
path: str | Path,
pdk: str = pdk or name,
process: str = process,
timeout: int = timeout,
host: str = host,
api_key: str = 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. |
pdk or name
|
process
|
str
|
the drc rules might be slightly different depending on the process |
process
|
timeout
|
int
|
timeout in seconds for the check (DRC only). |
timeout
|
host
|
str
|
api host (DRC only). |
host
|
api_key
|
str
|
the api key (DRC only). |
key
|
verbose
|
bool
|
if True, print status messages to stderr. |
True
|
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.
cli_environment
¶Get a CLI environment.
create_callgraph
¶
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_project_dir
¶find_project_dir() -> Path
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. |
generate_multipolygon
¶Generate a MultiPolygon from a component.
get_all_factories
¶
get_all_factory_names
¶Get all factory names from the database.
get_all_models
¶
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
¶
get_components_by_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_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_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_netlist_schema(netlist: dict) -> 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_pdk_name
¶get_pdk_name() -> str
Get the name of the pdk used in the project.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Name of the PDK. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the PDK name is not set in the project settings. |
get_ports
¶
get_runtime_factories_dependency_graph
¶get_runtime_factories_dependency_graph(*names: str) -> DiGraph
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_schematic_recnet
¶
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.
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_path(path: Path, *, reload: bool = False) -> ModuleType
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_picyml(
path: Path, module_name: str | None = None, *, reload: bool = False
) -> ModuleType
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. |
lazy_setattr
¶Lazily set an attribute on a LazyModule.
maybe_find_project_dir
¶maybe_find_project_dir() -> Path | None
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.
plot_callgraph
¶
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_components(*names: str) -> None
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_components_by_factories(*factory_names: str) -> None
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_factories(*names: str) -> None
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_models
¶remove_models(*names: str) -> None
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.
set_all_factories_has_model
¶set_all_factories_has_model(*, has_model: bool) -> None
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_factories_status_by_names
¶
sync_from_kcl
¶Sync all cells from gf.kcl into the components table of the database.
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. |
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
|