GithubHelp home page GithubHelp logo

Comments (7)

sebastian-goeldi avatar sebastian-goeldi commented on September 26, 2024 1

@doddgray seems reasonable to me. I am totally on board with doing this at least from the quick read through I did. I think in general it might also be better in the ipython (and probably shell) case to use a temp file. My motivation behind the build folder was so that there is traceability (and we don't need to care too much about tempfiles as they can be nasty if we or python clean up too fast). As it will allow you to go back and inspect the gds in case something went wrong or you accidentally close a gds which takes some time to build, etc.

Feel free to open the PR on kfactory. I am the main maintainer over there and @joamatab is the one that finds most of the bugs ^^

from gdsfactory.

joamatab avatar joamatab commented on September 26, 2024

What version of klayout are you using?

You need to update klayout to a somewhat recent version

from gdsfactory.

fp-matt avatar fp-matt commented on September 26, 2024

I am currently using KLayout v0.29.0

from gdsfactory.

joamatab avatar joamatab commented on September 26, 2024

What version on klive?

from gdsfactory.

sebastian-goeldi avatar sebastian-goeldi commented on September 26, 2024

@joamatab you only overwrote Component.show right, or only gf.show?

I think one might go to KFactory directly and therefore write a oasis (default behavior for kfactory on show).

from gdsfactory.

fp-matt avatar fp-matt commented on September 26, 2024

@joamatab I have klive v0.3.2

from gdsfactory.

doddgray avatar doddgray commented on September 26, 2024

I also ran into this issue after upgrading to v8 and needed to find a quick fix.

To do this I added a special case in kfactory.kcell to recognize calls from IPython kernels in the handling of name and used tempfile paths for the OAS files in that scenario. It seems to fix the issue, at least interactive sessions can stream GDS data to KLayout again. Maybe not the right way to do this in the long run.

In a local branch I modified the code here:
https://github.com/gdsfactory/kfactory/blob/2e8612db42b7da756ff84eafd6ab9a667d695de8/src/kfactory/kcell.py#L7577
to look like

    # Find the file that calls stack
    try:
        stk = inspect.getouterframes(inspect.currentframe())
        frame = stk[2]
        frame_filename_stem = Path(frame.filename).stem
        if frame_filename_stem.startswith("<ipython-input"):    # Case 1: IPython Kernel call
            ipython_shell_id = frame_filename_stem.rstrip(">").split("-")[-1]
            name = f"ipython-{ipython_shell_id}"
        else:                                                                              #  Case 2: Not IPython Kernel call
            if frame.function != "<module>":
                name = frame_filename_stem + "_" + frame.function
            else:
                name = frame_filename_stem

and the code here:
https://github.com/gdsfactory/kfactory/blob/2e8612db42b7da756ff84eafd6ab9a667d695de8/src/kfactory/kcell.py#L7659C1-L7661C63
to look like:

                if wtd is not None:
                    if name.startswith("ipython-"):
                        root = Path(tempfile.gettempdir()) / "gdsfactory"
                    else:
                        root = Path(wtd) / "build/gds"
                    root.mkdir(parents=True, exist_ok=True)
                    tf = root / Path(name).with_suffix(".oas")

I'm happy to create a pull request, but not sure if this is how the maintainers want to approach this.

from gdsfactory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.