indexify 0.4.28__tar.gz → 0.4.30__tar.gz

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 (78) hide show
  1. {indexify-0.4.28 → indexify-0.4.30}/PKG-INFO +2 -2
  2. {indexify-0.4.28 → indexify-0.4.30}/pyproject.toml +2 -2
  3. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/executor.py +11 -7
  4. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/__init__.py +2 -2
  5. indexify-0.4.30/src/indexify/executor/function_executor_controller/completed_task_allocation_metrics.py +87 -0
  6. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/events.py +29 -33
  7. indexify-0.4.28/src/indexify/executor/function_executor_controller/finalize_task.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/finalize_task_allocation.py +45 -37
  8. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/function_executor_controller.py +194 -180
  9. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/loggers.py +15 -17
  10. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/message_validators.py +4 -12
  11. indexify-0.4.30/src/indexify/executor/function_executor_controller/metrics/completed_task_allocation_metrics.py +70 -0
  12. indexify-0.4.30/src/indexify/executor/function_executor_controller/metrics/finalize_task_allocation.py +26 -0
  13. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/metrics/function_executor_controller.py +12 -11
  14. indexify-0.4.30/src/indexify/executor/function_executor_controller/metrics/prepare_task_allocation.py +27 -0
  15. indexify-0.4.28/src/indexify/executor/function_executor_controller/prepare_task.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/prepare_task_allocation.py +33 -29
  16. indexify-0.4.28/src/indexify/executor/function_executor_controller/run_task.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/run_task_allocation.py +54 -51
  17. indexify-0.4.28/src/indexify/executor/function_executor_controller/task_info.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/task_allocation_info.py +6 -6
  18. indexify-0.4.28/src/indexify/executor/function_executor_controller/task_input.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/task_allocation_input.py +2 -2
  19. indexify-0.4.28/src/indexify/executor/function_executor_controller/task_output.py → indexify-0.4.30/src/indexify/executor/function_executor_controller/task_allocation_output.py +24 -24
  20. indexify-0.4.30/src/indexify/executor/monitoring/desired_state_handler.py +24 -0
  21. indexify-0.4.30/src/indexify/executor/monitoring/reported_state_handler.py +22 -0
  22. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/server.py +4 -0
  23. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/state_reconciler.py +26 -19
  24. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/state_reporter.py +9 -4
  25. indexify-0.4.28/src/indexify/executor/function_executor_controller/completed_task_metrics.py +0 -83
  26. indexify-0.4.28/src/indexify/executor/function_executor_controller/metrics/completed_task_metrics.py +0 -68
  27. indexify-0.4.28/src/indexify/executor/function_executor_controller/metrics/finalize_task.py +0 -20
  28. indexify-0.4.28/src/indexify/executor/function_executor_controller/metrics/prepare_task.py +0 -18
  29. {indexify-0.4.28 → indexify-0.4.30}/README.md +0 -0
  30. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/cli/__init__.py +0 -0
  31. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/cli/build_image.py +0 -0
  32. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/cli/deploy.py +0 -0
  33. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/cli/executor.py +0 -0
  34. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/README.md +0 -0
  35. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/blob_store/blob_store.py +0 -0
  36. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/blob_store/local_fs_blob_store.py +0 -0
  37. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/blob_store/metrics/blob_store.py +0 -0
  38. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/blob_store/s3_blob_store.py +0 -0
  39. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/channel_manager.py +0 -0
  40. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_allowlist.py +0 -0
  41. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/function_executor.py +0 -0
  42. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/health_checker.py +0 -0
  43. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/invocation_state_client.py +0 -0
  44. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/metrics/function_executor.py +0 -0
  45. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/metrics/health_checker.py +0 -0
  46. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/metrics/invocation_state_client.py +0 -0
  47. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/server/client_configuration.py +0 -0
  48. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/server/function_executor_server.py +0 -0
  49. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/server/function_executor_server_factory.py +0 -0
  50. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/server/subprocess_function_executor_server.py +0 -0
  51. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor/server/subprocess_function_executor_server_factory.py +0 -0
  52. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/aio_utils.py +0 -0
  53. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/create_function_executor.py +0 -0
  54. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/debug_event_loop.py +0 -0
  55. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/downloads.py +0 -0
  56. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/metrics/downloads.py +0 -0
  57. /indexify-0.4.28/src/indexify/executor/function_executor_controller/metrics/run_task.py → /indexify-0.4.30/src/indexify/executor/function_executor_controller/metrics/run_task_allocation.py +0 -0
  58. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/function_executor_controller/terminate_function_executor.py +0 -0
  59. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/host_resources/host_resources.py +0 -0
  60. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/host_resources/nvidia_gpu.py +0 -0
  61. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/host_resources/nvidia_gpu_allocator.py +0 -0
  62. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/logging.py +0 -0
  63. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/metrics/channel_manager.py +0 -0
  64. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/metrics/executor.py +0 -0
  65. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/metrics/state_reconciler.py +0 -0
  66. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/metrics/state_reporter.py +0 -0
  67. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/handler.py +0 -0
  68. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/health_check_handler.py +0 -0
  69. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/health_checker/generic_health_checker.py +0 -0
  70. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/health_checker/health_checker.py +0 -0
  71. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/health_checker/metrics/health_checker.py +0 -0
  72. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/metrics.py +0 -0
  73. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/prometheus_metrics_handler.py +0 -0
  74. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/executor/monitoring/startup_probe_handler.py +0 -0
  75. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/proto/executor_api.proto +0 -0
  76. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/proto/executor_api_pb2.py +0 -0
  77. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/proto/executor_api_pb2.pyi +0 -0
  78. {indexify-0.4.28 → indexify-0.4.30}/src/indexify/proto/executor_api_pb2_grpc.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: indexify
