Skip to content

tests: restore the generic PDK layer table between test modules - #552

Open
Alisama20 wants to merge 1 commit into
gdsfactory:mainfrom
Alisama20:ali/fix-flaky-physical-layers
Open

Alisama20 wants to merge 1 commit into
gdsfactory:mainfrom
Alisama20:ali/fix-flaky-physical-layers

Conversation

@Alisama20

Copy link
Copy Markdown
Collaborator

Three tests in tests/meep/test_physical_layers.py fail depending on test order. I saw them on #548 (ubuntu, seed 2179762284) and #550 (macos, seed 1753024304). They pass alone and on main.

I bisected the Linux order down to four tests in four modules:

  1. tests/palace/test_magnetostatic_config.py::test_reversing_a_source_keeps_the_mesh_and_flips_only_its_direction leaves IHP active. Activating IHP deletes the empty generic layers.
  2. tests/fdtd/test_runtime_compatibility.py::test_artifact_simulation_is_a_deprecated_alias registers a raw (2, 0) in the freed slot 0.
  3. tests/palace/test_via_merge_clip_plumbing.py::test_clipping_does_not_hide_a_short_inside_one_bar re-activates the generic PDK. gdsfactory's restore calls Layout.move_layer / delete_layer, which raise on locked cells, and it swallows the error. The layout then holds two (2, 0) layers.
  4. tests/fdtd/test_monitor_names.py::test_xy_false_ignores_name_without_deprecation_warning. LAYER.SLAB150 writes to one (2, 0) layer, kcl.layer(2, 0) reads the other, and the slab region is empty.

The root is in gdsfactory (9.51.0) and I did not change it. This PR adds restore_generic_pdk() to tests/_helpers.py and a module-scoped autouse fixture in tests/conftest.py that runs it before and after every test module. It names each generic slot as the enum does, moves a foreign layer out of a generic slot and merges duplicate layers. It unlocks cells only while it does that. Nothing under src/ changes.

Checked: the first 1688 tests of the failing Linux order plus the three tests went from 3 failed to 1689 passed. The 4-test chain went from 3 failed to passing. The full suite passes with both seeds. tests/test_generic_pdk_restore.py adds three regression tests for the helper.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T20:14:48.971267Z e8be4be New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cd3bcce37

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/_helpers.py
if twins:
new_home = twins[0]
else:
new_home = layout.insert_layer(kdb.LayerInfo(*held))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep displaced layers out of IHP enum slots

When a prior module has activated IHP, the generic activation above prunes IHP's empty, fixed layer indices, and layout.insert_layer here can reuse one of those indices for the displaced foreign tuple. The added (250, 0) regression takes this branch and leaves nonempty geometry there; if a later default IHP test calls ihp.PDK.activate() while the cached locked_cell remains, IHP cannot restore its reserved slot without the same locked-cell relocation problem, so its enum may resolve to the foreign layer. Allocate a slot outside all registered enum reservations and add a generic-to-IHP regression.

AGENTS.md reference: AGENTS.md:L14-L15

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.68%. Comparing base (55aad85) to head (e8be4be).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #552      +/-   ##
==========================================
+ Coverage   91.66%   91.68%   +0.01%     
==========================================
  Files         216      216              
  Lines       30533    30533              
  Branches     5672     5672              
==========================================
+ Hits        27989    27993       +4     
+ Misses       1458     1457       -1     
+ Partials     1086     1083       -3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Alisama20

Copy link
Copy Markdown
Collaborator Author

@benvial could you review this one? GitHub won't let me add you as a reviewer.

Three tests in tests/meep/test_physical_layers.py failed depending on test
order: an earlier chain of PDK switches left two (2, 0) layers in the shared
layout. A module-scoped autouse fixture now restores the generic layer table
before and after every test module.
@vvahidd
vvahidd force-pushed the ali/fix-flaky-physical-layers branch from 3cd3bcc to e8be4be Compare December 1, 2026 20:10

This branch has not been deployed

No deployments
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.

1 participant