orca-python 0.7.0__py3-none-any.whl → 0.7.2__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.
- orca_python/exceptions.py +4 -0
- orca_python/main.py +43 -13
- {orca_python-0.7.0.dist-info → orca_python-0.7.2.dist-info}/METADATA +1 -1
- {orca_python-0.7.0.dist-info → orca_python-0.7.2.dist-info}/RECORD +6 -6
- {orca_python-0.7.0.dist-info → orca_python-0.7.2.dist-info}/LICENSE +0 -0
- {orca_python-0.7.0.dist-info → orca_python-0.7.2.dist-info}/WHEEL +0 -0
orca_python/exceptions.py
CHANGED
@@ -10,6 +10,10 @@ class InvalidAlgorithmReturnType(BaseOrcaException):
|
|
10
10
|
"""Raised when the return type of an algorithm is not valid"""
|
11
11
|
|
12
12
|
|
13
|
+
class InvalidWindowArgument(BaseOrcaException):
|
14
|
+
"""Raised when an argument to the Window class is not valid"""
|
15
|
+
|
16
|
+
|
13
17
|
class InvalidDependency(BaseOrcaException):
|
14
18
|
"""Raised when a dependency is invalid"""
|
15
19
|
|
orca_python/main.py
CHANGED
@@ -10,8 +10,11 @@ import re
|
|
10
10
|
import sys
|
11
11
|
import asyncio
|
12
12
|
import logging
|
13
|
+
import datetime as dt
|
13
14
|
import traceback
|
14
15
|
|
16
|
+
from google.protobuf import json_format, timestamp_pb2
|
17
|
+
|
15
18
|
logging.basicConfig(
|
16
19
|
level=logging.INFO,
|
17
20
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
@@ -48,6 +51,7 @@ from service_pb2_grpc import OrcaProcessorServicer
|
|
48
51
|
from orca_python import envs
|
49
52
|
from orca_python.exceptions import (
|
50
53
|
InvalidDependency,
|
54
|
+
InvalidWindowArgument,
|
51
55
|
InvalidAlgorithmArgument,
|
52
56
|
InvalidAlgorithmReturnType,
|
53
57
|
)
|
@@ -133,11 +137,41 @@ class NoneResult:
|
|
133
137
|
returnResult = StructResult | ArrayResult | ValueResult | NoneResult
|
134
138
|
|
135
139
|
|
140
|
+
@dataclass
|
141
|
+
class Window:
|
142
|
+
time_from: dt.datetime
|
143
|
+
time_to: dt.datetime
|
144
|
+
name: str
|
145
|
+
version: str
|
146
|
+
origin: str
|
147
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
148
|
+
|
149
|
+
|
136
150
|
@dataclass
|
137
151
|
class ExecutionParams:
|
138
|
-
window:
|
152
|
+
window: Window
|
139
153
|
dependencies: Optional[Iterable[pb.AlgorithmResult]] = None
|
140
154
|
|
155
|
+
def __init__(
|
156
|
+
self,
|
157
|
+
window: Window | pb.Window,
|
158
|
+
dependencies: Optional[Iterable[pb.AlgorithmResult]] = None,
|
159
|
+
):
|
160
|
+
if isinstance(window, Window):
|
161
|
+
self.window = window
|
162
|
+
elif isinstance(window, pb.Window):
|
163
|
+
self.window = Window(
|
164
|
+
time_from=window.time_from.ToDatetime(),
|
165
|
+
time_to=window.time_to.ToDatetime(),
|
166
|
+
name=window.window_type_name,
|
167
|
+
version=window.window_type_version,
|
168
|
+
origin=window.origin,
|
169
|
+
metadata=json_format.MessageToDict(window.metadata),
|
170
|
+
)
|
171
|
+
else:
|
172
|
+
raise InvalidWindowArgument(f"window of type {type(window)} not handled")
|
173
|
+
self.dependencies = dependencies
|
174
|
+
|
141
175
|
|
142
176
|
class AlgorithmFn(Protocol):
|
143
177
|
def __call__(
|
@@ -148,16 +182,6 @@ class AlgorithmFn(Protocol):
|
|
148
182
|
T = TypeVar("T", bound=AlgorithmFn)
|
149
183
|
|
150
184
|
|
151
|
-
@dataclass
|
152
|
-
class Window:
|
153
|
-
time_from: int
|
154
|
-
time_to: int
|
155
|
-
name: str
|
156
|
-
version: str
|
157
|
-
origin: str
|
158
|
-
metadata: Dict[str, Any] = field(default_factory=dict)
|
159
|
-
|
160
|
-
|
161
185
|
def EmitWindow(window: Window) -> None:
|
162
186
|
"""
|
163
187
|
Emits a window to Orca-core.
|
@@ -167,9 +191,15 @@ def EmitWindow(window: Window) -> None:
|
|
167
191
|
"""
|
168
192
|
LOGGER.info(f"Emitting window: {window}")
|
169
193
|
|
194
|
+
_time_from = timestamp_pb2.Timestamp()
|
195
|
+
_time_from.FromDatetime(window.time_from)
|
196
|
+
|
197
|
+
_time_to = timestamp_pb2.Timestamp()
|
198
|
+
_time_to.FromDatetime(window.time_to)
|
199
|
+
|
170
200
|
window_pb = pb.Window()
|
171
|
-
window_pb.time_to =
|
172
|
-
window_pb.time_from =
|
201
|
+
window_pb.time_to = _time_from
|
202
|
+
window_pb.time_from = _time_to
|
173
203
|
window_pb.window_type_name = window.name
|
174
204
|
window_pb.window_type_version = window.version
|
175
205
|
window_pb.origin = window.origin
|
@@ -8,10 +8,10 @@ vendor/validate_pb2.pyi,sha256=Qyebm_XUdrvo8As3XovHu7vVsHXYJtTdP3bYUmQEecs,30245
|
|
8
8
|
vendor/validate_pb2_grpc.py,sha256=qIlTS0MGHE7myQ7tCMbS-pPqA9FMZl_Hn9Mh_uq2o9o,896
|
9
9
|
orca_python/__init__.py,sha256=tHVOEF69iiLzbymMTuEKdbGSqeaAzpc-BiZY7VY1Gz4,362
|
10
10
|
orca_python/envs.py,sha256=zSuukNSpEw78VpSSIDAA9KRAurWedQMwx1qyQg9f8pk,560
|
11
|
-
orca_python/exceptions.py,sha256=
|
12
|
-
orca_python/main.py,sha256=
|
11
|
+
orca_python/exceptions.py,sha256=el7a5VUd21nNCTSTgVn5T9gyULncrQgKyFQghWmApnw,629
|
12
|
+
orca_python/main.py,sha256=0o4ZzVpwKUsNk5nGdp0aBI3N-Q7_JkK62UErjBhftlc,30453
|
13
13
|
orca_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
orca_python-0.7.
|
15
|
-
orca_python-0.7.
|
16
|
-
orca_python-0.7.
|
17
|
-
orca_python-0.7.
|
14
|
+
orca_python-0.7.2.dist-info/LICENSE,sha256=sxb8X8qhbZ_JaCBFmoIriJzA-jelKmh86sAKQsIRN_I,1062
|
15
|
+
orca_python-0.7.2.dist-info/METADATA,sha256=Eg_nxSuf7bc9F6p5pFFNr-44UldKOgPeZhe8ZWxJZ0M,3019
|
16
|
+
orca_python-0.7.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
17
|
+
orca_python-0.7.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|