3
- Version: 0.4.28
3
+ Version: 0.4.30
4
4
  Summary: Open Source Indexify components and helper tools
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Dist: aiohttp (>=3.12.15,<4.0.0)
17
- Requires-Dist: boto3 (>=1.40.12,<2.0.0)
17
+ Requires-Dist: boto3 (>=1.40.15,<2.0.0)
18
18
  Requires-Dist: docker (>=7.1.0,<8.0.0)
19
19
  Requires-Dist: httpx[http2] (==0.27.2)
20
20
  Requires-Dist: nanoid (>=2.0.0,<3.0.0)
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "indexify"
3
3
  # Incremented if any of the components provided in this packages are updated.
4
- version = "0.4.28"
4
+ version = "0.4.30"
5
5
  description = "Open Source Indexify components and helper tools"
6
6
  authors = ["Tensorlake Inc. <support@tensorlake.ai>"]
7
7
  license = "Apache 2.0"
@@ -25,7 +25,7 @@ httpx = { version = "0.27.2", extras = ["http2"] }
25
25
  pydantic = "^2.11"
26
26
  prometheus-client = "^0.22.1"
27
27
  psutil = "^7.0.0"
28
- boto3 = "^1.40.12"
28
+ boto3 = "^1.40.15"
29
29
  structlog = "25.4.0"
30
30
  # Adds function-executor binary, utils lib, sdk used in indexify-cli commands.
31
31
  # We need to specify the tensorlake version exactly because pip install doesn't respect poetry.lock files.
@@ -23,9 +23,11 @@ from .metrics.executor import (
23
23
  metric_executor_info,
24
24
  metric_executor_state,
25
25
  )
26
+ from .monitoring.desired_state_handler import DesiredStateHandler
26
27
  from .monitoring.health_check_handler import HealthCheckHandler
27
28
  from .monitoring.health_checker.health_checker import HealthChecker
28
29
  from .monitoring.prometheus_metrics_handler import PrometheusMetricsHandler
