-
Notifications
You must be signed in to change notification settings - Fork 436
Fix the aiq_compatibility_span_prefix fixture
#1199
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
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: David Gardner <[email protected]>
…e checks to fail in other modules which have already imported the span module Signed-off-by: David Gardner <[email protected]>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
WalkthroughAdded a notebook cell metadata tag and refactored a test fixture to perform reversible in-place adjustments to span prefix enum values instead of reloading modules or changing environment variables; also added a pytest warning filter in configuration. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Runner
participant Fixture as aiq_compatibility_span_prefix
participant Span as span module
participant Enum as SpanAttributes
Note over Test,Fixture `#EFEFEF`: Test setup
Test->>Fixture: enter fixture
Fixture->>Span: read _SPAN_PREFIX (origPrefix)
Fixture->>Enum: find values starting with origPrefix
Fixture->>Enum: replace matching prefix with "aiq." (record originals)
Note over Test,Fixture `#DFF7DF`: Test execution
Fixture-->>Test: yield (tests run using modified enums)
Note over Test,Fixture `#FDE8E8`: Teardown
Test->>Fixture: fixture cleanup
Fixture->>Span: restore _SPAN_PREFIX to origPrefix
Fixture->>Enum: restore recorded original enum values
Fixture-->>Test: teardown complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*⚙️ CodeRabbit configuration file
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
examples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py (1)
79-100: Consider adding type hint for the fixture.The fixture implementation correctly avoids the module reload issue by mutating enum values in-place. The approach of directly modifying
_value_on enum members is unconventional but necessary given that reloading causes pydantic validation failures (as described in the PR objectives). The restoration logic properly reverts all changes.Consider adding a return type hint for better type safety:
@pytest.fixture(name="aiq_compatibility_span_prefix") -def aiq_compatibility_span_prefix_fixture(): +def aiq_compatibility_span_prefix_fixture() -> Generator[None, None, None]: """ The values of the SpanAttributes are defined on import based upon the NAT_SPAN_PREFIX environment variable. Setting the environment variable after the fact has no impact. """As per coding guidelines, Python functions should use type hints for parameters and return values.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
examples/notebooks/getting_started_with_nat.ipynb(1 hunks)examples/notebooks/mcp_setup_and_integration.ipynb(0 hunks)examples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py(1 hunks)
💤 Files with no reviewable changes (1)
- examples/notebooks/mcp_setup_and_integration.ipynb
🧰 Additional context used
📓 Path-based instructions (2)
**/*
⚙️ CodeRabbit configuration file
**/*: # Code Review Instructions
- Ensure the code follows best practices and coding standards. - For Python code, follow
PEP 20 and
PEP 8 for style guidelines.- Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values (except for return values of
None,
in that situation no return type hint is needed).
Example:def my_function(param1: int, param2: str) -> bool: pass- For Python exception handling, ensure proper stack trace preservation:
- When re-raising exceptions: use bare
raisestatements to maintain the original stack trace,
and uselogger.error()(notlogger.exception()) to avoid duplicate stack trace output.- When catching and logging exceptions without re-raising: always use
logger.exception()
to capture the full stack trace information.Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any
words listed in the
ci/vale/styles/config/vocabularies/nat/reject.txtfile, words that might appear to be
spelling mistakes but are listed in theci/vale/styles/config/vocabularies/nat/accept.txtfile are OK.Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,
and should contain an Apache License 2.0 header comment at the top of each file.
- Confirm that copyright years are up-to date whenever a file is changed.
Referenced Documentation Contents
ci/vale/styles/config/vocabularies/nat/reject.txt:
Defines regex patterns ...
Files:
examples/notebooks/getting_started_with_nat.ipynbexamples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py
examples/**/*
⚙️ CodeRabbit configuration file
examples/**/*: - This directory contains example code and usage scenarios for the toolkit, at a minimum an example should
contain a README.md or file README.ipynb.
- If an example contains Python code, it should be placed in a subdirectory named
src/and should
contain apyproject.tomlfile. Optionally, it might also contain scripts in ascripts/directory.- If an example contains YAML files, they should be placed in a subdirectory named
configs/. - If an example contains sample data files, they should be placed in a subdirectory nameddata/, and should
be checked into git-lfs.
Files:
examples/notebooks/getting_started_with_nat.ipynbexamples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py
🧬 Code graph analysis (1)
examples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py (1)
src/nat/data_models/span.py (1)
SpanAttributes(92-106)
🔇 Additional comments (2)
examples/notebooks/getting_started_with_nat.ipynb (1)
437-437: LGTM! Documentation cleanup looks good.The removal of dask uninstallation instructions simplifies the notebook setup without impacting functionality.
examples/observability/simple_calculator_observability/tests/test_simple_calc_observability.py (1)
81-84: Excellent addition of explanatory docstring.The docstring clearly explains why this fixture is necessary - the SpanAttributes values are defined at import time based on the environment variable.
This reverts commit bdc6b0a. Signed-off-by: David Gardner <[email protected]>
…s are not altering the installed packages Signed-off-by: David Gardner <[email protected]>
Signed-off-by: David Gardner <[email protected]>
Description
The values of the
SpanAttributesenum are defined on import, the fixture originally attempted to reload thespanmodule. However this created a problem since other modules had already imported thespanmodule, which would cause pydantic validation to fail as the originalSpanContextclass no longer strictly matches the newSpanContext.Unrelated fix: Add the
skip_e2e_testtag to theuv pip uninstall daskcell to prevent the notebook from altering the environment mid-test.Silence a warning being emitted by strands that we have no control over [BUG] DeprecationWarning being emitted when importing strands strands-agents/sdk-python#1236
Closes #1197
By Submitting this PR I confirm:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.