gdsfactory / kfactory

gdsfactory with a klayout backend
https://gdsfactory.github.io/kfactory/
MIT License
28 stars 10 forks source link

Add enum for handling check_instances #341

Closed sebastian-goeldi closed 1 month ago

sebastian-goeldi commented 1 month ago

Allows different handling if any instance in the @cell decorated cell is off-grid or a non-90° rotation:

Example usage:

test.py ```python import kfactory as kf @kf.kcl.cell def rotated_bend() -> kf.KCell: c = kf.KCell() bend = c << kf.cells.euler.bend_euler(width=1, radius=10, layer=kf.kcl.layer(1, 0)) bend.drotate(30) straight = c << kf.cells.straight.straight( width=1, length=10, layer=kf.kcl.layer(2, 0) ) straight.connect("o1", bend, "o2") return c rotated_bend().show() ```

Run:

KFACTORY_CHECK_INSTANCES='vinstances' KFACTORY_LOGFILTER_LEVEL="DEBUG" KFACTORY_ALLOW_LAYER_MISMATCH=on python test.py

Or for single usage:

@cell(check_instances=config.CHECK_INSTANCES.VINSTANCES)

@tvt173

tvt173 commented 1 month ago

trying to understand how to set the behavior globally... the KFACTORY_CHECK_INSTANCES etc. that you mention above, those are meant to be environment variables? or how should they be set to change global behavior when executing a script?

tvt173 commented 1 month ago

for example, i would have expected that setting this in my script would have configured the setting globally, but i still see the same error

kf.config.check_instances = kf.conf.CHECK_INSTANCES.VINSTANCES