30
+ from .monitoring.reported_state_handler import ReportedStateHandler
29
31
  from .monitoring.server import MonitoringServer
30
32
  from .monitoring.startup_probe_handler import StartupProbeHandler
31
33
  from .state_reconciler import ExecutorStateReconciler
@@ -59,13 +61,6 @@ class Executor:
59
61
  protocol = "https"
60
62
 
61
63
  self._startup_probe_handler = StartupProbeHandler()
62
- self._monitoring_server = MonitoringServer(
63
- host=monitoring_server_host,
64
- port=monitoring_server_port,
65
- startup_probe_handler=self._startup_probe_handler,
66
- health_probe_handler=HealthCheckHandler(health_checker),
67
- metrics_handler=PrometheusMetricsHandler(),
68
- )
69
64
  self._channel_manager = ChannelManager(
70
65
  server_address=grpc_server_addr,
71
66
  config_path=config_path,
@@ -96,6 +91,15 @@ class Executor:
96
91
  state_reporter=self._state_reporter,
97
92
  logger=self._logger,
98
93
  )
94
+ self._monitoring_server = MonitoringServer(
95
+ host=monitoring_server_host,
96
+ port=monitoring_server_port,
97
+ startup_probe_handler=self._startup_probe_handler,
98
+ health_probe_handler=HealthCheckHandler(health_checker),
99
+ metrics_handler=PrometheusMetricsHandler(),
100
+ reported_state_handler=ReportedStateHandler(self._state_reporter),
101
+ desired_state_handler=DesiredStateHandler(self._state_reconciler),
102
+ )
99
103
  self._run_aio_task: Optional[asyncio.Task] = None
100
104
  self._shutdown_aio_task: Optional[asyncio.Task] = None
101
105
 
@@ -4,7 +4,7 @@ from .message_validators import (
4
4
  validate_function_executor_description,
5
5
  validate_task_allocation,
6
6
  )
7
- from .task_output import TaskOutput
7
+ from .task_allocation_output import TaskAllocationOutput
8
8
 
