indexify 0.3.19__py3-none-any.whl → 0.3.21__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.
Files changed (33) hide show
  1. indexify/cli/cli.py +12 -0
  2. indexify/executor/api_objects.py +11 -6
  3. indexify/executor/blob_store/blob_store.py +69 -0
  4. indexify/executor/blob_store/local_fs_blob_store.py +48 -0
  5. indexify/executor/blob_store/metrics/blob_store.py +33 -0
  6. indexify/executor/blob_store/s3_blob_store.py +88 -0
  7. indexify/executor/downloader.py +192 -27
  8. indexify/executor/executor.py +29 -13
  9. indexify/executor/function_executor/function_executor.py +1 -1
  10. indexify/executor/function_executor/function_executor_states_container.py +5 -0
  11. indexify/executor/function_executor/function_executor_status.py +2 -0
  12. indexify/executor/function_executor/health_checker.py +7 -2
  13. indexify/executor/function_executor/invocation_state_client.py +4 -2
  14. indexify/executor/function_executor/single_task_runner.py +2 -0
  15. indexify/executor/function_executor/task_output.py +8 -1
  16. indexify/executor/grpc/channel_manager.py +4 -3
  17. indexify/executor/grpc/function_executor_controller.py +163 -193
  18. indexify/executor/grpc/metrics/state_reconciler.py +17 -0
  19. indexify/executor/grpc/metrics/task_controller.py +8 -0
  20. indexify/executor/grpc/state_reconciler.py +305 -188
  21. indexify/executor/grpc/state_reporter.py +18 -10
  22. indexify/executor/grpc/task_controller.py +247 -189
  23. indexify/executor/metrics/task_reporter.py +17 -0
  24. indexify/executor/task_reporter.py +217 -94
  25. indexify/executor/task_runner.py +1 -0
  26. indexify/proto/executor_api.proto +37 -11
  27. indexify/proto/executor_api_pb2.py +49 -47
  28. indexify/proto/executor_api_pb2.pyi +55 -15
  29. {indexify-0.3.19.dist-info → indexify-0.3.21.dist-info}/METADATA +2 -1
  30. {indexify-0.3.19.dist-info → indexify-0.3.21.dist-info}/RECORD +32 -27
  31. indexify/executor/grpc/completed_tasks_container.py +0 -26
  32. {indexify-0.3.19.dist-info → indexify-0.3.21.dist-info}/WHEEL +0 -0
  33. {indexify-0.3.19.dist-info → indexify-0.3.21.dist-info}/entry_points.txt +0 -0
@@ -3,8 +3,6 @@ import hashlib
3
3
  from socket import gethostname
4
4
  from typing import Any, Dict, List, Optional
5
5
 
6
- import grpc
7
-
8
6
  from indexify.proto.executor_api_pb2 import (
9
7
  AllowedFunction,
10
8
  )
@@ -62,6 +60,7 @@ class ExecutorStateReporter:
62
60
  function_executor_states: FunctionExecutorStatesContainer,
63
61
  channel_manager: ChannelManager,
64
62
  logger: Any,
63
+ reporting_interval_sec: int = _REPORTING_INTERVAL_SEC,
65
64
  ):
66
65
  self._executor_id: str = executor_id
67
66
  self._flavor: ExecutorFlavor = flavor
@@ -74,21 +73,28 @@ class ExecutorStateReporter:
74
73
  )
75
74
  self._channel_manager = channel_manager
76
75
  self._logger: Any = logger.bind(module=__name__)
76
+ self._reporting_interval_sec: int = reporting_interval_sec
77
+
77
78
  self._is_shutdown: bool = False
78
79
  self._executor_status: ExecutorStatus = ExecutorStatus.EXECUTOR_STATUS_UNKNOWN
79
80
  self._allowed_functions: List[AllowedFunction] = _to_grpc_allowed_functions(
80
81
  function_allowlist
81
82
  )
82
83
  self._labels.update(_label_values_to_strings(RuntimeProbes().probe().labels))
84
+ self._last_server_clock: Optional[int] = None
83
85
 
84
86
  def update_executor_status(self, value: ExecutorStatus):
85
87
  self._executor_status = value
86
88
 
89
+ def update_last_server_clock(self, value: int):
90
+ self._last_server_clock = value
91
+
87
92
  async def run(self):
88
93
  """Runs the state reporter.
89
94
 
90
95
  Never raises any exceptions.
91
96
  """
97
+ # TODO: Move this into a new async task and cancel it in shutdown().
92
98
  while not self._is_shutdown:
93
99
  stub = ExecutorAPIStub(await self._channel_manager.get_channel())
94
100
  while not self._is_shutdown:
@@ -98,7 +104,7 @@ class ExecutorStateReporter:
98
104
  # for all RPCs that we do from Executor to Server. So all the RPCs benefit
99
105
  # from this channel health monitoring.
100
106
  await self.report_state(stub)
101
- await asyncio.sleep(_REPORTING_INTERVAL_SEC)
107
+ await asyncio.sleep(self._reporting_interval_sec)
102
108
  except Exception as e:
103
109
  self._logger.error(
104
110
  f"Failed to report state to the server, reconnecting in {_REPORT_BACKOFF_ON_ERROR_SEC} sec.",
@@ -132,12 +138,21 @@ class ExecutorStateReporter:
132
138
  labels=self._labels,
133
139
  )
134
140
  state.state_hash = _state_hash(state)
141
+ if self._last_server_clock is not None:
142
+ state.server_clock = self._last_server_clock
135
143
 
136
144
  await stub.report_executor_state(
137
145
  ReportExecutorStateRequest(executor_state=state),
138
146
  timeout=_REPORT_RPC_TIMEOUT_SEC,
139
147
  )
140
148
 
149
+ async def shutdown(self):
150
+ """Shuts down the state reporter.
151
+
152
+ Never raises any exceptions.
153
+ """
154
+ self._is_shutdown = True
155
+
141
156
  async def _fetch_free_host_resources(self) -> HostResources:
142
157
  # TODO: Implement host resource metrics reporting.
143
158
  return HostResources(
@@ -177,13 +192,6 @@ class ExecutorStateReporter:
177
192
 
178
193
  return states
179
194
 
180
- async def shutdown(self):
181
- """Shuts down the state reporter.
182
-
183
- Never raises any exceptions.
184
- """
185
- self._is_shutdown = True
186
-
187
195
 
188
196
  def _to_grpc_allowed_functions(function_allowlist: Optional[List[FunctionURI]]):
189
197
  if function_allowlist is None: