Skip to content
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

♻️ Fixes deprecation warning of aiohttp client session #5321

Merged

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Feb 8, 2024

What do these changes do?

Fixes long standing deprecation warning on aiohttp.ClientSession() (more details in issue below). This change required a small redesign. This is the idea: Basically an aiohttp application created using app = create_safe_application() injects an event app.cleanup_ctx.append(persistent_client_session) to create an aiohttp.ClientSession that is attached to the lifespam of the application, i.e. a unique client session that is started and closed with the application. This is the only session used for all communications with other internal or external services. After the app starts, the session is ready and can be obtained using get_client_session. This pattern is used in all the aiohttp-based apps, i.e. web-server and storage.

This fix might unblock upgrading aiohttp #5206

  • 🔥 Removes some duplicated tests.

Related issue/s

How to test

  • all tests in place of servicelib
  • mainly covered packages/service-library/tests/aiohttp/test_application.py

Dev Checklist

DevOps Checklist

@pcrespov pcrespov self-assigned this Feb 8, 2024
@pcrespov pcrespov changed the title Is4628/deprecation client session ♻️ Fixes deprecation warning of aiohttp client session Feb 8, 2024
@pcrespov pcrespov added a:storage issue related to storage service a:webserver issue related to the webserver service a:services-library issues on packages/service-libs t:maintenance Some planned maintenance work labels Feb 8, 2024
@pcrespov pcrespov added this to the Schoggilebe milestone Feb 8, 2024
@pcrespov pcrespov marked this pull request as draft February 8, 2024 21:01
@pcrespov pcrespov changed the title ♻️ Fixes deprecation warning of aiohttp client session WIP: ♻️ Fixes deprecation warning of aiohttp client session Feb 8, 2024
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c80cedd) 87.3% compared to head (4a0ba94) 87.3%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #5321     +/-   ##
========================================
- Coverage    87.3%   87.3%   -0.1%     
========================================
  Files        1320    1320             
  Lines       54073   54063     -10     
  Branches     1174    1172      -2     
========================================
- Hits        47212   47202     -10     
- Misses       6610    6611      +1     
+ Partials      251     250      -1     
Flag Coverage Δ
integrationtests 64.9% <44.4%> (-0.2%) ⬇️
unittests 85.1% <100.0%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...e-library/src/servicelib/aiohttp/client_session.py 100.0% <100.0%> (+7.1%) ⬆️
...rage/src/simcore_service_storage/simcore_s3_dsm.py 94.7% <100.0%> (ø)
.../src/simcore_service_webserver/scicrunch/plugin.py 100.0% <100.0%> (ø)
...core_service_webserver/scicrunch/service_client.py 65.2% <100.0%> (+0.5%) ⬆️

... and 3 files with indirect coverage changes

@pcrespov pcrespov force-pushed the is4628/deprecation-client-session branch from 8c36de4 to 4a0ba94 Compare February 11, 2024 12:54
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@pcrespov pcrespov changed the title WIP: ♻️ Fixes deprecation warning of aiohttp client session ♻️ Fixes deprecation warning of aiohttp client session Feb 11, 2024
@pcrespov pcrespov marked this pull request as ready for review February 11, 2024 13:06
Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

Thanks!

@pcrespov pcrespov enabled auto-merge (squash) February 12, 2024 06:35
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

thanks

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

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

Thanks a lot.

@pcrespov pcrespov merged commit 195c0d0 into ITISFoundation:master Feb 12, 2024
55 checks passed
@pcrespov pcrespov deleted the is4628/deprecation-client-session branch February 12, 2024 08:35
jsaq007 pushed a commit to jsaq007/osparc-simcore that referenced this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:services-library issues on packages/service-libs a:storage issue related to storage service a:webserver issue related to the webserver service t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DeprecationWarning: ClientSession The object should be created within an async function
4 participants