9
9
  __all__ = [
10
10
  "function_executor_logger",
@@ -12,5 +12,5 @@ __all__ = [
12
12
  "validate_function_executor_description",
13
13
  "validate_task_allocation",
14
14
  "FunctionExecutorController",
15
- "TaskOutput",
15
+ "TaskAllocationOutput",
16
16
  ]
@@ -0,0 +1,87 @@
1
+ import time
2
+ from typing import Any
3
+
4
+ from indexify.proto.executor_api_pb2 import (
5
+ TaskFailureReason,
6
+ TaskOutcomeCode,
7
+ )
8
+
9
+ from .metrics.completed_task_allocation_metrics import (
10
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_ALL,
11
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_FUNCTION_ERROR,
12
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_FUNCTION_EXECUTOR_TERMINATED,
13
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_INTERNAL_ERROR,
14
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_NONE,
15
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_TASK_CANCELLED,
16
+ METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_UNKNOWN,
17
+ METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_ALL,
18
+ METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
19
+ METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_SUCCESS,
20
+ metric_task_allocation_completion_latency,
21
+ metric_task_allocations_completed,
22
+ )
23
+ from .task_allocation_info import TaskAllocationInfo
24
+
25
+
26
+ def emit_completed_task_allocation_metrics(
27
+ alloc_info: TaskAllocationInfo, logger: Any
28
+ ) -> None:
29
+ """Emits Prometheus metrics for a completed task allocation.
30
+
31
+ Doesn't raise any exceptions.
32
+ """
33
+ logger = logger.bind(module=__name__)
34
+ metric_task_allocation_completion_latency.observe(
35
+ time.monotonic() - alloc_info.start_time
36
+ )
37
+
38
+ task_outcome_code: TaskOutcomeCode = alloc_info.output.outcome_code
39
+ task_failure_reason: TaskFailureReason = alloc_info.output.failure_reason
40
+ metric_task_allocations_completed.labels(
41
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_ALL,
42
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_ALL,
43
+ ).inc()
44
+ if task_outcome_code == TaskOutcomeCode.TASK_OUTCOME_CODE_SUCCESS:
45
+ metric_task_allocations_completed.labels(
46
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_SUCCESS,
47
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_NONE,
48
+ ).inc()
49
+ elif task_outcome_code == TaskOutcomeCode.TASK_OUTCOME_CODE_FAILURE:
50
+ if task_failure_reason == TaskFailureReason.TASK_FAILURE_REASON_INTERNAL_ERROR:
51
+ metric_task_allocations_completed.labels(
52
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
53
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_INTERNAL_ERROR,
54
+ ).inc()
55
+ elif (
56
+ task_failure_reason
57
+ == TaskFailureReason.TASK_FAILURE_REASON_FUNCTION_EXECUTOR_TERMINATED
58
+ ):
59
+ metric_task_allocations_completed.labels(
60
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
61
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_FUNCTION_EXECUTOR_TERMINATED,
62
+ ).inc()
63
+ elif (
64
+ task_failure_reason == TaskFailureReason.TASK_FAILURE_REASON_TASK_CANCELLED
65
+ ):
66
+ metric_task_allocations_completed.labels(
67
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
68
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_TASK_CANCELLED,
69
+ ).inc()
70
+ elif task_failure_reason in [
71
+ TaskFailureReason.TASK_FAILURE_REASON_FUNCTION_ERROR,
72
+ TaskFailureReason.TASK_FAILURE_REASON_FUNCTION_TIMEOUT,
73
+ TaskFailureReason.TASK_FAILURE_REASON_INVOCATION_ERROR,
74
+ ]:
75
+ metric_task_allocations_completed.labels(
76
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
77
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_FUNCTION_ERROR,
78
+ ).inc()
79
+ else:
80
+ metric_task_allocations_completed.labels(
81
+ outcome_code=METRIC_TASK_ALLOCATIONS_COMPLETED_OUTCOME_CODE_FAILURE,
82
+ failure_reason=METRIC_TASK_ALLOCATIONS_COMPLETED_FAILURE_REASON_UNKNOWN,
83
+ ).inc()
84
+ logger.warning(
85
+ "unexpected task allocation failure reason",
86
+ failure_reason=TaskFailureReason.Name(task_failure_reason),
87
+ )
@@ -1,26 +1,22 @@
1
1
  from enum import Enum
2
2
  from typing import List, Optional
3
3
 
4
- from tensorlake.function_executor.proto.function_executor_pb2 import (
5
- FunctionInputs,
6
- )
7
-
8
4
  from indexify.executor.function_executor.function_executor import (
9
5
  FunctionExecutor,
10
6
  )
11
7
  from indexify.proto.executor_api_pb2 import FunctionExecutorTerminationReason
12
8
 
13
- from .task_info import TaskInfo
9
+ from .task_allocation_info import TaskAllocationInfo
14
10
 
15
11
 
16
12
  class EventType(Enum):
17
13
  FUNCTION_EXECUTOR_CREATED = 1
18
14
  FUNCTION_EXECUTOR_TERMINATED = 2
19
15
  SHUTDOWN_INITIATED = 3
20
- TASK_PREPARATION_FINISHED = 4
21
- SCHEDULE_TASK_EXECUTION = 5
22
- TASK_EXECUTION_FINISHED = 6
23
- TASK_OUTPUT_UPLOAD_FINISHED = 7
16
+ TASK_ALLOCATION_PREPARATION_FINISHED = 4
17
+ SCHEDULE_TASK_ALLOCATION_EXECUTION = 5
18
+ TASK_ALLOCATION_EXECUTION_FINISHED = 6
19
+ TASK_ALLOCATION_FINALIZATION_FINISHED = 7
24
20
 
25
21
 
26
22
  class BaseEvent:
@@ -94,50 +90,50 @@ class ShutdownInitiated(BaseEvent):
94
90
  super().__init__(EventType.SHUTDOWN_INITIATED)
95
91
 
96
92
 
97
- class TaskPreparationFinished(BaseEvent):
93
+ class TaskAllocationPreparationFinished(BaseEvent):
98
94
  """
99
- Event indicating that a task has been prepared for execution or failed to do that.
95
+ Event indicating that a task allocation has been prepared for execution or failed to do that.
100
96
  """
101
97
 
102
98
  def __init__(
103
99
  self,
104
- task_info: TaskInfo,
100
+ alloc_info: TaskAllocationInfo,
105
101
  is_success: bool,
106
102
  ):
107
- super().__init__(EventType.TASK_PREPARATION_FINISHED)
108
- self.task_info: TaskInfo = task_info
103
+ super().__init__(EventType.TASK_ALLOCATION_PREPARATION_FINISHED)
104
+ self.alloc_info: TaskAllocationInfo = alloc_info
109
105
  self.is_success: bool = is_success
110
106
 
111
107
  def __str__(self) -> str:
112
108
  return (
113
109
  f"Event(type={self.event_type.name}, "
114
- f"task_id={self.task_info.allocation.task.id}, "
115
- f"allocation_id={self.task_info.allocation.allocation_id}), "
110
+ f"task_id={self.alloc_info.allocation.task.id}, "
111
+ f"allocation_id={self.alloc_info.allocation.allocation_id}), "
116
112
  f"is_success={self.is_success}"
117
113
  )
118
114
 
119
115
 
120
- class ScheduleTaskExecution(BaseEvent):
116
+ class ScheduleTaskAllocationExecution(BaseEvent):
121
117
  """
122
- Event indicating that a task execution has been scheduled.
118
+ Event indicating that a task allocation has been scheduled.
123
119
  """
124
120
 
125
121
  def __init__(self):
126
- super().__init__(EventType.SCHEDULE_TASK_EXECUTION)
122
+ super().__init__(EventType.SCHEDULE_TASK_ALLOCATION_EXECUTION)
127
123
 
128
124
 
129
- class TaskExecutionFinished(BaseEvent):
125
+ class TaskAllocationExecutionFinished(BaseEvent):
130
126
  """
131
- Event indicating that a task execution has been finished on Function Executor.
127
+ Event indicating that a task allocation execution has been finished on Function Executor.
132
128
  """
133
129
 
134
130
  def __init__(
135
131
  self,
136
- task_info: TaskInfo,
132
+ alloc_info: TaskAllocationInfo,
137
133
  function_executor_termination_reason: FunctionExecutorTerminationReason, # type: Optional[FunctionExecutorTerminationReason]
138
134
  ):
139
- super().__init__(EventType.TASK_EXECUTION_FINISHED)
140
- self.task_info: TaskInfo = task_info
135
+ super().__init__(EventType.TASK_ALLOCATION_EXECUTION_FINISHED)
136
+ self.alloc_info: TaskAllocationInfo = alloc_info
141
137
  # Not None if the FE needs to get destroyed after running the task.
142
138
  self.function_executor_termination_reason = function_executor_termination_reason
143
139
 
@@ -151,26 +147,26 @@ class TaskExecutionFinished(BaseEvent):
151
147
  )
152
148
  return (
153
149
  f"Event(type={self.event_type.name}, "
154
- f"task_id={self.task_info.allocation.task.id}, "
155
- f"allocation_id={self.task_info.allocation.allocation_id}), "
150
+ f"task_id={self.alloc_info.allocation.task.id}, "
151
+ f"allocation_id={self.alloc_info.allocation.allocation_id}), "
156
152
  f"function_executor_termination_reason={function_executor_termination_reason_str}"
157
153
  )
158
154
 
159
155
 
160
- class TaskFinalizationFinished(BaseEvent):
156
+ class TaskAllocationFinalizationFinished(BaseEvent):
161
157
  """
162
- Event indicating that a task finalization is finished.
158
+ Event indicating that a task allocation finalization is finished.
163
159
  """
164
160
 
165
- def __init__(self, task_info: TaskInfo, is_success: bool):
166
- super().__init__(EventType.TASK_OUTPUT_UPLOAD_FINISHED)
167
- self.task_info: TaskInfo = task_info
161
+ def __init__(self, alloc_info: TaskAllocationInfo, is_success: bool):
162
+ super().__init__(EventType.TASK_ALLOCATION_FINALIZATION_FINISHED)
163
+ self.alloc_info: TaskAllocationInfo = alloc_info
168
164
  self.is_success: bool = is_success
