Skip to content

better labels#211

Merged
joamatab merged 5 commits intomainfrom
better_labels
Apr 13, 2026
Merged

better labels#211
joamatab merged 5 commits intomainfrom
better_labels

Conversation

@joamatab
Copy link
Copy Markdown
Contributor

@joamatab joamatab commented Feb 25, 2026

  • better_rings
  • better_rings
  • better_rings
  • better_xor
  • better labels

Summary by Sourcery

Update ring cell APIs to support configurable bend components while enriching test coverage and infrastructure for port-aware regression testing and GDS XOR visualization.

New Features:

  • Allow cband and oband ring_single cells to accept a configurable bend component with an Euler fraction parameter.
  • Add a pytest difftest helper that generates GDS XOR artifacts and optional reference updates for layout regressions.
  • Introduce sample scripts in si500 and sin300 PDKs to visually inspect specific coupler cells.

Enhancements:

  • Export component ports in all PDK settings regression tests to validate port positions and metadata.
  • Regenerate numerous YAML-based settings fixtures to include detailed port definitions for optical and electrical components.
  • Extend the Makefile with dedicated targets for port-position tests and GDS reference regeneration using the new update flag.
  • Broaden the Release Drafter workflow triggers to run on pull request events and manual dispatches.
  • Upgrade the gdsfactory dependency to version 9.35.1 to leverage newer layout and port features.

CI:

  • Adjust GitHub Actions release-drafter workflow to respond to more PR-related events for better automation.

Tests:

  • Add and update regression fixtures to check that serialized components now include explicit port data and verify optical port positions across PDKs.

Chores:

  • Add a test diffs output directory and gitignore updates to manage generated comparison artifacts.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Feb 25, 2026

Reviewer's Guide

Updates regression test infrastructure and fixtures to include explicit port data, improves GDS difftest UX with visual XOR outputs and an update flag, exposes new ring configuration options, and enhances CI release workflow and Makefile targets to better manage labeling and GDS reference updates.

Sequence diagram for updated ring_single bend resolution

sequenceDiagram
    actor Designer
    participant ring_single_cband
    participant gf_get_component
    participant gf_c_ring_single

    Designer->>ring_single_cband: call ring_single(gap, radius, length_x, length_y, cross_section, bend, p)
    ring_single_cband->>gf_get_component: get_component(bend, p, radius, cross_section)
    gf_get_component-->>ring_single_cband: bend_component
    ring_single_cband->>gf_c_ring_single: ring_single(gap, radius, length_x, length_y, bend_component, straight, coupler_ring, cross_section, length_extension)
    gf_c_ring_single-->>Designer: ring_component
Loading

Flow diagram for updated Makefile test and GDS update workflow

flowchart LR
    dev[Developer]
    make_test[Run make test]
    make_test_ports[Run make test-ports]
    make_test_force[Run make test-force]
    pytest_all[pytest selected test suites]
    pytest_ports[pytest optical_port_positions tests]
    pytest_force[pytest with --update-gds-refs --force-regen]
    gds_refs[GDS reference files updated]

    dev --> make_test
    dev --> make_test_ports
    dev --> make_test_force

    make_test --> pytest_all
    make_test_ports --> pytest_ports
    make_test_force --> pytest_force
    pytest_force --> gds_refs
Loading

File-Level Changes

Change Details Files
Include ports in component settings regression data and regenerate fixtures accordingly.
  • Change si220_cband/oband, si500, and sin300 settings tests to call component.to_dict(with_ports=True) so ports are serialized into regression data.
  • Regenerate numerous settings.yml fixtures to add a structured ports section for optical, electrical, pad, and vertical_te ports.
  • Ensure components without ports still serialize a ports: {} section to keep schemas consistent.
