nv-ingest-api 2025.2.23.dev20250223233317__tar.gz → 2025.2.24.dev20250224233316__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.
Potentially problematic release.
This version of nv-ingest-api might be problematic. Click here for more details.
- {nv_ingest_api-2025.2.23.dev20250223233317/src/nv_ingest_api.egg-info → nv_ingest_api-2025.2.24.dev20250224233316}/PKG-INFO +1 -1
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api/primitives/control_message_task.py +5 -3
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api/primitives/ingest_control_message.py +50 -3
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316/src/nv_ingest_api.egg-info}/PKG-INFO +1 -1
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/LICENSE +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/MANIFEST.in +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/README.md +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/pyproject.toml +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/setup.cfg +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api/__init__.py +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api/primitives/__init__.py +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api.egg-info/SOURCES.txt +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api.egg-info/dependency_links.txt +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api.egg-info/requires.txt +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/nv_ingest_api.egg-info/top_level.txt +0 -0
- {nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/src/version.py +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
|
|
1
3
|
from pydantic import BaseModel, Field, ConfigDict
|
|
2
|
-
from typing import Any, Dict
|
|
4
|
+
from typing import Any, Dict, Union
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
class ControlMessageTask(BaseModel):
|
|
6
8
|
model_config = ConfigDict(extra="forbid")
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
id: str
|
|
10
|
+
type: str
|
|
11
|
+
id: Union[str, UUID]
|
|
10
12
|
properties: Dict[str, Any] = Field(default_factory=dict)
|
|
@@ -12,6 +12,46 @@ from nv_ingest_api.primitives.control_message_task import ControlMessageTask
|
|
|
12
12
|
logger = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
def remove_task_by_type(ctrl_msg, task: str):
|
|
16
|
+
"""
|
|
17
|
+
Remove a task from the control message by matching its type.
|
|
18
|
+
|
|
19
|
+
This function iterates over the tasks in the control message, and if it finds a task
|
|
20
|
+
whose type matches the provided task string, it removes that task (using its unique id)
|
|
21
|
+
and returns the task's properties.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
ctrl_msg : IngestControlMessage
|
|
26
|
+
The control message from which to remove the task.
|
|
27
|
+
task : str
|
|
28
|
+
The task type to remove.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
dict
|
|
33
|
+
The properties of the removed task.
|
|
34
|
+
|
|
35
|
+
Raises
|
|
36
|
+
------
|
|
37
|
+
ValueError
|
|
38
|
+
If no task with the given type is found.
|
|
39
|
+
"""
|
|
40
|
+
task_obj = None
|
|
41
|
+
for t in ctrl_msg.get_tasks():
|
|
42
|
+
if t.type == task:
|
|
43
|
+
task_obj = t
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
if task_obj is None:
|
|
47
|
+
err_msg = f"process_control_message: Task '{task}' not found in control message."
|
|
48
|
+
logger.error(err_msg)
|
|
49
|
+
raise ValueError(err_msg)
|
|
50
|
+
|
|
51
|
+
removed_task = ctrl_msg.remove_task(task_obj.id)
|
|
52
|
+
return removed_task.properties
|
|
53
|
+
|
|
54
|
+
|
|
15
55
|
class IngestControlMessage:
|
|
16
56
|
"""
|
|
17
57
|
A control message class for ingesting tasks and managing associated metadata,
|
|
@@ -53,14 +93,18 @@ class IngestControlMessage:
|
|
|
53
93
|
"""
|
|
54
94
|
return task_id in self._tasks
|
|
55
95
|
|
|
56
|
-
def remove_task(self, task_id: str) ->
|
|
96
|
+
def remove_task(self, task_id: str) -> ControlMessageTask:
|
|
57
97
|
"""
|
|
58
98
|
Remove a task from the control message. Logs a warning if the task does not exist.
|
|
59
99
|
"""
|
|
60
100
|
if task_id in self._tasks:
|
|
101
|
+
_task = self._tasks[task_id]
|
|
102
|
+
|
|
61
103
|
del self._tasks[task_id]
|
|
104
|
+
|
|
105
|
+
return _task
|
|
62
106
|
else:
|
|
63
|
-
|
|
107
|
+
raise RuntimeError(f"Attempted to remove non-existent task with id: {task_id}")
|
|
64
108
|
|
|
65
109
|
def config(self, config: Dict[str, Any] = None) -> Dict[str, Any]:
|
|
66
110
|
"""
|
|
@@ -154,7 +198,8 @@ class IngestControlMessage:
|
|
|
154
198
|
Retrieve timestamps whose keys match the regex filter.
|
|
155
199
|
"""
|
|
156
200
|
pattern = re.compile(regex_filter)
|
|
157
|
-
|
|
201
|
+
timestamps_snapshot = self._timestamps.copy()
|
|
202
|
+
return {key: ts for key, ts in timestamps_snapshot.items() if pattern.search(key)}
|
|
158
203
|
|
|
159
204
|
def get_timestamp(self, key: str, fail_if_nonexist: bool = False) -> datetime:
|
|
160
205
|
"""
|
|
@@ -188,12 +233,14 @@ class IngestControlMessage:
|
|
|
188
233
|
"""
|
|
189
234
|
if isinstance(timestamp, datetime):
|
|
190
235
|
self._timestamps[key] = timestamp
|
|
236
|
+
|
|
191
237
|
elif isinstance(timestamp, str):
|
|
192
238
|
try:
|
|
193
239
|
dt = datetime.fromisoformat(timestamp)
|
|
194
240
|
self._timestamps[key] = dt
|
|
195
241
|
except ValueError as e:
|
|
196
242
|
raise ValueError(f"Invalid timestamp format: {timestamp}") from e
|
|
243
|
+
|
|
197
244
|
else:
|
|
198
245
|
raise ValueError("timestamp must be a datetime object or ISO format string")
|
|
199
246
|
|
{nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/LICENSE
RENAMED
|
File without changes
|
{nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/MANIFEST.in
RENAMED
|
File without changes
|
{nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
{nv_ingest_api-2025.2.23.dev20250223233317 → nv_ingest_api-2025.2.24.dev20250224233316}/setup.cfg
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|