orca-python 0.7.1__py3-none-any.whl → 0.7.3__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 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
@@ -13,7 +13,7 @@ import logging
13
13
  import datetime as dt
14
14
  import traceback
15
15
 
16
- from google.protobuf import timestamp_pb2
16
+ from google.protobuf import json_format, timestamp_pb2
17
17
 
18
18
  logging.basicConfig(
19
19
  level=logging.INFO,
@@ -51,6 +51,7 @@ from service_pb2_grpc import OrcaProcessorServicer
51
51
  from orca_python import envs
52
52
  from orca_python.exceptions import (
53
53
  InvalidDependency,
54
+ InvalidWindowArgument,
54
55
  InvalidAlgorithmArgument,
55
56
  InvalidAlgorithmReturnType,
56
57
  )
@@ -136,11 +137,41 @@ class NoneResult:
136
137
  returnResult = StructResult | ArrayResult | ValueResult | NoneResult
137
138
 
138
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
+
139
150
  @dataclass
140
151
  class ExecutionParams:
141
- window: pb.Window
152
+ window: Window
142
153
  dependencies: Optional[Iterable[pb.AlgorithmResult]] = None
143
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
+
144
175
 
145
176
  class AlgorithmFn(Protocol):
146
177
  def __call__(
@@ -151,16 +182,6 @@ class AlgorithmFn(Protocol):
151
182
  T = TypeVar("T", bound=AlgorithmFn)
152
183
 
153
184
 
154
- @dataclass
155
- class Window:
156
- time_from: dt.datetime
157
- time_to: dt.datetime
158
- name: str
159
- version: str
160
- origin: str
161
- metadata: Dict[str, Any] = field(default_factory=dict)
162
-
163
-
164
185
  def EmitWindow(window: Window) -> None:
165
186
  """
166
187
  Emits a window to Orca-core.
@@ -177,8 +198,8 @@ def EmitWindow(window: Window) -> None:
177
198
  _time_to.FromDatetime(window.time_to)
178
199
 
179
200
  window_pb = pb.Window()
180
- window_pb.time_to = _time_from
181
- window_pb.time_from = _time_to
201
+ window_pb.time_to.CopyFrom(_time_to)
202
+ window_pb.time_from.CopyFrom(_time_from)
182
203
  window_pb.window_type_name = window.name
183
204
  window_pb.window_type_version = window.version
184
205
  window_pb.origin = window.origin
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: orca-python
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: Python SDK for the Predixus Orca product
5
5
  Author: Frederick Mannings
6
6
  Author-email: contact@predixus.com
@@ -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=WjkKGQvmS8Z7L63rIROnLFjA-8sGX5R9714xgD1j_7E,512
12
- orca_python/main.py,sha256=zKRWZX_Rh63vcK0QL6TSUz0DuulHkqz0oObpAnDVfTc,29651
11
+ orca_python/exceptions.py,sha256=el7a5VUd21nNCTSTgVn5T9gyULncrQgKyFQghWmApnw,629
12
+ orca_python/main.py,sha256=F6LWHkv2fnH0OOLmcCHbwdnjdZSF2cMFuwUrUwRjQeA,30469
13
13
  orca_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- orca_python-0.7.1.dist-info/LICENSE,sha256=sxb8X8qhbZ_JaCBFmoIriJzA-jelKmh86sAKQsIRN_I,1062
15
- orca_python-0.7.1.dist-info/METADATA,sha256=qEE8Eh7vSr7OtvNFI2ATiAvJ1tUZtd1-l_pvFRApA8o,3019
16
- orca_python-0.7.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
17
- orca_python-0.7.1.dist-info/RECORD,,
14
+ orca_python-0.7.3.dist-info/LICENSE,sha256=sxb8X8qhbZ_JaCBFmoIriJzA-jelKmh86sAKQsIRN_I,1062
15
+ orca_python-0.7.3.dist-info/METADATA,sha256=4E3cKPM6bdILzQ6YsjKdFNfpC7Nlb90dbPIlpdRvcXE,3019
16
+ orca_python-0.7.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
17
+ orca_python-0.7.3.dist-info/RECORD,,