nv-ingest-api 2025.4.17.dev20250417__py3-none-any.whl → 2025.4.18.dev20250418__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.
Potentially problematic release.
This version of nv-ingest-api might be problematic. Click here for more details.
- nv_ingest_api/util/message_brokers/simple_message_broker/simple_client.py +22 -6
- nv_ingest_api/util/service_clients/client_base.py +16 -2
- nv_ingest_api/util/service_clients/redis/redis_client.py +669 -180
- nv_ingest_api/util/service_clients/rest/rest_client.py +356 -223
- {nv_ingest_api-2025.4.17.dev20250417.dist-info → nv_ingest_api-2025.4.18.dev20250418.dist-info}/METADATA +1 -1
- {nv_ingest_api-2025.4.17.dev20250417.dist-info → nv_ingest_api-2025.4.18.dev20250418.dist-info}/RECORD +9 -9
- {nv_ingest_api-2025.4.17.dev20250417.dist-info → nv_ingest_api-2025.4.18.dev20250418.dist-info}/WHEEL +0 -0
- {nv_ingest_api-2025.4.17.dev20250417.dist-info → nv_ingest_api-2025.4.18.dev20250418.dist-info}/licenses/LICENSE +0 -0
- {nv_ingest_api-2025.4.17.dev20250417.dist-info → nv_ingest_api-2025.4.18.dev20250418.dist-info}/top_level.txt +0 -0
|
@@ -11,10 +11,10 @@ import socket
|
|
|
11
11
|
import json
|
|
12
12
|
import time
|
|
13
13
|
import logging
|
|
14
|
-
from typing import Optional
|
|
14
|
+
from typing import Optional, Tuple, Union
|
|
15
15
|
|
|
16
16
|
from nv_ingest_api.internal.schemas.message_brokers.response_schema import ResponseSchema
|
|
17
|
-
from nv_ingest_api.util.service_clients.client_base import MessageBrokerClientBase
|
|
17
|
+
from nv_ingest_api.util.service_clients.client_base import MessageBrokerClientBase, FetchMode
|
|
18
18
|
|
|
19
19
|
logger = logging.getLogger(__name__)
|
|
20
20
|
|
|
@@ -80,7 +80,11 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
80
80
|
return self
|
|
81
81
|
|
|
82
82
|
def submit_message(
|
|
83
|
-
self,
|
|
83
|
+
self,
|
|
84
|
+
queue_name: str,
|
|
85
|
+
message: str,
|
|
86
|
+
timeout: Optional[Tuple[int, Union[float]]] = (100, None),
|
|
87
|
+
for_nv_ingest: bool = False,
|
|
84
88
|
) -> ResponseSchema:
|
|
85
89
|
"""
|
|
86
90
|
Submit a message to the specified queue.
|
|
@@ -103,7 +107,12 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
103
107
|
"""
|
|
104
108
|
return self._handle_push(queue_name, message, timeout, for_nv_ingest)
|
|
105
109
|
|
|
106
|
-
def fetch_message(
|
|
110
|
+
def fetch_message(
|
|
111
|
+
self,
|
|
112
|
+
queue_name: str,
|
|
113
|
+
timeout: Optional[Tuple[int, Union[float]]] = (100, None),
|
|
114
|
+
override_fetch_mode: FetchMode = None,
|
|
115
|
+
) -> ResponseSchema:
|
|
107
116
|
"""
|
|
108
117
|
Fetch a message from the specified queue.
|
|
109
118
|
|
|
@@ -119,6 +128,9 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
119
128
|
ResponseSchema
|
|
120
129
|
The response containing the fetched message.
|
|
121
130
|
"""
|
|
131
|
+
if isinstance(timeout, int):
|
|
132
|
+
timeout = (timeout, None)
|
|
133
|
+
|
|
122
134
|
return self._handle_pop(queue_name, timeout)
|
|
123
135
|
|
|
124
136
|
def ping(self) -> ResponseSchema:
|
|
@@ -151,7 +163,7 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
151
163
|
return self._execute_simple_command(command)
|
|
152
164
|
|
|
153
165
|
def _handle_push(
|
|
154
|
-
self, queue_name: str, message: str, timeout: Optional[float], for_nv_ingest: bool
|
|
166
|
+
self, queue_name: str, message: str, timeout: Optional[Tuple[int, Union[float, None]]], for_nv_ingest: bool
|
|
155
167
|
) -> ResponseSchema:
|
|
156
168
|
"""
|
|
157
169
|
Push a message to the queue with optional timeout.
|
|
@@ -183,6 +195,7 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
183
195
|
else:
|
|
184
196
|
command = {"command": "PUSH", "queue_name": queue_name, "message": message}
|
|
185
197
|
|
|
198
|
+
timeout = int(timeout[0])
|
|
186
199
|
if timeout is not None:
|
|
187
200
|
command["timeout"] = timeout
|
|
188
201
|
|
|
@@ -237,7 +250,7 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
237
250
|
|
|
238
251
|
time.sleep(0.5) # Backoff delay before retry
|
|
239
252
|
|
|
240
|
-
def _handle_pop(self, queue_name: str, timeout: Optional[float]) -> ResponseSchema:
|
|
253
|
+
def _handle_pop(self, queue_name: str, timeout: Optional[Tuple[int, Union[float, None]]]) -> ResponseSchema:
|
|
241
254
|
"""
|
|
242
255
|
Pop a message from the queue with optional timeout.
|
|
243
256
|
|
|
@@ -258,6 +271,9 @@ class SimpleClient(MessageBrokerClientBase):
|
|
|
258
271
|
return ResponseSchema(response_code=1, response_reason="Invalid queue name.")
|
|
259
272
|
|
|
260
273
|
command = {"command": "POP", "queue_name": queue_name}
|
|
274
|
+
|
|
275
|
+
timeout = int(timeout[0])
|
|
276
|
+
|
|
261
277
|
if timeout is not None:
|
|
262
278
|
command["timeout"] = timeout
|
|
263
279
|
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
from abc import ABC
|
|
6
6
|
from abc import abstractmethod
|
|
7
|
+
from enum import Enum, auto
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
|
|
10
|
+
from nv_ingest_api.internal.schemas.message_brokers.response_schema import ResponseSchema
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class FetchMode(Enum):
|
|
14
|
+
DESTRUCTIVE = auto() # Read and delete immediately (current behavior)
|
|
15
|
+
NON_DESTRUCTIVE = auto() # Read without deleting (requires TTL on Redis data)
|
|
16
|
+
CACHE_BEFORE_DELETE = auto() # Read, write to local cache, then delete from Redis
|
|
7
17
|
|
|
8
18
|
|
|
9
19
|
class MessageBrokerClientBase(ABC):
|
|
@@ -49,24 +59,28 @@ class MessageBrokerClientBase(ABC):
|
|
|
49
59
|
"""
|
|
50
60
|
|
|
51
61
|
@abstractmethod
|
|
52
|
-
def fetch_message(
|
|
62
|
+
def fetch_message(
|
|
63
|
+
self, job_index: str, timeout: Tuple[int, float] = (100, None), override_fetch_mode: FetchMode = None
|
|
64
|
+
) -> ResponseSchema:
|
|
53
65
|
"""
|
|
54
66
|
Fetches a message from the specified queue with retries on failure.
|
|
55
67
|
|
|
56
68
|
Parameters:
|
|
57
69
|
job_index (str): The index of the job to fetch the message for.
|
|
58
70
|
timeout (float): The timeout in seconds for blocking until a message is available.
|
|
71
|
+
override_fetch_mode: Optional; overrides the default fetch mode.
|
|
59
72
|
|
|
60
73
|
Returns:
|
|
61
74
|
The fetched message, or None if no message could be fetched.
|
|
62
75
|
"""
|
|
63
76
|
|
|
64
77
|
@abstractmethod
|
|
65
|
-
def submit_message(self, channel_name: str, message: str) ->
|
|
78
|
+
def submit_message(self, channel_name: str, message: str, for_nv_ingest=False) -> ResponseSchema:
|
|
66
79
|
"""
|
|
67
80
|
Submits a message to a specified queue with retries on failure.
|
|
68
81
|
|
|
69
82
|
Parameters:
|
|
70
83
|
channel_name (str): The name of the queue to submit the message to.
|
|
71
84
|
message (str): The message to submit.
|
|
85
|
+
for_nv_ingest (bool): Whether the message is for NV Ingest.
|
|
72
86
|
"""
|