Skip to content

♻️ web-server: Refactor products domain #7263

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

Merged
merged 46 commits into from
Feb 26, 2025

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Feb 21, 2025

What does this PR do?

ReDoc

This PR refactors the simcore_service_webserver.products domain, improving its structure and organization while extending test coverage of that domain to over 90%.

✨ Key Changes:

  • Refactored package structure to follow a layered architecture:image

    • Repository layer: _repository
    • Service layer: _service, products_service (public)
    • Domain models: _models, models (public)
      • Fields upgraded to Annotated
    • HTTP server modules (web):
      • _web_events: Defines web.Application event slots
      • _web_middlewares: Handles web.Application middlewares
      • _web_helpers: Provides helper functions wrapping the service layer for aiohttp.web
      • products_web (public): Exposes some helpers
    • Controller layer:
      • _rest
        • Moved _invitation_rest to the invitations domain
        • Removed unused entrypoint
        • Increased minor version web-api v0.59 -> v0.60
        • _rest_schemas are remaining schemas that were not in models_library.api_schemas_webserver.product
      • _rpc
    • Domain bootstrap/setup: plugin
      • Optimized internal imports to reduce boot time
  • Extended test coverage: Increased coverage to over 90% for the products domain.

🔍 Expected Public Interface Usage:

from ..products import products_web, products_service
from ..products.models import Product

async def some_handler(request: web.Request): 
    product: Product = products_web.get_current_product(request)
    products_web.get_product_template_path(request, template_name)
    # etc.
     
async def other_func(app: web.Application):
    for product in products_service.list_products(app):
        # do something

What's Next?

Further improvements, as outlined in #7275, will follow in subsequent PRs.

Related issue/s

  • towards refactoring projects domain

How to test

Driving test

cd services/web/server
make install-dev
pytest -vv tests --cov=simcore_service_webserver --cov-config=/home/crespo/repos/osparc-simcore/.coveragerc  tests/unit/isolated/**/test_*product*.py
pytest -vv tests --cov=simcore_service_webserver --cov-config=/home/crespo/repos/osparc-simcore/.coveragerc  tests/unit/with_db/**/test_*product*.py

Dev-ops

None

@pcrespov pcrespov self-assigned this Feb 21, 2025
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 93.19728% with 30 lines in your changes missing coverage. Please review.

Project coverage is 87.11%. Comparing base (2472861) to head (40f7dbe).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7263      +/-   ##
==========================================
+ Coverage   87.08%   87.11%   +0.03%     
==========================================
  Files        1685     1689       +4     
  Lines       65492    65523      +31     
  Branches     1119     1119              
==========================================
+ Hits        57031    57081      +50     
+ Misses       8143     8124      -19     
  Partials      318      318              
Flag Coverage Δ
integrationtests 65.38% <66.13%> (-0.01%) ⬇️
unittests 86.13% <93.19%> (+0.03%) ⬆️
Components Coverage Δ
api 76.84% <ø> (ø)
pkg_aws_library 94.24% <ø> (ø)
pkg_dask_task_models_library 97.09% <ø> (ø)
pkg_models_library 91.54% <100.00%> (-0.01%) ⬇️
pkg_notifications_library 84.57% <ø> (ø)
pkg_postgres_database 88.28% <100.00%> (ø)
pkg_service_integration 70.03% <ø> (ø)
pkg_service_library 72.52% <ø> (ø)
pkg_settings_library 90.61% <ø> (ø)
pkg_simcore_sdk 85.46% <ø> (ø)
agent 96.46% <ø> (ø)
api_server 90.56% <ø> (ø)
autoscaling 96.08% <ø> (ø)
catalog 91.73% <ø> (ø)
clusters_keeper 99.24% <ø> (ø)
dask_sidecar 91.25% <ø> (ø)
datcore_adapter 98.06% <ø> (ø)
director 76.68% <ø> (ø)
director_v2 91.30% <ø> (ø)
dynamic_scheduler 97.33% <ø> (ø)
dynamic_sidecar 89.74% <ø> (ø)
efs_guardian 90.25% <ø> (ø)
invitations 93.28% <ø> (ø)
osparc_gateway_server ∅ <ø> (∅)
payments 92.66% <ø> (ø)
resource_usage_tracker 89.11% <ø> (ø)
storage 84.39% <ø> (+0.24%) ⬆️
webclient ∅ <ø> (∅)
webserver 85.21% <93.13%> (+0.09%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2472861...40f7dbe. Read the comment docs.

@pcrespov pcrespov force-pushed the mai/refactor-products branch 2 times, most recently from 694fdaa to 4976951 Compare February 24, 2025 10:19
@pcrespov pcrespov added this to the The Awakening milestone Feb 24, 2025
@pcrespov pcrespov added the t:maintenance Some planned maintenance work label Feb 24, 2025
@pcrespov pcrespov force-pushed the mai/refactor-products branch 3 times, most recently from 07d794e to db2c77c Compare February 25, 2025 15:02
@pcrespov pcrespov force-pushed the mai/refactor-products branch from db2c77c to d98a77b Compare February 25, 2025 17:59
@pcrespov pcrespov force-pushed the mai/refactor-products branch from 2e85962 to f072c21 Compare February 26, 2025 10:22
@pcrespov pcrespov changed the title WIP: ♻️ mai/refactor products ♻️ web-server: Refactor products domain Feb 26, 2025
@pcrespov pcrespov marked this pull request as ready for review February 26, 2025 13:22
Copy link
Collaborator

@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 for the initiative, very nice!

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 for the effort! 🚀

@pcrespov pcrespov enabled auto-merge (squash) February 26, 2025 15:36
@pcrespov pcrespov merged commit 315de3a into ITISFoundation:master Feb 26, 2025
94 of 95 checks passed
@pcrespov pcrespov deleted the mai/refactor-products branch February 28, 2025 09:34
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Mar 6, 2025
63 tasks
mrnicegyu11 pushed a commit to mrnicegyu11/osparc-simcore that referenced this pull request Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants