codecraftai-integration-runtime 1.3.0__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 (48) hide show
  1. ccai/integrationruntime/__init__.py +27 -0
  2. ccai/integrationruntime/entrypoints.py +59 -0
  3. ccai/integrationruntime/initialize.py +100 -0
  4. ccai/integrationruntime/integratedtestjob.py +100 -0
  5. ccai/integrationruntime/integrationruntimedefaulttypefactory.py +51 -0
  6. ccai/integrationruntime/py.typed +0 -0
  7. ccai/integrationruntime/results/__init__.py +13 -0
  8. ccai/integrationruntime/results/concentrators/__init__.py +13 -0
  9. ccai/integrationruntime/results/concentrators/progressconcentratorservice.py +526 -0
  10. ccai/integrationruntime/results/recorders/__init__.py +22 -0
  11. ccai/integrationruntime/results/recorders/integrationjsonresultrecorder.py +126 -0
  12. ccai/integrationruntime/results/recorders/streamingresultrecorder.py +271 -0
  13. ccai/integrationruntime/results/streaming/__init__.py +25 -0
  14. ccai/integrationruntime/results/streaming/resultstreamer.py +581 -0
  15. ccai/integrationruntime/runtimeoutputcontext.py +68 -0
  16. ccai/integrationruntime/runtimerunmetadata.py +165 -0
  17. ccai/integrationruntime/templates/v2/static/images/test-report-banner-background-image.png +0 -0
  18. ccai/integrationruntime/templates/v2/static/javascript/d3.v7.js +20625 -0
  19. ccai/integrationruntime/templates/v2/static/javascript/icon-components.js +510 -0
  20. ccai/integrationruntime/templates/v2/static/javascript/mojo-components.js +1417 -0
  21. ccai/integrationruntime/templates/v2/static/javascript/prism.js +1789 -0
  22. ccai/integrationruntime/templates/v2/static/javascript/testsummary-accessibility.js +704 -0
  23. ccai/integrationruntime/templates/v2/static/javascript/testsummary-comparison.js +1287 -0
  24. ccai/integrationruntime/templates/v2/static/javascript/testsummary-components.js +3499 -0
  25. ccai/integrationruntime/templates/v2/static/javascript/testsummary-helpers.js +426 -0
  26. ccai/integrationruntime/templates/v2/static/javascript/testsummary-responsive.js +493 -0
  27. ccai/integrationruntime/templates/v2/static/javascript/testsummary.js +1128 -0
  28. ccai/integrationruntime/templates/v2/static/javascript/webcomponent-helpers.js +112 -0
  29. ccai/integrationruntime/templates/v2/static/styles/branding-theme.css +144 -0
  30. ccai/integrationruntime/templates/v2/static/styles/icon-styles.css +9 -0
  31. ccai/integrationruntime/templates/v2/static/styles/mojo-components.css +384 -0
  32. ccai/integrationruntime/templates/v2/static/styles/prism.css +143 -0
  33. ccai/integrationruntime/templates/v2/static/styles/tabs-responsive.css +186 -0
  34. ccai/integrationruntime/templates/v2/static/styles/testsummary-accessibility.css +413 -0
  35. ccai/integrationruntime/templates/v2/static/styles/testsummary-comparison.css +746 -0
  36. ccai/integrationruntime/templates/v2/static/styles/testsummary-responsive.css +679 -0
  37. ccai/integrationruntime/templates/v2/static/styles/testsummary.css +1631 -0
  38. ccai/integrationruntime/templates/v2/tabs/tab-data.html +870 -0
  39. ccai/integrationruntime/templates/v2/tabs/tab-images.html +110 -0
  40. ccai/integrationruntime/templates/v2/tabs/tab-logs.html +594 -0
  41. ccai/integrationruntime/templates/v2/tabs/tab-sounds.html +112 -0
  42. ccai/integrationruntime/templates/v2/tabs/tab-timeseries.html +368 -0
  43. ccai/integrationruntime/templates/v2/tabs/tab-videos.html +372 -0
  44. ccai/integrationruntime/templates/v2/testsummary.html +81 -0
  45. codecraftai_integration_runtime-1.3.0.dist-info/METADATA +73 -0
  46. codecraftai_integration_runtime-1.3.0.dist-info/RECORD +48 -0
  47. codecraftai_integration_runtime-1.3.0.dist-info/WHEEL +4 -0
  48. codecraftai_integration_runtime-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,271 @@