169
165
 
170
166
  def __str__(self) -> str:
171
167
  return (
172
168
  f"Event(type={self.event_type.name}, "
173
- f"task_id={self.task_info.allocation.task.id}, "
174
- f"allocation_id={self.task_info.allocation.allocation_id}), "
169
+ f"task_id={self.alloc_info.allocation.task.id}, "
170
+ f"allocation_id={self.alloc_info.allocation.allocation_id}), "
175
171
  f"is_success={self.is_success}"
176
172
  )
@@ -8,21 +8,21 @@ from indexify.proto.executor_api_pb2 import (
8
8
  TaskOutcomeCode,
9
9
  )
10
10
 
11
- from .events import TaskFinalizationFinished
12
- from .metrics.finalize_task import (
13
- metric_task_finalization_errors,
14
- metric_task_finalization_latency,
15
- metric_task_finalizations,
16
- metric_tasks_finalizing,
11
+ from .events import TaskAllocationFinalizationFinished
12
+ from .metrics.finalize_task_allocation import (
13
+ metric_task_allocation_finalization_errors,
14
+ metric_task_allocation_finalization_latency,
15
+ metric_task_allocation_finalizations,
16
+ metric_task_allocations_finalizing,
17
17
  )
18
- from .task_info import TaskInfo
19
- from .task_input import TaskInput
20
- from .task_output import TaskOutput
18
+ from .task_allocation_info import TaskAllocationInfo
19
+ from .task_allocation_input import TaskAllocationInput
20
+ from .task_allocation_output import TaskAllocationOutput
21
21
 
22
22
 
23
- async def finalize_task(
24
- task_info: TaskInfo, blob_store: BLOBStore, logger: Any
25
- ) -> TaskFinalizationFinished:
23
+ async def finalize_task_allocation(
24
+ task_alloc: TaskAllocationInfo, blob_store: BLOBStore, logger: Any
25
+ ) -> TaskAllocationFinalizationFinished:
26
26
  """Prepares the task output for getting it reported to Server.
27
27
 
28
28
  The task output is either coming from a failed task or from its finished execution on the Function Executor.
@@ -32,34 +32,40 @@ async def finalize_task(
32
32
  start_time = time.monotonic()
33
33
 
34
34
  with (
35
- metric_tasks_finalizing.track_inprogress(),
36
- metric_task_finalization_latency.time(),
37
- metric_task_finalization_errors.count_exceptions(),
35
+ metric_task_allocations_finalizing.track_inprogress(),
36
+ metric_task_allocation_finalization_latency.time(),
37
+ metric_task_allocation_finalization_errors.count_exceptions(),
38
38
  ):
39
- metric_task_finalizations.inc()
39
+ metric_task_allocation_finalizations.inc()
40
40
  try:
41
- await _finalize_task_output(
42
- task_info=task_info,
41
+ await _finalize_task_alloc_output(
42
+ alloc_info=task_alloc,
43
43
  blob_store=blob_store,
44
44
  logger=logger,
45
45
  )
46
46
  logger.info(
47
- "task finalized",
47
+ "task allocation finalized",
48
48
  duration=time.monotonic() - start_time,
49
49
  )
50
- return TaskFinalizationFinished(task_info=task_info, is_success=True)
50
+ return TaskAllocationFinalizationFinished(
51
+ alloc_info=task_alloc, is_success=True
52
+ )
51
53
  except asyncio.CancelledError:
52
- return TaskFinalizationFinished(task_info=task_info, is_success=False)
54
+ return TaskAllocationFinalizationFinished(
55
+ alloc_info=task_alloc, is_success=False
56
+ )
53
57
  except BaseException as e:
54
58
  logger.error(
55
- "failed to finalize task",
59
+ "failed to finalize task allocation",
56
60
  exc_info=e,
57
61
  duration=time.monotonic() - start_time,
58
62
  )
59
- return TaskFinalizationFinished(task_info=task_info, is_success=False)
63
+ return TaskAllocationFinalizationFinished(
64
+ alloc_info=task_alloc, is_success=False
65
+ )
60
66
 
61
67
 
62
- class _TaskOutputSummary:
68
+ class _TaskAllocationOutputSummary:
63
69
  def __init__(self):
64
70
  self.output_count: int = 0
65
71
  self.output_bytes: int = 0
@@ -68,27 +74,27 @@ class _TaskOutputSummary:
68
74
  self.next_functions_count: int = 0
69
75
 
70
76
 
71
- async def _finalize_task_output(
72
- task_info: TaskInfo, blob_store: BLOBStore, logger: Any
77
+ async def _finalize_task_alloc_output(
78
+ alloc_info: TaskAllocationInfo, blob_store: BLOBStore, logger: Any
73
79
  ) -> None:
74
80
  """Finalizes the task output.
75
81
 
76
82
  Raises exception on error."""
77
- if task_info.input is None:
83
+ if alloc_info.input is None:
78
84
  raise Exception(
79
- "task input is None, this should never happen",
85
+ "task allocation input is None, this should never happen",
80
86
  )
81
- if task_info.output is None:
87
+ if alloc_info.output is None:
82
88
  raise Exception(
83
- "task output is None, this should never happen",
89
+ "task allocation output is None, this should never happen",
84
90
  )
85
91
 
86
- input: TaskInput = task_info.input
87
- output: TaskOutput = task_info.output
92
+ input: TaskAllocationInput = alloc_info.input
93
+ output: TaskAllocationOutput = alloc_info.output
88
94
 
89
- output_summary: _TaskOutputSummary = _task_output_summary(output)
95
+ output_summary: _TaskAllocationOutputSummary = _task_output_summary(output)
90
96
  logger.info(
91
- "task output summary",
97
+ "task allocation output summary",
92
98
  output_count=output_summary.output_count,
93
99
  output_bytes=output_summary.output_bytes,
94
100
  invocation_error_output_count=output_summary.invocation_error_output_count,
@@ -152,8 +158,10 @@ async def _finalize_task_output(
152
158
  )
153
159
 
154
160
 
155
- def _task_output_summary(task_output: TaskOutput) -> _TaskOutputSummary:
156
- summary: _TaskOutputSummary = _TaskOutputSummary()
161
+ def _task_output_summary(
162
+ task_output: TaskAllocationOutput,
163
+ ) -> _TaskAllocationOutputSummary:
164
+ summary: _TaskAllocationOutputSummary = _TaskAllocationOutputSummary()
157
165
 
158
166
  for output in task_output.function_outputs:
159
167
  summary.output_count += 1
@@ -172,7 +180,7 @@ def _task_output_summary(task_output: TaskOutput) -> _TaskOutputSummary:
172
180
 
173
181
  # Temporary workaround is logging customer metrics until we store them somewhere
174
182
  # for future retrieval and processing.
175
- def _log_function_metrics(output: TaskOutput, logger: Any):
183
+ def _log_function_metrics(output: TaskAllocationOutput, logger: Any):
176
184
  if output.metrics is None:
177
185
  return
178
186