File tree Expand file tree Collapse file tree 4 files changed +16
-23
lines changed
Expand file tree Collapse file tree 4 files changed +16
-23
lines changed Original file line number Diff line number Diff line change 1111logger = logging .getLogger (__name__ )
1212
1313
14+ def register_platform (service_type : ProcessTypeEnum ):
15+ def decorator (cls : Type [BaseProcessingPlatform ]):
16+ logger .debug (
17+ f"Registering processing platform with class { cls } for service type: { service_type } "
18+ )
19+ PROCESSING_PLATFORMS [service_type ] = cls
20+ return cls
21+
22+ return decorator
23+
24+
1425def load_processing_platforms ():
1526 """Dynamically load all processing platform implementations."""
1627 for _ , module_name , _ in pkgutil .iter_modules (
@@ -19,20 +30,6 @@ def load_processing_platforms():
1930 importlib .import_module (f"app.platforms.implementations.{ module_name } " )
2031
2132
22- def register_processing_platform (
23- service_type : ProcessTypeEnum , cls : Type [BaseProcessingPlatform ]
24- ):
25- """ "Register a new processing platform class for a specific service type.
26-
27- :param service_type: The type of service for which to register the platform.
28- :param cls: The class that implements BaseProcessingPlatform.
29- """
30- logger .debug (
31- f"Registering processing platform with class { cls } for service type: { service_type } "
32- )
33- PROCESSING_PLATFORMS [service_type ] = cls
34-
35-
3633def get_processing_platform (service_type : ProcessTypeEnum ) -> BaseProcessingPlatform :
3734 """
3835 Factory function to get the appropriate processing platform based on the service type.
Original file line number Diff line number Diff line change 11import logging
22
33from app .platforms .base import BaseProcessingPlatform
4- from app .platforms .dispatcher import register_processing_platform
4+ from app .platforms .dispatcher import register_platform
55from app .schemas .enum import ProcessTypeEnum , ProcessingStatusEnum
66from app .schemas .unit_job import ServiceDetails
77
88logger = logging .getLogger (__name__ )
99
1010
11+ @register_platform (ProcessTypeEnum .OGC_API_PROCESS )
1112class OGCAPIProcessPlatform (BaseProcessingPlatform ):
1213 """
1314 OGC API Process processing platform implementation.
@@ -23,6 +24,3 @@ def get_job_status(
2324 raise NotImplementedError (
2425 "OGC API Process job status retrieval not implemented yet."
2526 )
26-
27-
28- register_processing_platform (ProcessTypeEnum .OGC_API_PROCESS , OGCAPIProcessPlatform )
Original file line number Diff line number Diff line change 88from dotenv import load_dotenv
99
1010from app .platforms .base import BaseProcessingPlatform
11- from app .platforms .dispatcher import register_processing_platform
11+ from app .platforms .dispatcher import register_platform
1212from app .schemas .enum import ProcessTypeEnum , ProcessingStatusEnum
1313from app .schemas .unit_job import ServiceDetails
1414
2222}
2323
2424
25+ @register_platform (ProcessTypeEnum .OPENEO )
2526class OpenEOPlatform (BaseProcessingPlatform ):
2627 """
2728 OpenEO processing platform implementation.
@@ -160,6 +161,3 @@ def get_job_status(
160161 raise SystemError (
161162 f"Failed to fetch status openEO job with ID { job_id } "
162163 ) from e
163-
164-
165- register_processing_platform (ProcessTypeEnum .OPENEO , OpenEOPlatform )
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def clear_registry():
2727
2828
2929def test_register_processing_platform ():
30- dispatcher .register_processing_platform (ProcessTypeEnum .OPENEO , DummyPlatform )
30+ dispatcher .register_platform (ProcessTypeEnum .OPENEO )( DummyPlatform )
3131 assert dispatcher .PROCESSING_PLATFORMS [ProcessTypeEnum .OPENEO ] is DummyPlatform
3232
3333
You can’t perform that action at this time.
0 commit comments