File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 "cells" : [
33 {
44 "cell_type" : " code" ,
5- "execution_count" : null ,
5+ "execution_count" : 1 ,
66 "metadata" : {},
77 "outputs" : [],
88 "source" : [
1212 },
1313 {
1414 "cell_type" : " code" ,
15- "execution_count" : null ,
15+ "execution_count" : 2 ,
1616 "metadata" : {},
1717 "outputs" : [],
1818 "source" : [
19- " service_provider = await services.build_service_provider().__aenter__()"
20- ]
21- },
22- {
23- "cell_type" : " code" ,
24- "execution_count" : null ,
25- "metadata" : {},
26- "outputs" : [],
27- "source" : [
28- " email_service = await service_provider.get_required_service(EmailService)\n " ,
19+ " email_service = await services.get(EmailService)\n " ,
2920 " await email_service.send_email()"
3021 ]
3122 }
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ version = "0.1.0"
44requires-python = " >=3.14"
55dependencies = [
66 " aiohttp>=3.13.3" ,
7- " aspy-dependency-injection>=0.5.0" ,
87 " asyncpg>=0.31.0" ,
9- " azure-monitor-opentelemetry>=1.8.4 " ,
8+ " azure-monitor-opentelemetry>=1.8.5 " ,
109 " fastapi[standard-no-fastapi-cloud-cli]>=0.128.0" ,
1110 " greenlet>=3.3.1" ,
1211 " pydantic>=2.12.5" ,
1312 " pydantic-settings[azure-key-vault]>=2.12.0" ,
1413 " sqlmodel>=0.0.31" ,
14+ " wirio>=0.7.0" ,
1515]
1616
1717[dependency-groups ]
@@ -22,7 +22,7 @@ dev = [
2222 " pytest-cov>=7.0.0" ,
2323 " pytest-mock>=3.15.1" ,
2424 " ruff>=0.14.14" ,
25- " ty>=0.0.13 " ,
25+ " ty>=0.0.14 " ,
2626]
2727
2828[build-system ]
Original file line number Diff line number Diff line change 55
66
77async def main () -> None :
8- async with services . build_service_provider () as service_provider :
9- email_service = await service_provider . get_required_service (EmailService )
8+ async with services :
9+ email_service = await services . get (EmailService )
1010 await email_service .send_email ()
1111
1212
Original file line number Diff line number Diff line change 1- from aspy_dependency_injection .service_collection import ServiceCollection
21from fastapi import FastAPI
2+ from wirio .service_container import ServiceContainer
33
44from python_template .api .application_settings import ApplicationSettings
55from python_template .api .service_collection_extensions import (
2424app = FastAPI (openapi_url = openapi_url )
2525app .include_router (product_router )
2626
27- services = ServiceCollection ()
27+ services = ServiceContainer ()
2828application_settings = ApplicationSettings () # ty:ignore[missing-argument]
2929services .add_singleton (ApplicationSettings , application_settings )
3030add_observability (services , application_settings )
Original file line number Diff line number Diff line change 11import logging
22from logging import Logger
33
4- from aspy_dependency_injection .service_collection import ServiceCollection
54from azure .identity import DefaultAzureCredential
65from azure .monitor .opentelemetry import configure_azure_monitor
76from sqlalchemy .ext .asyncio import (
109 async_sessionmaker ,
1110 create_async_engine ,
1211)
12+ from wirio .service_container import ServiceContainer
1313
1414from python_template .api .application_settings import ApplicationSettings
1515from python_template .common .application_environment import ApplicationEnvironment
1616
1717
1818def add_observability (
19- services : ServiceCollection , application_settings : ApplicationSettings
19+ services : ServiceContainer , application_settings : ApplicationSettings
2020) -> None :
2121 def inject_logging () -> Logger :
2222 return logging .getLogger (__name__ )
@@ -32,7 +32,7 @@ def inject_logging() -> Logger:
3232 )
3333
3434
35- def add_sqlmodel (services : ServiceCollection ) -> None :
35+ def add_sqlmodel (services : ServiceContainer ) -> None :
3636 def inject_async_engine (application_settings : ApplicationSettings ) -> AsyncEngine :
3737 return create_async_engine (application_settings .postgresql_connection_string )
3838
Original file line number Diff line number Diff line change 11from typing import Annotated
22
3- from aspy_dependency_injection .annotations import Inject
43from fastapi import APIRouter
4+ from wirio .annotations import FromServices
55
66from python_template .api .workflows .products .discontinue_product .discontinue_product_request import (
77 DiscontinueProductRequest ,
2828@product_router .post ("" )
2929async def publish_product (
3030 request : PublishProductRequest ,
31- workflow : Annotated [PublishProductWorkflow , Inject ()],
31+ workflow : Annotated [PublishProductWorkflow , FromServices ()],
3232) -> PublishProductResponse :
3333 return await workflow .execute (request )
3434
3535
3636@product_router .post ("/discontinue" )
3737async def discontinue_product (
3838 request : DiscontinueProductRequest ,
39- workflow : Annotated [DiscontinueProductWorkflow , Inject ()],
39+ workflow : Annotated [DiscontinueProductWorkflow , FromServices ()],
4040) -> None :
4141 await workflow .execute (request )
Original file line number Diff line number Diff line change 11from collections .abc import AsyncGenerator
22
33import pytest
4- from aspy_dependency_injection . service_provider import ServiceProvider
4+ from wirio . service_container import ServiceContainer
55
66from python_template .api .main import services
77
88
99@pytest .fixture
10- async def service_provider () -> AsyncGenerator [ServiceProvider ]:
11- async with services . build_service_provider () as service_provider :
12- yield service_provider
10+ async def services_fixture () -> AsyncGenerator [ServiceContainer ]:
11+ async with services :
12+ yield services
Original file line number Diff line number Diff line change 11import pytest
2- from aspy_dependency_injection .service_provider import ServiceProvider
32from sqlalchemy .ext .asyncio import AsyncSession
3+ from wirio .service_container import ServiceContainer
44
55from python_template .api .workflows .products .discontinue_product .discontinue_product_request import (
66 DiscontinueProductRequest ,
1414
1515class TestDiscontinueProductWorkflow :
1616 @pytest .fixture (autouse = True )
17- async def setup (self , service_provider : ServiceProvider ) -> None :
18- self .workflow = await service_provider .get_required_service (
19- DiscontinueProductWorkflow
20- )
21- self .sql_session = await service_provider .get_required_service (AsyncSession )
17+ async def setup (self , services_fixture : ServiceContainer ) -> None :
18+ self .workflow = await services_fixture .get (DiscontinueProductWorkflow )
19+ self .sql_session = await services_fixture .get (AsyncSession )
2220
2321 async def test_discontinue_product (self ) -> None :
2422 product = ProductBuilder ().build ()
Original file line number Diff line number Diff line change 11import pytest
2- from aspy_dependency_injection . service_provider import ServiceProvider
2+ from wirio . service_container import ServiceContainer
33
44from python_template .api .workflows .products .publish_product .publish_product_workflow import (
55 PublishProductWorkflow ,
1111
1212class TestPublishProductWorkflow :
1313 @pytest .fixture (autouse = True )
14- async def setup (self , service_provider : ServiceProvider ) -> None :
15- self .workflow = await service_provider .get_required_service (
16- PublishProductWorkflow
17- )
14+ async def setup (self , services_fixture : ServiceContainer ) -> None :
15+ self .workflow = await services_fixture .get (PublishProductWorkflow )
1816
1917 async def test_publish_product (self ) -> None :
2018 request = PublishProductRequestBuilder ().build ()
You can’t perform that action at this time.
0 commit comments