esd-services-api-client 2.0.3__py3-none-any.whl → 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esd_services_api_client/_version.py +1 -1
- esd_services_api_client/nexus/README.md +13 -0
- esd_services_api_client/nexus/configurations/__init__.py +0 -0
- esd_services_api_client/nexus/configurations/algorithm_configuration.py +37 -0
- esd_services_api_client/nexus/core/app_core.py +16 -0
- esd_services_api_client/nexus/core/app_dependencies.py +17 -0
- {esd_services_api_client-2.0.3.dist-info → esd_services_api_client-2.0.4.dist-info}/METADATA +1 -1
- {esd_services_api_client-2.0.3.dist-info → esd_services_api_client-2.0.4.dist-info}/RECORD +10 -8
- {esd_services_api_client-2.0.3.dist-info → esd_services_api_client-2.0.4.dist-info}/LICENSE +0 -0
- {esd_services_api_client-2.0.3.dist-info → esd_services_api_client-2.0.4.dist-info}/WHEEL +0 -0
@@ -1 +1 @@
|
|
1
|
-
__version__ = '2.0.
|
1
|
+
__version__ = '2.0.4'
|
@@ -17,6 +17,7 @@ import asyncio
|
|
17
17
|
import json
|
18
18
|
import socketserver
|
19
19
|
import threading
|
20
|
+
import os
|
20
21
|
from dataclasses import dataclass
|
21
22
|
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
|
22
23
|
from typing import Dict, Optional
|
@@ -34,6 +35,7 @@ from esd_services_api_client.nexus.abstractions.socket_provider import (
|
|
34
35
|
from esd_services_api_client.nexus.core.app_core import Nexus
|
35
36
|
from esd_services_api_client.nexus.algorithms import MinimalisticAlgorithm
|
36
37
|
from esd_services_api_client.nexus.input import InputReader, InputProcessor
|
38
|
+
from esd_services_api_client.nexus.configurations.algorithm_configuration import NexusConfiguration
|
37
39
|
from pandas import DataFrame as PandasDataFrame
|
38
40
|
|
39
41
|
from esd_services_api_client.nexus.input.payload_reader import AlgorithmPayload
|
@@ -47,6 +49,16 @@ async def my_on_complete_func_2(**kwargs):
|
|
47
49
|
pass
|
48
50
|
|
49
51
|
|
52
|
+
@dataclass
|
53
|
+
class MyAlgorithmConfiguration(NexusConfiguration):
|
54
|
+
@classmethod
|
55
|
+
def from_environment(cls) -> "NexusConfiguration":
|
56
|
+
return MyAlgorithmConfiguration.from_json(os.getenv("NEXUS__MY_CONFIGURATION"))
|
57
|
+
|
58
|
+
c1: str
|
59
|
+
c2: str
|
60
|
+
|
61
|
+
|
50
62
|
@dataclass
|
51
63
|
class MyAlgorithmPayload(AlgorithmPayload, DataClassJsonMixin):
|
52
64
|
x: Optional[list[int]] = None
|
@@ -250,6 +262,7 @@ async def main():
|
|
250
262
|
.add_reader(YReader)
|
251
263
|
.use_processor(MyInputProcessor)
|
252
264
|
.use_algorithm(MyAlgorithm)
|
265
|
+
.inject_configuration(MyAlgorithmConfiguration)
|
253
266
|
.inject_payload(MyAlgorithmPayload, MyAlgorithmPayload2)
|
254
267
|
)
|
255
268
|
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"""
|
2
|
+
Configuration class primitive for injections.
|
3
|
+
"""
|
4
|
+
from abc import abstractmethod, ABC
|
5
|
+
from dataclasses import dataclass
|
6
|
+
|
7
|
+
from dataclasses_json import DataClassJsonMixin
|
8
|
+
|
9
|
+
|
10
|
+
# Copyright (c) 2023. ECCO Sneaks & Data
|
11
|
+
#
|
12
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
13
|
+
# you may not use this file except in compliance with the License.
|
14
|
+
# You may obtain a copy of the License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
20
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
21
|
+
# See the License for the specific language governing permissions and
|
22
|
+
# limitations under the License.
|
23
|
+
#
|
24
|
+
|
25
|
+
|
26
|
+
@dataclass
|
27
|
+
class NexusConfiguration(DataClassJsonMixin, ABC):
|
28
|
+
"""
|
29
|
+
Base class for algorithm configurations
|
30
|
+
"""
|
31
|
+
|
32
|
+
@classmethod
|
33
|
+
@abstractmethod
|
34
|
+
def from_environment(cls) -> "NexusConfiguration":
|
35
|
+
"""
|
36
|
+
Instantiates this configuration from the environment variable.
|
37
|
+
"""
|
@@ -46,6 +46,9 @@ from esd_services_api_client.crystal import (
|
|
46
46
|
from esd_services_api_client.nexus.algorithms._baseline_algorithm import (
|
47
47
|
BaselineAlgorithm,
|
48
48
|
)
|
49
|
+
from esd_services_api_client.nexus.configurations.algorithm_configuration import (
|
50
|
+
NexusConfiguration,
|
51
|
+
)
|
49
52
|
from esd_services_api_client.nexus.core.app_dependencies import (
|
50
53
|
ServiceConfigurator,
|
51
54
|
)
|
@@ -163,6 +166,19 @@ class Nexus:
|
|
163
166
|
self._configurator = self._configurator.with_payload((await get_payload()))
|
164
167
|
return self
|
165
168
|
|
169
|
+
def inject_configuration(
|
170
|
+
self, *configuration_types: Type[NexusConfiguration]
|
171
|
+
) -> "Nexus":
|
172
|
+
"""
|
173
|
+
Adds custom configuration class instances to the DI container.
|
174
|
+
"""
|
175
|
+
for config_type in configuration_types:
|
176
|
+
self._configurator = self._configurator.with_configuration(
|
177
|
+
config_type.from_environment()
|
178
|
+
)
|
179
|
+
|
180
|
+
return self
|
181
|
+
|
166
182
|
async def _submit_result(
|
167
183
|
self,
|
168
184
|
result: Optional[PandasDataFrame] = None,
|
@@ -32,6 +32,9 @@ from esd_services_api_client.nexus.abstractions.logger_factory import LoggerFact
|
|
32
32
|
from esd_services_api_client.nexus.abstractions.socket_provider import (
|
33
33
|
ExternalSocketProvider,
|
34
34
|
)
|
35
|
+
from esd_services_api_client.nexus.configurations.algorithm_configuration import (
|
36
|
+
NexusConfiguration,
|
37
|
+
)
|
35
38
|
from esd_services_api_client.nexus.exceptions.startup_error import (
|
36
39
|
FatalStartupConfigurationError,
|
37
40
|
)
|
@@ -42,6 +45,7 @@ from esd_services_api_client.nexus.input.payload_reader import (
|
|
42
45
|
)
|
43
46
|
|
44
47
|
|
48
|
+
@final
|
45
49
|
class MetricsModule(Module):
|
46
50
|
"""
|
47
51
|
Metrics provider module.
|
@@ -63,6 +67,7 @@ class MetricsModule(Module):
|
|
63
67
|
return metrics_class(**metrics_settings)
|
64
68
|
|
65
69
|
|
70
|
+
@final
|
66
71
|
class LoggerFactoryModule(Module):
|
67
72
|
"""
|
68
73
|
Logger factory module.
|
@@ -77,6 +82,7 @@ class LoggerFactoryModule(Module):
|
|
77
82
|
return LoggerFactory()
|
78
83
|
|
79
84
|
|
85
|
+
@final
|
80
86
|
class CrystalReceiverClientModule(Module):
|
81
87
|
"""
|
82
88
|
Crystal receiver module.
|
@@ -93,6 +99,7 @@ class CrystalReceiverClientModule(Module):
|
|
93
99
|
)
|
94
100
|
|
95
101
|
|
102
|
+
@final
|
96
103
|
class QueryEnabledStoreModule(Module):
|
97
104
|
"""
|
98
105
|
QES module.
|
@@ -107,6 +114,7 @@ class QueryEnabledStoreModule(Module):
|
|
107
114
|
return QueryEnabledStore.from_string(os.getenv("NEXUS__QES_CONNECTION_STRING"))
|
108
115
|
|
109
116
|
|
117
|
+
@final
|
110
118
|
class StorageClientModule(Module):
|
111
119
|
"""
|
112
120
|
Storage client module.
|
@@ -203,3 +211,12 @@ class ServiceConfigurator:
|
|
203
211
|
lambda binder: binder.bind(payload.__class__, to=payload, scope=singleton)
|
204
212
|
)
|
205
213
|
return self
|
214
|
+
|
215
|
+
def with_configuration(self, config: NexusConfiguration) -> "ServiceConfigurator":
|
216
|
+
"""
|
217
|
+
Adds the specified payload instance to the DI container.
|
218
|
+
"""
|
219
|
+
self._injection_binds.append(
|
220
|
+
lambda binder: binder.bind(config.__class__, to=config, scope=singleton)
|
221
|
+
)
|
222
|
+
return self
|
@@ -1,5 +1,5 @@
|
|
1
1
|
esd_services_api_client/__init__.py,sha256=rP0njtEgVSMm-sOVayVfcRUrrubl4lme7HI2zS678Lo,598
|
2
|
-
esd_services_api_client/_version.py,sha256=
|
2
|
+
esd_services_api_client/_version.py,sha256=YuAuFLBrpl-SUl_UsvW1U1NTjqnldfuD1xUmSLmtaRw,22
|
3
3
|
esd_services_api_client/beast/__init__.py,sha256=NTaz_7YoLPK8MCLwbwqH7rW1zDWLxXu2T7fGmMmRxyg,718
|
4
4
|
esd_services_api_client/beast/v3/__init__.py,sha256=TRjB4-T6eIORpMvdylb32_GinrIpYNFmAdshSC1HqHg,749
|
5
5
|
esd_services_api_client/beast/v3/_connector.py,sha256=oPizDQ1KOKOfiyh-jAofKodlpRzrRiELv-rmP_o_oio,11473
|
@@ -15,7 +15,7 @@ esd_services_api_client/crystal/__init__.py,sha256=afSGQRkDic0ECsJfgu3b291kX8CyU
|
|
15
15
|
esd_services_api_client/crystal/_api_versions.py,sha256=2BMiQRS0D8IEpWCCys3dge5alVBRCZrOuCR1QAn8UIM,832
|
16
16
|
esd_services_api_client/crystal/_connector.py,sha256=WjfMezWXia41Z8aiNupaT577fk9Sx6uy6V23O6y9hfI,12870
|
17
17
|
esd_services_api_client/crystal/_models.py,sha256=eRhGAl8LjglCyIFwf1bcFBhjbpSuRYucuF2LO388L2E,4025
|
18
|
-
esd_services_api_client/nexus/README.md,sha256=
|
18
|
+
esd_services_api_client/nexus/README.md,sha256=73TcvRlAoMUrxE4rnARZmlwS7AwlW9fDV0Tj-MPwC00,8141
|
19
19
|
esd_services_api_client/nexus/__init__.py,sha256=e7RPs-qJNQqDHj121TeYx-_YadZSOIyJuAPyhSSXRsE,622
|
20
20
|
esd_services_api_client/nexus/abstractions/__init__.py,sha256=e7RPs-qJNQqDHj121TeYx-_YadZSOIyJuAPyhSSXRsE,622
|
21
21
|
esd_services_api_client/nexus/abstractions/logger_factory.py,sha256=JHl_t0d0ra_k-EixZlkw-s746wHUdBhSU6preqoARtk,2031
|
@@ -26,9 +26,11 @@ esd_services_api_client/nexus/algorithms/_baseline_algorithm.py,sha256=4Gqp8qV5n
|
|
26
26
|
esd_services_api_client/nexus/algorithms/distributed.py,sha256=iWjx9D6g-ASwTWPkQ9GmInTLymVlxl7UkfEBcEfnkmc,1628
|
27
27
|
esd_services_api_client/nexus/algorithms/minimalistic.py,sha256=9KvIXXsiOZ9wAOvrIZuOlNYcJLB-SjlQoNpICJu-qeQ,1366
|
28
28
|
esd_services_api_client/nexus/algorithms/recursive.py,sha256=2YuAeYZ6-K5hcY8NEAAJVyGhtVVQMTZ7wjkWPPo8qeE,1829
|
29
|
+
esd_services_api_client/nexus/configurations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
|
+
esd_services_api_client/nexus/configurations/algorithm_configuration.py,sha256=sg3ul-Vqd39li42cfMsdWtFJIBNfQ52XLmqKO2sryDg,1086
|
29
31
|
esd_services_api_client/nexus/core/__init__.py,sha256=e7RPs-qJNQqDHj121TeYx-_YadZSOIyJuAPyhSSXRsE,622
|
30
|
-
esd_services_api_client/nexus/core/app_core.py,sha256=
|
31
|
-
esd_services_api_client/nexus/core/app_dependencies.py,sha256=
|
32
|
+
esd_services_api_client/nexus/core/app_core.py,sha256=7cT6ZEzKzq3lfio6YNxREpTTeXt1wjhHUOXxaezuFiQ,9393
|
33
|
+
esd_services_api_client/nexus/core/app_dependencies.py,sha256=rIk6R-InJeF1P0DC4bhj4kJTNNxYg39Vhuz8AXfV6pk,6140
|
32
34
|
esd_services_api_client/nexus/exceptions/__init__.py,sha256=JgPXhrvBIi0U1QOF90TYHS8jv_SBQEoRLsEg6rrtRoc,691
|
33
35
|
esd_services_api_client/nexus/exceptions/_nexus_error.py,sha256=b3L8JnNvV2jdxNfuFWh9-j4kVb_VX7gNH5WHKcC-R78,890
|
34
36
|
esd_services_api_client/nexus/exceptions/input_reader_error.py,sha256=D-xYTKRNREQ2-NGhc88GHOmXCvLNsIVQsH8wf0LLC_0,1760
|
@@ -37,7 +39,7 @@ esd_services_api_client/nexus/input/__init__.py,sha256=0k_HMIP4NPC5O2ixKJPgKsLzY
|
|
37
39
|
esd_services_api_client/nexus/input/input_processor.py,sha256=MiXXd_APrG85Pi-Ke68_UHNEV7T_QHN1hU1WAPWoTsw,3187
|
38
40
|
esd_services_api_client/nexus/input/input_reader.py,sha256=uxTAGX5xNhjTFpEsVQnr8BkVgpIH_U_om54hh3pvJ3s,3269
|
39
41
|
esd_services_api_client/nexus/input/payload_reader.py,sha256=__r_QjIFRAWwx56X5WUK1qensJUae0vZEb422dzOgSY,2511
|
40
|
-
esd_services_api_client-2.0.
|
41
|
-
esd_services_api_client-2.0.
|
42
|
-
esd_services_api_client-2.0.
|
43
|
-
esd_services_api_client-2.0.
|
42
|
+
esd_services_api_client-2.0.4.dist-info/LICENSE,sha256=0gS6zXsPp8qZhzi1xaGCIYPzb_0e8on7HCeFJe8fOpw,10693
|
43
|
+
esd_services_api_client-2.0.4.dist-info/METADATA,sha256=CGlXTMSDUh5Fvzm0E4-r8b9FA9SuQ5gm5xUX7ulxhIg,1236
|
44
|
+
esd_services_api_client-2.0.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
45
|
+
esd_services_api_client-2.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|