tests/test_si220_cband.py
tests/test_si220_oband.py
tests/test_si500.py
tests/test_sin300.py
tests/test_si220_cband/*.yml
tests/test_si220_oband/*.yml
Introduce a shared pytest difftest helper that produces XOR GDS and PNG images and supports conditional reference updates.
  • Add tests/conftest.py with a global difftest() that writes run GDS files, compares against reference GDS, and optionally copies new references when missing or accepted.
  • Add a --update-gds-refs pytest option stored in a small config dict and used to control whether GDS refs may be updated.
  • On GDS mismatch, generate an XOR diff GDS via gdsfactory.difftest.diff, render it to PNG using klayout LayoutView, and raise a detailed AssertionError referencing all artifacts and the flag to update refs.
tests/conftest.py
Expose configurable bend components in ring_single cells and rely on core gdsfactory implementation for edge cases.
  • Add bend and p parameters to cspdk si220 cband/oband ring_single APIs, documenting bend type and Euler percentage p.
  • Remove custom zero-length straight handling logic and delegate ring construction entirely to gf.c.ring_single.
  • Resolve bend by calling gf.get_component(bend, p=p, radius=radius, cross_section=cross_section) and passing that into gf.c.ring_single.
cspdk/si220/cband/cells/rings.py
cspdk/si220/oband/cells/rings.py
Improve Makefile and CI workflow to better manage GDS reference updates and labeling/release automation.
  • Add a test-ports make target that runs only the optical port position tests across several PDKs.
  • Extend test-force target to pass --update-gds-refs along with --force-regen so reference GDS files are refreshed automatically.
  • Broaden .github/workflows/release-drafter.yml to also trigger on PR events and manual workflow_dispatch, and rename the workflow to 'Release Drafter and Labels' to reflect labeling behavior.
Makefile
.github/workflows/release-drafter.yml
Update dependency on gdsfactory and add small helper scripts to debug port positions for specific PDK cells.
  • Bump gdsfactory dependency from ~9.34.0 to ~9.35.1 in pyproject.toml to pick up newer behavior (e.g., improved port handling and difftest support).
  • Add sample scripts in cspdk/si500/samples and cspdk/sin300/samples to activate the respective PDK and visualize selected coupler variants for port debugging.
pyproject.toml
cspdk/si500/samples/all_cells2.py
cspdk/sin300/samples/all_cells2.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In both si220 ring_single wrappers, passing bend=gf.get_component(...) into gf.c.ring_single changes the API from a ComponentSpec/name to a concrete Component instance; if gdsfactory expects a spec here, this should instead pass the bend spec/parameters, not a pre-instantiated component.
  • The removal of the explicit zero-length (length_x/length_y == 0) handling in ring_single means you now fully rely on gf.c.ring_single for those edge cases; if zero-length straights previously avoided port overlap issues, consider verifying that gf.c.ring_single handles these geometries equivalently or restoring a lightweight guard.
  • The custom difftest in tests/conftest.py still prompts via input() when --update-gds-refs is set, which is not suitable for automated CI runs; consider making update behavior fully non-interactive (e.g., always update or controlled by an additional flag) and avoiding klayout-based GUI calls in headless environments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In both si220 ring_single wrappers, passing `bend=gf.get_component(...)` into `gf.c.ring_single` changes the API from a ComponentSpec/name to a concrete Component instance; if gdsfactory expects a spec here, this should instead pass the bend spec/parameters, not a pre-instantiated component.
- The removal of the explicit zero-length (length_x/length_y == 0) handling in ring_single means you now fully rely on gf.c.ring_single for those edge cases; if zero-length straights previously avoided port overlap issues, consider verifying that gf.c.ring_single handles these geometries equivalently or restoring a lightweight guard.
- The custom difftest in tests/conftest.py still prompts via input() when `--update-gds-refs` is set, which is not suitable for automated CI runs; consider making update behavior fully non-interactive (e.g., always update or controlled by an additional flag) and avoiding klayout-based GUI calls in headless environments.

## Individual Comments

### Comment 1
<location path="tests/conftest.py" line_range="43-52" />
<code_context>
+def difftest(  # noqa: C901
</code_context>
<issue_to_address>
**issue (bug_risk):** The custom `difftest` helper is interactive when `--update-gds-refs` is used, which can make automated runs non-deterministic.

Within the `if _config["update_gds_refs"]:` branch, `difftest` calls `input()` to confirm updates, which can hang or behave unpredictably in non-interactive contexts (CI, pre-commit, etc.). Consider either making `--update-gds-refs` non-interactive (always update) and adding a separate flag for interactive review, or failing fast with a clear error when used in a non-interactive environment. This will keep behavior deterministic for automated pipelines.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/conftest.py
Comment on lines +43 to +52
def difftest( # noqa: C901
component: gf.Component,
test_name: str | None = None,
dirpath: pathlib.Path = pathlib.Path.cwd(), # noqa: B008
xor: bool = True,
dirpath_run: pathlib.Path | None = None,
ignore_sliver_differences: bool | None = None,
sliver_tolerance: int = 1,
) -> None:
"""Custom difftest that saves XOR diff images on failure instead of prompting."""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The custom difftest helper is interactive when --update-gds-refs is used, which can make automated runs non-deterministic.

Within the if _config["update_gds_refs"]: branch, difftest calls input() to confirm updates, which can hang or behave unpredictably in non-interactive contexts (CI, pre-commit, etc.). Consider either making --update-gds-refs non-interactive (always update) and adding a separate flag for interactive review, or failing fast with a clear error when used in a non-interactive environment. This will keep behavior deterministic for automated pipelines.

Copy link
Copy Markdown
Contributor

@ThomasPluck ThomasPluck left a comment

Choose a reason for hiding this comment

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

pass tests

@joamatab joamatab merged commit f857f9b into main Apr 13, 2026
7 of 8 checks passed
@joamatab joamatab deleted the better_labels branch April 13, 2026 15:04
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.

3 participants