Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component reduce #2480

Merged
merged 4 commits into from Jan 21, 2024
Merged

Component reduce #2480

merged 4 commits into from Jan 21, 2024

Conversation

simbilod
Copy link
Collaborator

@simbilod simbilod commented Jan 21, 2024

Override the "reduce" built-in method in Component to allow pickling. This is useful when integrating gdsfactory/gplugins with libraries that use pickling to move data around

@joamatab I'm not sure about this one because there's a lot going with the caching/serialization in gdsfactory. I tried using json and yaml serialization, but it didn't work as well as gds + metadata like I do now.

I don't really care how it's done, I just want to fix the "gdstk.Cell not serializable" errors we get when we try to pickle Components, and I just want a component similar in structure to be returned (I don't really care about unique IDs and such since this is for simulation, not layout)

Copy link

codecov bot commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6cd8e78) 72.55% compared to head (5a87a0c) 72.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2480      +/-   ##
==========================================
+ Coverage   72.55%   72.57%   +0.01%     
==========================================
  Files         366      366              
  Lines       23367    23381      +14     
  Branches     3807     3807              
==========================================
+ Hits        16954    16968      +14     
  Misses       5286     5286              
  Partials     1127     1127              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


# Component functions
def serialize_gds(component):
"""Saves Component as GDS + YAML metadata in temporary files with unique name."""
gds_filepath = GDSDIR_TEMP / component.name
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joamatab should this use something else than the name to guarantee there are no collisions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think name is the best we can use :)

Copy link
Contributor

@joamatab joamatab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you Simon!


# Component functions
def serialize_gds(component):
"""Saves Component as GDS + YAML metadata in temporary files with unique name."""
gds_filepath = GDSDIR_TEMP / component.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think name is the best we can use :)

@joamatab joamatab merged commit 19922cb into main Jan 21, 2024
10 checks passed
@joamatab joamatab deleted the component_reduce branch January 21, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants