-
Notifications
You must be signed in to change notification settings - Fork 701
ISSUE-3317: Remove maximum version constraint, increase minimum version on starlette by fixing unit tests #3456
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: main
Are you sure you want to change the base?
Conversation
… unit tests. Fixed some warnings in unit tests.
@aabmass could you review as well and are you able to upgrade the requirements? I'm not comfortable enough to update the lockfiles. |
|
||
|
||
@patch.dict( |
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.
How about using this in setUp?
test_env_patch = mock.patch.dict("os.environ", {content here})
test_env_patch.start()
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.
Done, stopped the patches in tearDown
@@ -13,6 +13,6 @@ | |||
# limitations under the License. | |||
|
|||
|
|||
_instruments = ("starlette >= 0.13, <0.15",) | |||
_instruments = ("starlette >= 0.13",) |
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.
Need to run tox -e generate
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.
Should be ok now
@@ -34,7 +34,7 @@ dependencies = [ | |||
] | |||
|
|||
[project.optional-dependencies] | |||
instruments = ["starlette >= 0.13, <0.15"] | |||
instruments = ["starlette >= 0.13"] |
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.
I think we need to update the requirements.latest.txt as well.
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.
Updated test-requirements.latest.txt and uv.lock
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.
Also updated test-requirements.oldest.txt as I had to increase minimum version
…trap/test-requirements. Use setUp/tearDown iso decorator on test class
We should test the min version. |
@Kludex those oldest tests were indeed failing. I've increased the minimal version to 0.37.2. This one is a year old and didn't cause any problems with me. Is this acceptable? Older versions were causing this issue for me encode/starlette#2770 |
This reverts commit 08df2be.
PR is ready to be reviewed again @emdneto, if anything needs a change, feel free to put me to work again ;) |
([#3448](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3448 | ||
- `opentelemetry-instrumentation-starlette` Remove max version constraint on starlete, increase min version ([#3456](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3456)) |
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.
([#3448](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3448 | |
- `opentelemetry-instrumentation-starlette` Remove max version constraint on starlete, increase min version ([#3456](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3456)) | |
([#3448](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3448)) | |
- `opentelemetry-instrumentation-starlette` Bump starlette supported version to 0.37.2 | |
([#3456](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3456)) |
Is there a reason we picked 0.37.2?
# via requests | ||
wrapt==1.16.0 | ||
wrapt==1.10.0 |
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.
This is strange
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.
It was supposed to not work on this version and raise an error like:
ImportError: cannot import name 'getargspec' from 'inspect'
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.
It is failing with that error (as was expected?). I got these new versions of oldest.txt and latest.txt by using the 'uv pip compile' commands in the respective files. Should these commands be updated, or should I update the '.in' file?
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.
@emdneto did you manually change the version of wrapt
in oldest.txt, because for me uv pip compile
(without-o
option) resolves to 1.10.0
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.
@MattiasDC could you please change the ".in" file to
# Used to generate test-requirements.{oldest,latest}.txt with uv pip compile
pytest~=7.4.4
requests~=2.32
httpx~=0.28
wrapt~=1.14.0
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-asgi
-e util/opentelemetry-util-http
-e instrumentation/opentelemetry-instrumentation-starlette[instruments]
and run uv pip compile command again?
# via | ||
# httpx | ||
# starlette | ||
asgiref==3.0.0 |
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.
Why are you downgrading this?
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.
All changes to oldest.txt and latest.txt were obtained by running the 'uv pip compile' commands which were listed on top of the respective files. Should I manually adjust them or should the pip compile command be changed?
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.
What command did you run?
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.
using uv 0.6.14:
Line 2 in 82d860b
# uv pip compile --python 3.8 --universal --resolution lowest-direct --no-emit-package opentelemetry-api --no-emit-package opentelemetry-semantic-conventions -c dev-requirements.txt instrumentation/opentelemetry-instrumentation-starlette/test-requirements.in -o instrumentation/opentelemetry-instrumentation-starlette/test-requirements.oldest.txt |
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.
Note that if a package version in oldest.txt was manually increased, uv pip compile
will leave it higher than it's own resolution.. You can check this if you omit the -o
option
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.
You can for example see that here, 3.0 is the minimum allowed:
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-asgi/pyproject.toml
Line 29 in 82d860b
"asgiref ~= 3.0", |
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.
@aabmass, do you remember manually changing things after running the uv pip compile
?
That maybe be fixed by using an older httpx in the requirements. |
Conditional dependencies are not supported in |
Description
Remove maximum version constraint on starlette, by fixing unit tests. Fixed some warnings in unit tests.
Problem was that the environment was patched only during the
setUp
execution, and not during the tests themselves. By putting the patch decorator on the class itself, the environment variables are patched during the test class, as is done in another place in the same file.This PR also includes some small changes to reduce the amount of warnings encountered in the unit tests.
route
androute_websocket
decoratorsStarletteInstrumentor._uninstrument
can clear all instrumented apps, use adiscard
i.s.o.remove
in the deletor of_InstrumentedStarlette
to prevent aKeyError
being raisedFixes #3317
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
All existing unit tests pass with the newest version of starlette (0.46.2)
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.