gdsfactory.read.from_yaml

Contents

gdsfactory.read.from_yaml#

gdsfactory.read.from_yaml(yaml_str: str | ~pathlib.Path | ~typing.IO[~typing.Any] | dict[str, ~typing.Any], routing_strategy: dict[str, ~collections.abc.Callable[[...], ~collections.abc.Sequence[~kfactory.routing.generic.ManhattanRoute | ~kfactory.routing.aa.optical.OpticalAllAngleRoute]]] | None = None, routing_strategies: dict[str, ~collections.abc.Callable[[...], ~collections.abc.Sequence[~kfactory.routing.generic.ManhattanRoute | ~kfactory.routing.aa.optical.OpticalAllAngleRoute]]] | None = None, label_instance_function: ~gdsfactory.read.from_yaml.LabelInstanceFunction = <function add_instance_label>, name: str | None = None) Component[source]#

Returns Component from YAML string or file.

YAML includes instances, placements, routes, ports and connections.

Parameters:
  • yaml_str – YAML string or file.

  • routing_strategy – for each route. (deprecated)

  • routing_strategies – for each route.

  • label_instance_function – to label each instance.

  • name – Optional name.

valid variables:

name: Optional Component name
settings: Optional variables
pdk: overrides
info: Optional component info
    description: just a demo
    polarization: TE
    ...
instances:
    name:
        component: (ComponentSpec)
        settings (Optional)
            length: 10
            ...
placements:
    x: float, str | None  str can be instanceName,portName
    y: float, str | None
    rotation: float | None
    mirror: bool, float | None float is x mirror axis
    port: str | None port anchor
connections (Optional): between instances
ports (Optional): ports to expose
routes (Optional): bundles of routes
    routeName:
    library: optical
    links:
        instance1,port1: instance2,port2
settings:
    length_mmi: 5

instances:
    mmi_bot:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_top:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: ${settings.length_mmi}

placements:
    mmi_top:
        port: o1
        x: 0
        y: 0
    mmi_bot:
        port: o1
        x: mmi_top,o2
        y: mmi_top,o2
        dx: 30
        dy: -30
routes:
    optical:
        library: optical
        links:
            mmi_top,o3: mmi_bot,o1