gdsfactory / kfactory

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

Use tempfile if called from IPython #405

Closed doddgray closed 6 days ago

doddgray commented 1 week ago

This PR is meant to address https://github.com/gdsfactory/gdsfactory/issues/2782.

It modifies kcell to handle the case when it is called from an IPython kernel. Currently an IPython call causes a bug when inspect is used to identify the calling python file. This just adds a check to see if the "filename" looks like an IPython call and if so streams to KLayout via a temporary OAS file (in Path(tempfile.gettempdir()) / "gdsfactory") rather than the build directory in the calling file's repository.

sourcery-ai[bot] commented 1 week ago

🧙 Sourcery has finished reviewing your pull request!


Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - You can change your review settings at any time by accessing your [dashboard](https://sourcery.ai/dashboard): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
doddgray commented 1 week ago

@sebastian-goeldi how does this look? I simplified the changes to reflect your suggestion. LMK if this needs anything else to merge.

sebastian-goeldi commented 1 week ago

LGTM

Can you remove that one commented line? Then I'll merge. I'll try to release soon. There are some annoying manhattan routing bugs that currently are blocking for gdsfactory to upgrade. Once I figure those out we should be good for a new release

doddgray commented 1 week ago

I will make that last edit in ~3 hours.

doddgray commented 1 week ago

I removed the commented print statement (line ~7600) that I think you were referencing. LMK if anything else is needed to merge.