1
+ """
2
+ .. module:: ccai.integrationruntime.results.recorders.streamingresultrecorder
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Module for streaming-enabled result recorder.
5
+
6
+ This module provides a result recorder that streams results to external
7
+ services in real-time while also writing them to local files.
8
+
9
+ .. moduleauthor:: CodeCraftX
10
+ """
11
+
12
+
13
+
14
+ __author__ = "CodeCraftX"
15
+ __copyright__ = "Copyright 2025, Code Craft AI LLC"
16
+ __credits__ = []
17
+
18
+
19
+ from typing import Optional
20
+
21
+ from datetime import datetime
22
+
23
+ from ccai.testbase.results.model.buildinfo import BuildInfo
24
+ from ccai.testbase.results.model.jobinfo import JobInfo
25
+ from ccai.testbase.results.model.pipelineinfo import PipelineInfo
26
+ from ccai.testbase.results.model.renderinfo import RenderInfo
27
+ from ccai.testbase.results.model.streaminginfo import StreamingInfo, StreamingCallback
28
+
29
+ from ccai.testbase.results.model.resultnode import ResultNode
30
+
31
+ from ccai.testbase.results.recorders.jsonresultrecorder import JsonResultRecorder
32
+ from ccai.integrationruntime.results.streaming.resultstreamer import (
33
+ ResultStreamer,
34
+ create_result_streamer
35
+ )
36
+
37
+
38
+ class StreamingResultRecorder(JsonResultRecorder):
39
+ """
40
+ A result recorder that streams results to external services in real-time.
41
+
42
+ This recorder extends :class:`JsonResultRecorder` to add real-time streaming
43
+ of test results to external monitoring services. Results are both written
44
+ to local files (as with JsonResultRecorder) and streamed to the configured
45
+ external service.
46
+
47
+ The streaming functionality supports both REST endpoint streaming and
48
+ WebSocket-based streaming, allowing integration with various monitoring
49
+ and dashboard systems.
50
+
51
+ Context Manager Lifecycle
52
+ -------------------------
53
+ The StreamingResultRecorder extends the JsonResultRecorder lifecycle:
54
+
55
+ 1. **Entry (__enter__)**:
56
+ - Initializes local file recording (inherited)
57
+ - Starts the result streaming thread
58
+
59
+ 2. **Active Recording**:
60
+ - preview() writes to local file AND streams to external service
61
+ - record() writes to local file AND streams to external service
62
+
63
+ 3. **Exit (__exit__)**:
64
+ - Stops the streaming thread
65
+ - Finalizes local file recording (inherited)
66
+
67
+ Thread Safety
68
+ -------------
69
+ The StreamingResultRecorder is thread-safe for concurrent recording.
70
+ The streaming thread operates independently and uses a queue to receive
71
+ results from the recording thread.
72
+
73
+ Example Usage
74
+ -------------
75
+ Basic usage with REST streaming::
76
+
77
+ from datetime import datetime
78
+ from ccai.testbase.results.recorders.streamingresultrecorder import (
79
+ StreamingResultRecorder
80
+ )
81
+ from ccai.testbase.results.model.renderinfo import RenderInfo
82
+ from ccai.testbase.results.model.streaminginfo import (
83
+ StreamingInfo, StreamingProtocol
84
+ )
85
+
86
+ # Configure render info (local files)
87
+ render_info = RenderInfo(
88
+ title="My Test Run",
89
+ summary_filename="/output/testsummary.json",
90
+ summary_template="/templates/testsummary.html",
91
+ stream_results_filename="/output/testresults_stream.jsos",
92
+ consolidated_results_filename="/output/testresults.json",
93
+ static_resource_source="/templates/static",
94
+ static_resource_destination="/output/static"
95
+ )
96
+
97
+ # Configure streaming (external service)
98
+ streaming_info = StreamingInfo(
99
+ protocol=StreamingProtocol.REST,
100
+ streaming_url="https://monitoring.example.com/api/results",
101
+ streaming_headers={"Authorization": "Bearer token123"},
102
+ stream_previews=True,
103
+ stream_results=True
104
+ )
105
+
106
+ # Use as context manager
107
+ with StreamingResultRecorder(
108
+ runid="run-uuid-123",
109
+ start=datetime.now(),
110
+ render_info=render_info,
111
+ streaming_info=streaming_info
112
+ ) as recorder:
113
+ # Record test results - they are written locally AND streamed
114
+ for test_result in test_results:
115
+ recorder.preview(test_result)
116
+ # ... execute test ...
117
+ recorder.record(test_result)
118
+
119
+ See Also
120
+ --------
121
+ :class:`JsonResultRecorder` : Base class for JSON result recording
122
+ :class:`ResultStreamer` : Base class for result streaming
123
+ :class:`RestResultStreamer` : REST endpoint streaming implementation
124
+ :class:`WebSocketResultStreamer` : WebSocket streaming implementation
125
+ """
126
+
127
+ def __init__(self, *, runid: str, start: datetime, render_info: RenderInfo,
128
+ streaming_info: StreamingInfo,
129
+ apod: Optional[str] = None, build_info: Optional[BuildInfo] = None,
130
+ pipeline_info: Optional[PipelineInfo] = None, job_info: Optional[JobInfo] = None,
131
+ streaming_callback: Optional[StreamingCallback] = None):
132
+ """
133
+ Initializes the StreamingResultRecorder.
134
+
135
+ :param runid: The uuid string that identifies a set of test results.
136
+ :param start: The date and time of the start of the test run.
137
+ :param render_info: A :class:`RenderInfo` instance containing output file paths.
138
+ :param streaming_info: A :class:`StreamingInfo` instance containing streaming
139
+ configuration for the external service.
140
+ :param apod: Optional name of an automation pod.
141
+ :param build_info: Optional :class:`BuildInfo` instance.
142
+ :param pipeline_info: Optional :class:`PipelineInfo` instance.
143
+ :param job_info: Optional :class:`JobInfo` instance.
144
+ :param streaming_callback: Optional :class:`StreamingCallback` for custom
145
+ result handling during streaming.
146
+
147
+ :returns: None
148
+ """
149
+ super().__init__(
150
+ runid=runid,
151
+ start=start,
152
+ render_info=render_info,
153
+ apod=apod,
154
+ build_info=build_info,
155
+ pipeline_info=pipeline_info,
156
+ job_info=job_info
157
+ )
158
+
159
+ self._streaming_info = streaming_info
160
+ self._streaming_callback = streaming_callback
161
+ self._streamer: Optional[ResultStreamer] = None
162
+
163
+ def __enter__(self):
164
+ """
165
+ Starts up the recording process and streaming thread.
166
+
167
+ This method extends the parent __enter__ to also start the
168
+ result streaming thread.
169
+
170
+ :returns: self - The recorder instance for use within the context block.
171
+ """
172
+ # Initialize local file recording
173
+ super().__enter__()
174
+
175
+ # Start the streaming thread
176
+ self._streamer = create_result_streamer(
177
+ self._streaming_info,
178
+ self._streaming_callback
179
+ )
180
+ self._streamer.start()
181
+
182
+ return self
183
+
184
+ def __exit__(self, ex_type, ex_inst, ex_tb):
185
+ """
186
+ Finalizes the recording process and stops the streaming thread.
187
+
188
+ This method extends the parent __exit__ to also stop the
189
+ result streaming thread.
190
+
191
+ :param ex_type: The type of exception being raised, or None.
192
+ :param ex_inst: The exception instance, or None.
193
+ :param ex_tb: The traceback, or None.
194
+
195
+ :returns: None
196
+ """
197
+ # Stop the streaming thread
198
+ if self._streamer is not None:
199
+ self._streamer.stop()
200
+ self._streamer = None
201
+
202
+ # Finalize local file recording
203
+ return super().__exit__(ex_type, ex_inst, ex_tb)
204
+
205
+ def preview(self, result: ResultNode):
206
+ """
207
+ Writes a preview of a result to the stream file and streams it.
208
+
209
+ This method extends the parent preview to also stream the
210
+ preview to the external service.
211
+
212
+ :param result: A :class:`ResultNode` object to preview.
213
+
214
+ :returns: None
215
+ """
216
+ # Write to local file
217
+ super().preview(result)
218
+
219
+ # Stream to external service
220
+ if self._streamer is not None and self._streamer.is_running:
221
+ result_dict = result.as_dict(is_preview=True)
222
+ self._streamer.stream_preview(result_dict)
223
+
224
+ return
225
+
226
+ def record(self, result: ResultNode):
227
+ """
228
+ Records a final result entry and streams it.
229
+
230
+ This method extends the parent record to also stream the
231
+ result to the external service.
232
+
233
+ :param result: A :class:`ResultNode` object to record.
234
+
235
+ :returns: None
236
+ """
237
+ # Write to local file
238
+ super().record(result)
239
+
240
+ # Stream to external service
241
+ if self._streamer is not None and self._streamer.is_running:
242
+ result_dict = result.as_dict(is_preview=False)
243
+ self._streamer.stream_result(result_dict)
244
+
245
+ return
246
+
247
+ @property
248
+ def streaming_stats(self) -> dict:
249
+ """
250
+ Returns streaming statistics.
251
+
252
+ :returns: A dictionary containing streaming statistics including
253
+ previews_sent, results_sent, errors, and reconnects.
254
+ """
255
+ if self._streamer is not None:
256
+ return self._streamer.stats
257
+ return {
258
+ "previews_sent": 0,
259
+ "results_sent": 0,
260
+ "errors": 0,
261
+ "reconnects": 0
262
+ }
263
+
264
+ @property
265
+ def is_streaming(self) -> bool:
266
+ """
267
+ Returns True if the streaming thread is running.
268
+
269
+ :returns: True if streaming is active, False otherwise.
270
+ """
271
+ return self._streamer is not None and self._streamer.is_running
@@ -0,0 +1,25 @@
1
+ """
2
+ .. module:: ccai.integrationruntime.results.streaming
3
+ :platform: Darwin, Linux, Unix, Windows
4
+ :synopsis: Package for result streaming services.
5
+
6
+ This package provides services for streaming test results to external
7
+ services in real-time. It supports both REST endpoint streaming and
8
+ WebSocket-based streaming.
9
+
10
+ .. moduleauthor:: CodeCraftX
11
+ """
12
+
13
+ from ccai.integrationruntime.results.streaming.resultstreamer import (
14
+ ResultStreamer,
15
+ RestResultStreamer,
16
+ WebSocketResultStreamer,
17
+ create_result_streamer
18
+ )
19
+
20
+ __all__ = [
21
+ "ResultStreamer",
22
+ "RestResultStreamer",
23
+ "WebSocketResultStreamer",
24
+ "create_result_streamer"
25
+ ]