Closed 95-martin-orion closed 1 month ago
I think this is just fighting symptoms and actually a bad idea:
Imagine the following:
I would not want to debug this in a project
Our project follows the Google style guide for Python, which prohibits importing functions directly. This is useful because it means you don't have to check your entire repo for mycell()
to see if you can define it in other.py
- the module can always be used to differentiate it.
If the issue is instead that {module}_{function}
names can collide with existing cells (e.g. bend_euler
above), this can be avoided with alternate naming schemes. For example, {module}-{function}
cannot collide with an existing function name because -
is not a valid character in Python function names.
https://www.klayout.de/forum/discussion/comment/9963/#Comment_9963
-
is not necessarily a safe character to use in gds.
Thanks for the context. From that thread, it looks like $
might be a safe alternative, although {module}${function}
isn't as clear to read. Double underscore (__
) could also work, since these should be rare in function names.
This feature is important to our project because we often have variants of a component for different designs, and a layout may import multiple designs. Including the version in the component name (e.g. Foo_v00_euler
) is tedious, but manageable; the real issue comes in when someone forgets to do this and the cache silently replaces the component with a different version. We've had similar unexpected-caching issues happen before, and they're very difficult to track down.
You can actually very easily patch this in yourself, which I would recommend in this case as I am a bit hesitant to just implement this, as it will make debugging a nightmare:
When running main.py, this will yield:
Thanks for the detailed recommendation! That should be enough to unblock my team's upgrade to v8.
@joamatab what do you think about this?
I am hesitant to implement this as a flag in the cell decorator, but I would be willing to implement this as a separate decorator (e.g. as in the example above)
i think it would be nice to implement this
Initial testing is at #451 but it's not ready yet.
Is your feature request related to a problem? Please describe. gdsfactory v7.* supported
include_module
in cells, which allows the same function name to be used for cells in different modules without worrying about collisions. This is distinct fromkcl.cell(basename="foo")
, which cannot automatically include the name of the function in the cell name.Describe the solution you'd like Add the
include_module
behavior fromgf.cell
in gdsfactory v7.* tokcl.cell
and provide access to it in gdsfactory.For example, this should work: