Skip to content

fix: Fix --pre test by stopping using the deprecated sentry_sdk method #1304

Merged
Czaki merged 4 commits intodevelopfrom
fix_pre_test
Sep 23, 2025
Merged

fix: Fix --pre test by stopping using the deprecated sentry_sdk method #1304
Czaki merged 4 commits intodevelopfrom
fix_pre_test

Conversation

@Czaki
Copy link
Collaborator

@Czaki Czaki commented Sep 23, 2025

Summary by Sourcery

Migrate the Sentry integration test to the new capture_envelope API and update the GitHub Actions prerelease workflow for better output formatting

Enhancements:

  • Update test_exception_pass to use capture_envelope and assert on the new envelope payload structure
  • Add done flag assertion to ensure the test callback is executed

CI:

  • Set FORCE_COLOR and COLUMNS environment variables in the test_prereleases workflow

Summary by CodeRabbit

  • Refactor
    • Updated error-reporting integration to set user context via the current scope, improving reliability of user information in crash reports.
  • Tests
    • Adjusted Sentry tests to validate envelope-based capture and added completion checks to ensure asynchronous paths finish.
  • Chores
    • CI workflow enforces colored output and a wider terminal width for clearer logs.

@Czaki Czaki added this to the 0.16.4 milestone Sep 23, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Sentry test to stop using the deprecated capture_event method and adjusts the assertion logic to work with enveloped data, while also enhancing the GitHub Actions prerelease workflow with environment variables for improved test output formatting.

File-Level Changes

Change Details Files
Replace deprecated sentry_sdk.capture_event with capture_envelope in the exception test
  • Introduce a done flag to validate callback execution
  • Modify check_event to accept an envelope and traverse to exception frames
  • Patch transport.capture_envelope instead of capture_event via monkeypatch
  • Add final assertion to confirm check_event was invoked
package/tests/test_PartSeg/test_sentry.py
Add environment variables to the prerelease test workflow for colored and wider output
  • Set FORCE_COLOR=1 to force colored logs
  • Define COLUMNS=120 to widen terminal output
.github/workflows/test_prereleases.yml

Possibly linked issues

  • Add side view option #123: PR fixes failing --pre test by updating sentry_sdk method in test_sentry.py.
  • #0: The PR fixes the failing --pre test by updating the deprecated sentry_sdk.capture_event to sentry_sdk.capture_envelope.
  • #0: PR updates deprecated sentry_sdk method to fix the failing pre-install test workflow.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Added CI environment defaults to a GitHub Actions workflow; refactored Sentry scope usage to call get_current_scope() and scope.set_user(...); updated a Sentry test to use capture_envelope and assert on envelope payload, adding an async completion flag; bumped a project workspace version and added an sdk dependency.

Changes

Cohort / File(s) Summary of Changes
CI Workflow Env Defaults
.github/workflows/test_prereleases.yml
Added global env entries: FORCE_COLOR: 1 and COLUMNS: 120; no step or control-flow edits.
Sentry Scope Handling (runtime)
package/PartSeg/common_backend/base_argparser.py
Replaced sentry_sdk.configure_scope() context-manager usage with sentry_sdk.get_current_scope() and scope.set_user(...).
Sentry Tests (envelope path)
package/tests/test_PartSeg/test_sentry.py
Switched test dispatch from capture_event to capture_envelope; adjusted assertions to inspect envelope.items[0].payload.json[...]; added a done flag to ensure async completion.
Project metadata
.github/project_dict.pws
Bumped personal_ws version (21→22) and added new sdk entry under deps.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Application
  participant Sdk as sentry_sdk
  participant Scope as Current Scope
  participant Transport as Transport
  participant Test as Test

  App->>Sdk: exception occurs / capture
  Sdk->>Scope: get_current_scope()
  Scope-->>Scope: set_user({...})
  Sdk->>Transport: capture_envelope(envelope)
  Transport-->>Test: deliver envelope
  Test->>Test: assert envelope.items[0].payload.json contains frames
  Test->>Test: mark done = True
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through CI light,
Sets scopes by day and tests by night.
Envelopes tumble, frames in tow,
Colors and columns line up in row.
Tiny paws approve — commits ready to go. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely and accurately describes the primary change: fixing the '--pre' test by ceasing use of a deprecated sentry_sdk method (the tests were migrated to capture_envelope). It is specific and focused enough for a reviewer to understand the main intent without listing minor workflow adjustments.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_pre_test

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b0025c4 and 83796c1.

📒 Files selected for processing (1)
  • .github/project_dict.pws (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/project_dict.pws
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
  • GitHub Check: 4DNucleome.PartSeg
  • GitHub Check: 4DNucleome.PartSeg (Tests_other test windows)
  • GitHub Check: 4DNucleome.PartSeg (Tests_linux test_linux)
  • GitHub Check: 4DNucleome.PartSeg (Tests_other test macos)
  • GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller windows)
  • GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller macos_arm)
  • GitHub Check: 4DNucleome.PartSeg (Builds sdist)
  • GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller macos)
  • GitHub Check: 4DNucleome.PartSeg (Builds pyinstaller_linux)
  • GitHub Check: Base py3.11 / macos-13 py 3.11 latest PyQt5
  • GitHub Check: 4DNucleome.PartSeg (manifest_check manifest_check)
  • GitHub Check: 4DNucleome.PartSeg (Documentation_check Notebook_check)
  • GitHub Check: 4DNucleome.PartSeg (Documentation_check help)
  • GitHub Check: 4DNucleome.PartSeg (GetTestData linux)
  • GitHub Check: 4DNucleome.PartSeg (formatting_check check_formating)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Sourcery review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@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 there - I've reviewed your changes - here's some feedback:

  • The new test uses a manual done flag to verify capture_envelope was called; consider using pytest’s mock or monkeypatch call_count assertions for a cleaner invocation check.
  • check_event only inspects envelope.items[0]; to make the test more robust, filter envelope.items by their payload type so it doesn’t break if Sentry’s item ordering changes.
  • Review whether forcing color output (FORCE_COLOR) in the CI workflow is necessary—ANSI codes in logs can cause readability issues on some systems.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new test uses a manual done flag to verify capture_envelope was called; consider using pytest’s mock or monkeypatch call_count assertions for a cleaner invocation check.
- check_event only inspects envelope.items[0]; to make the test more robust, filter envelope.items by their payload type so it doesn’t break if Sentry’s item ordering changes.
- Review whether forcing color output (FORCE_COLOR) in the CI workflow is necessary—ANSI codes in logs can cause readability issues on some systems.

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.

@Czaki Czaki changed the title Fix --pre test by stop using deprecated sentry_sdk method fix: Fix --pre test by stopping using the deprecated sentry_sdk method Sep 23, 2025
@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (55cee42) to head (83796c1).
⚠️ Report is 36 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1304      +/-   ##
===========================================
+ Coverage    93.14%   93.16%   +0.01%     
===========================================
  Files          210      210              
  Lines        33270    33270              
===========================================
+ Hits         30991    30996       +5     
+ Misses        2279     2274       -5     

☔ View full report in Codecov by Sentry.
📢 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.

@sonarqubecloud
Copy link

@Czaki Czaki merged commit e4c8ebe into develop Sep 23, 2025
63 checks passed
@Czaki Czaki deleted the fix_pre_test branch September 23, 2025 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.

1 participant

Comments