codecraftai-testbase 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.
- ccai/factories/py.typed +0 -0
- ccai/factories/testbasedefaulttypefactory.py +25 -0
- ccai/testbase/__init__.py +63 -0
- ccai/testbase/breakpoints.py +110 -0
- ccai/testbase/cli/__init__.py +13 -0
- ccai/testbase/cli/cmdtree/agents/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/config/__init__.py +24 -0
- ccai/testbase/cli/cmdtree/agents/config/extract.py +94 -0
- ccai/testbase/cli/cmdtree/agents/formatting.py +71 -0
- ccai/testbase/cli/cmdtree/agents/jsosparser.py +119 -0
- ccai/testbase/cli/cmdtree/agents/pathresolver.py +34 -0
- ccai/testbase/cli/cmdtree/agents/summary/__init__.py +26 -0
- ccai/testbase/cli/cmdtree/agents/summary/compare.py +128 -0
- ccai/testbase/cli/cmdtree/agents/summary/extract.py +91 -0
- ccai/testbase/cli/cmdtree/agents/testresult/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/agents/testresult/extract.py +77 -0
- ccai/testbase/cli/cmdtree/agents/testresult/failures.py +73 -0
- ccai/testbase/cli/cmdtree/agents/testresult/list.py +63 -0
- ccai/testbase/cli/cmdtree/services/__init__.py +27 -0
- ccai/testbase/cli/cmdtree/services/results.py +66 -0
- ccai/testbase/cli/cmdtree/testing/__init__.py +30 -0
- ccai/testbase/cli/cmdtree/testing/jobs.py +175 -0
- ccai/testbase/cli/cmdtree/testing/query.py +131 -0
- ccai/testbase/cli/cmdtree/testing/run.py +263 -0
- ccai/testbase/cli/cmdtree/utilities/__init__.py +28 -0
- ccai/testbase/cli/cmdtree/utilities/timestamp.py +33 -0
- ccai/testbase/cli/options.py +370 -0
- ccai/testbase/cli/testbase_command.py +64 -0
- ccai/testbase/cli/utilities.py +31 -0
- ccai/testbase/configuration.py +324 -0
- ccai/testbase/constraints.py +998 -0
- ccai/testbase/coupling/__init__.py +569 -0
- ccai/testbase/coupling/basecoupling.py +69 -0
- ccai/testbase/coupling/configurationcoupling.py +138 -0
- ccai/testbase/coupling/integrationcoupling.py +842 -0
- ccai/testbase/coupling/validatorcoupling.py +127 -0
- ccai/testbase/debuggingext.py +281 -0
- ccai/testbase/debuglogging.py +407 -0
- ccai/testbase/debugports.py +469 -0
- ccai/testbase/declaration/__init__.py +13 -0
- ccai/testbase/declaration/attachments.py +222 -0
- ccai/testbase/declaration/originations.py +217 -0
- ccai/testbase/declaration/parameterization.py +160 -0
- ccai/testbase/declaration/registrations.py +476 -0
- ccai/testbase/diagnostic_level.py +197 -0
- ccai/testbase/diagnostic_streaming.py +1534 -0
- ccai/testbase/diagnostics.py +1685 -0
- ccai/testbase/entrypoints.py +485 -0
- ccai/testbase/environment.py +162 -0
- ccai/testbase/errors/testruntimeouterror.py +50 -0
- ccai/testbase/expressions.py +355 -0
- ccai/testbase/factories.py +277 -0
- ccai/testbase/factoryprotocols.py +35 -0
- ccai/testbase/features.py +913 -0
- ccai/testbase/initialize.py +210 -0
- ccai/testbase/injection/__init__.py +25 -0
- ccai/testbase/injection/injectiongroup.py +493 -0
- ccai/testbase/injection/injectionmoment.py +155 -0
- ccai/testbase/injection/injectionregistry.py +823 -0
- ccai/testbase/injection/injectionscope.py +2589 -0
- ccai/testbase/injection/introspection.py +514 -0
- ccai/testbase/markers.py +665 -0
- ccai/testbase/mocking.py +4856 -0
- ccai/testbase/origins/__init__.py +13 -0
- ccai/testbase/origins/resourceorigin.py +110 -0
- ccai/testbase/origins/validatororigin.py +111 -0
- ccai/testbase/output/__init__.py +17 -0
- ccai/testbase/output/outputcontext.py +201 -0
- ccai/testbase/output/runmetadata.py +184 -0
- ccai/testbase/properties/__init__.py +40 -0
- ccai/testbase/properties/assumptions.py +56 -0
- ccai/testbase/properties/decorators.py +173 -0
- ccai/testbase/properties/propertyrunner.py +449 -0
- ccai/testbase/properties/strategies.py +1592 -0
- ccai/testbase/properties/unittestsupport.py +87 -0
- ccai/testbase/py.typed +0 -0
- ccai/testbase/queries.py +95 -0
- ccai/testbase/resourcelifespan.py +24 -0
- ccai/testbase/results/__init__.py +35 -0
- ccai/testbase/results/exceptions.py +60 -0
- ccai/testbase/results/filtering/__init__.py +26 -0
- ccai/testbase/results/filtering/resultfilter.py +570 -0
- ccai/testbase/results/model/__init__.py +32 -0
- ccai/testbase/results/model/buildinfo.py +54 -0
- ccai/testbase/results/model/checkresult.py +183 -0
- ccai/testbase/results/model/forwardinginfo.py +30 -0
- ccai/testbase/results/model/jobcontainer.py +32 -0
- ccai/testbase/results/model/jobinfo.py +91 -0
- ccai/testbase/results/model/nestedprogressinfo.py +211 -0
- ccai/testbase/results/model/pipelineinfo.py +51 -0
- ccai/testbase/results/model/progressaggregator.py +551 -0
- ccai/testbase/results/model/progresscode.py +29 -0
- ccai/testbase/results/model/progressdelivery.py +51 -0
- ccai/testbase/results/model/progressinfo.py +84 -0
- ccai/testbase/results/model/progresstype.py +24 -0
- ccai/testbase/results/model/renderinfo.py +30 -0
- ccai/testbase/results/model/resultcode.py +28 -0
- ccai/testbase/results/model/resultcontainer.py +95 -0
- ccai/testbase/results/model/resultnode.py +258 -0
- ccai/testbase/results/model/resulttype.py +34 -0
- ccai/testbase/results/model/streaminginfo.py +111 -0
- ccai/testbase/results/model/taskinggroup.py +85 -0
- ccai/testbase/results/model/taskingresult.py +297 -0
- ccai/testbase/results/model/testcontainer.py +35 -0
- ccai/testbase/results/model/testresult.py +170 -0
- ccai/testbase/results/recorders/__init__.py +31 -0
- ccai/testbase/results/recorders/csvresultrecorder.py +414 -0
- ccai/testbase/results/recorders/jsonresultrecorder.py +467 -0
- ccai/testbase/results/recorders/resultrecorder.py +1472 -0
- ccai/testbase/results/recorders/stdoutresultrecorder.py +70 -0
- ccai/testbase/results/recorders/xmlresultrecorder.py +305 -0
- ccai/testbase/results/utilities.py +141 -0
- ccai/testbase/sequencing/__init__.py +13 -0
- ccai/testbase/sequencing/sequencermodulescope.py +96 -0
- ccai/testbase/sequencing/sequencerscopebase.py +91 -0
- ccai/testbase/sequencing/sequencersessionscope.py +84 -0
- ccai/testbase/sequencing/sequencertestscope.py +249 -0
- ccai/testbase/sequencing/sequencertestsetupscope.py +86 -0
- ccai/testbase/sequencing/testactivity.py +111 -0
- ccai/testbase/sequencing/testsequencer.py +3072 -0
- ccai/testbase/server/__init__.py +13 -0
- ccai/testbase/server/resultserver.py +599 -0
- ccai/testbase/sources/__init__.py +13 -0
- ccai/testbase/sources/configurationsource.py +32 -0
- ccai/testbase/sources/integrationsource.py +29 -0
- ccai/testbase/sources/resourcesource.py +27 -0
- ccai/testbase/sources/sourcebase.py +71 -0
- ccai/testbase/sources/unknownsource.py +30 -0
- ccai/testbase/sources/validatorsource.py +28 -0
- ccai/testbase/tandem/__init__.py +13 -0
- ccai/testbase/tandem/validators.py +286 -0
- ccai/testbase/testcollector.py +230 -0
- ccai/testbase/testgroup.py +54 -0
- ccai/testbase/testjob.py +600 -0
- ccai/testbase/testref.py +64 -0
- ccai/testbase/utilities.py +472 -0
- ccai/testbase/verification.py +768 -0
- codecraftai_testbase-1.3.0.dist-info/METADATA +99 -0
- codecraftai_testbase-1.3.0.dist-info/RECORD +142 -0
- codecraftai_testbase-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_testbase-1.3.0.dist-info/entry_points.txt +3 -0
- codecraftai_testbase-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
"""
|
|
2
|
+
.. module:: ccai.testbase.results.recorders.csvresultrecorder
|
|
3
|
+
:platform: Darwin, Linux, Unix, Windows
|
|
4
|
+
:synopsis: Module for CSV result recording.
|
|
5
|
+
|
|
6
|
+
.. moduleauthor:: CodeCraftX
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = "CodeCraftX"
|
|
10
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
11
|
+
__credits__ = []
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from typing import Any, List, Optional
|
|
15
|
+
|
|
16
|
+
import csv
|
|
17
|
+
import json
|
|
18
|
+
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
|
|
21
|
+
from ccai.testbase.results.exceptions import ResultRecordingError
|
|
22
|
+
from ccai.testbase.results.model.buildinfo import BuildInfo
|
|
23
|
+
from ccai.testbase.results.model.jobinfo import JobInfo
|
|
24
|
+
from ccai.testbase.results.model.pipelineinfo import PipelineInfo
|
|
25
|
+
from ccai.testbase.results.model.renderinfo import RenderInfo
|
|
26
|
+
|
|
27
|
+
from ccai.testbase.results.model.resultcode import ResultCode
|
|
28
|
+
from ccai.testbase.results.model.resultnode import ResultNode
|
|
29
|
+
from ccai.testbase.results.model.resulttype import ResultType
|
|
30
|
+
|
|
31
|
+
from ccai.testbase.results.recorders.resultrecorder import ResultRecorder
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# CSV column headers for result records
|
|
35
|
+
RESULT_CSV_HEADERS = [
|
|
36
|
+
"name",
|
|
37
|
+
"instance",
|
|
38
|
+
"parent",
|
|
39
|
+
"rtype",
|
|
40
|
+
"result",
|
|
41
|
+
"start",
|
|
42
|
+
"stop",
|
|
43
|
+
"errors",
|
|
44
|
+
"failures",
|
|
45
|
+
"warnings"
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
# CSV column headers for summary records
|
|
49
|
+
SUMMARY_CSV_HEADERS = [
|
|
50
|
+
"version",
|
|
51
|
+
"title",
|
|
52
|
+
"runid",
|
|
53
|
+
"start",
|
|
54
|
+
"stop",
|
|
55
|
+
"result",
|
|
56
|
+
"apod",
|
|
57
|
+
"errors",
|
|
58
|
+
"failed",
|
|
59
|
+
"skipped",
|
|
60
|
+
"passed",
|
|
61
|
+
"total",
|
|
62
|
+
"build_branch",
|
|
63
|
+
"build_build",
|
|
64
|
+
"build_flavor",
|
|
65
|
+
"build_release",
|
|
66
|
+
"build_url",
|
|
67
|
+
"pipeline_id",
|
|
68
|
+
"pipeline_name",
|
|
69
|
+
"pipeline_instance",
|
|
70
|
+
"job_id",
|
|
71
|
+
"job_name",
|
|
72
|
+
"job_type",
|
|
73
|
+
"job_owner"
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _datetime_to_str(dt: datetime) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Converts a datetime object to an ISO format string.
|
|
80
|
+
|
|
81
|
+
:param dt: The datetime object to convert.
|
|
82
|
+
:returns: ISO format string representation.
|
|
83
|
+
"""
|
|
84
|
+
if dt is None:
|
|
85
|
+
return ""
|
|
86
|
+
return dt.isoformat()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _value_to_csv_str(value: Any) -> str:
|
|
90
|
+
"""
|
|
91
|
+
Converts a value to a string representation for CSV.
|
|
92
|
+
|
|
93
|
+
:param value: The value to convert.
|
|
94
|
+
:returns: String representation of the value.
|
|
95
|
+
"""
|
|
96
|
+
if value is None:
|
|
97
|
+
return ""
|
|
98
|
+
elif isinstance(value, datetime):
|
|
99
|
+
return value.isoformat()
|
|
100
|
+
elif isinstance(value, (list, dict)):
|
|
101
|
+
return json.dumps(value)
|
|
102
|
+
elif isinstance(value, bool):
|
|
103
|
+
return str(value).lower()
|
|
104
|
+
else:
|
|
105
|
+
return str(value)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _result_dict_to_csv_row(result_dict: dict) -> List[str]:
|
|
109
|
+
"""
|
|
110
|
+
Converts a result dictionary to a CSV row.
|
|
111
|
+
|
|
112
|
+
:param result_dict: The result dictionary to convert.
|
|
113
|
+
:returns: A list of string values for the CSV row.
|
|
114
|
+
"""
|
|
115
|
+
row = []
|
|
116
|
+
for header in RESULT_CSV_HEADERS:
|
|
117
|
+
if header in result_dict:
|
|
118
|
+
value = result_dict[header]
|
|
119
|
+
row.append(_value_to_csv_str(value))
|
|
120
|
+
elif header == "errors" and "detail" in result_dict:
|
|
121
|
+
row.append(_value_to_csv_str(result_dict["detail"].get("errors", [])))
|
|
122
|
+
elif header == "failures" and "detail" in result_dict:
|
|
123
|
+
row.append(_value_to_csv_str(result_dict["detail"].get("failures", [])))
|
|
124
|
+
elif header == "warnings" and "detail" in result_dict:
|
|
125
|
+
row.append(_value_to_csv_str(result_dict["detail"].get("warnings", [])))
|
|
126
|
+
else:
|
|
127
|
+
row.append("")
|
|
128
|
+
return row
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class CsvResultRecorder(ResultRecorder):
|
|
132
|
+
"""
|
|
133
|
+
Records test results in CSV format.
|
|
134
|
+
|
|
135
|
+
The :class:`CsvResultRecorder` is a concrete implementation of
|
|
136
|
+
:class:`ResultRecorder` that writes test results to CSV files. It produces
|
|
137
|
+
three main output files:
|
|
138
|
+
|
|
139
|
+
1. **Summary File** (testsummary.csv): Contains run metadata, timing, and
|
|
140
|
+
result counts in CSV format with a single data row.
|
|
141
|
+
|
|
142
|
+
2. **Stream Results File** (testresults_stream.csv): Contains individual
|
|
143
|
+
result records as CSV rows. Records are written as tests execute.
|
|
144
|
+
|
|
145
|
+
3. **Consolidated Results File** (testresults.csv): Contains all results
|
|
146
|
+
in a flat CSV format (hierarchical structure is flattened).
|
|
147
|
+
|
|
148
|
+
CSV Format Notes
|
|
149
|
+
----------------
|
|
150
|
+
- The CSV format is inherently flat, so hierarchical result structures
|
|
151
|
+
are flattened when written.
|
|
152
|
+
- Complex fields (errors, failures, warnings) are serialized as JSON
|
|
153
|
+
strings within CSV cells.
|
|
154
|
+
- The stream file includes a header row followed by data rows.
|
|
155
|
+
|
|
156
|
+
Context Manager Lifecycle
|
|
157
|
+
-------------------------
|
|
158
|
+
The CsvResultRecorder inherits the context manager pattern from ResultRecorder:
|
|
159
|
+
|
|
160
|
+
1. **Entry (__enter__)**: Initializes output environment, writes initial
|
|
161
|
+
summary, opens stream file with CSV header
|
|
162
|
+
2. **Active Recording**: preview() and record() write CSV rows
|
|
163
|
+
3. **Exit (__exit__)**: Finalizes counts, writes final summary, closes files
|
|
164
|
+
|
|
165
|
+
Thread Safety
|
|
166
|
+
-------------
|
|
167
|
+
The CsvResultRecorder is thread-safe for concurrent recording:
|
|
168
|
+
|
|
169
|
+
- The record() method uses locking when updating result counters
|
|
170
|
+
- Multiple threads can call record() concurrently without data corruption
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
def __init__(self, *, runid: str, start: datetime, render_info: RenderInfo,
|
|
174
|
+
apod: Optional[str] = None, build_info: Optional[BuildInfo] = None,
|
|
175
|
+
pipeline_info: Optional[PipelineInfo] = None, job_info: Optional[JobInfo] = None):
|
|
176
|
+
"""
|
|
177
|
+
Initializes the :class:`CsvResultRecorder` for recording test results.
|
|
178
|
+
|
|
179
|
+
:param runid: The uuid string that identifies a set of test results.
|
|
180
|
+
:param start: The date and time of the start of the test run.
|
|
181
|
+
:param render_info: A :class:`RenderInfo` instance containing output file paths.
|
|
182
|
+
:param apod: Optional name of an automation pod.
|
|
183
|
+
:param build_info: Optional :class:`BuildInfo` instance.
|
|
184
|
+
:param pipeline_info: Optional :class:`PipelineInfo` instance.
|
|
185
|
+
:param job_info: Optional :class:`JobInfo` instance.
|
|
186
|
+
|
|
187
|
+
:returns: None
|
|
188
|
+
"""
|
|
189
|
+
super(CsvResultRecorder, self).__init__(runid=runid, start=start, render_info=render_info, apod=apod,
|
|
190
|
+
build_info=build_info, pipeline_info=pipeline_info, job_info=job_info)
|
|
191
|
+
self._csv_writer = None
|
|
192
|
+
self._header_written = False
|
|
193
|
+
return
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def __enter__(self):
|
|
197
|
+
"""
|
|
198
|
+
Starts up the recording process of test results.
|
|
199
|
+
|
|
200
|
+
This method extends the base class __enter__ to write the CSV header
|
|
201
|
+
row to the stream file after opening it.
|
|
202
|
+
|
|
203
|
+
:returns: self - The recorder instance for use within the context block.
|
|
204
|
+
"""
|
|
205
|
+
# Call parent __enter__ which opens the stream file
|
|
206
|
+
super(CsvResultRecorder, self).__enter__()
|
|
207
|
+
|
|
208
|
+
# Write CSV header row
|
|
209
|
+
self._csv_writer = csv.writer(self._rout)
|
|
210
|
+
self._csv_writer.writerow(RESULT_CSV_HEADERS)
|
|
211
|
+
self._rout.flush()
|
|
212
|
+
self._header_written = True
|
|
213
|
+
|
|
214
|
+
return self
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def preview(self, result: ResultNode):
|
|
218
|
+
"""
|
|
219
|
+
Writes a preview of a result to the stream file in CSV format.
|
|
220
|
+
|
|
221
|
+
This method serializes the result as a CSV row (without detail fields)
|
|
222
|
+
and writes it to the stream results file.
|
|
223
|
+
|
|
224
|
+
:param result: A :class:`ResultNode` object to preview.
|
|
225
|
+
|
|
226
|
+
:returns: None
|
|
227
|
+
"""
|
|
228
|
+
result_dict = result.as_dict(is_preview=True)
|
|
229
|
+
row = _result_dict_to_csv_row(result_dict)
|
|
230
|
+
|
|
231
|
+
self._csv_writer.writerow(row)
|
|
232
|
+
self._rout.flush()
|
|
233
|
+
|
|
234
|
+
self.catalog_output_directory()
|
|
235
|
+
|
|
236
|
+
return
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def record(self, result: ResultNode):
|
|
240
|
+
"""
|
|
241
|
+
Records a final result entry to the stream file in CSV format.
|
|
242
|
+
|
|
243
|
+
This method serializes the complete result (with detail fields) and
|
|
244
|
+
writes it to the stream results file. Result counters are updated based
|
|
245
|
+
on the result type and code.
|
|
246
|
+
|
|
247
|
+
Thread Safety:
|
|
248
|
+
This method is thread-safe. Counter updates are performed within
|
|
249
|
+
a lock-protected section.
|
|
250
|
+
|
|
251
|
+
:param result: A :class:`ResultNode` object to record.
|
|
252
|
+
|
|
253
|
+
:returns: None
|
|
254
|
+
"""
|
|
255
|
+
result_dict = result.as_dict(is_preview=False)
|
|
256
|
+
row = _result_dict_to_csv_row(result_dict)
|
|
257
|
+
|
|
258
|
+
self._csv_writer.writerow(row)
|
|
259
|
+
self._rout.flush()
|
|
260
|
+
|
|
261
|
+
self._lock.acquire()
|
|
262
|
+
try:
|
|
263
|
+
if result.result_type == ResultType.TEST:
|
|
264
|
+
self._total_count += 1
|
|
265
|
+
|
|
266
|
+
result_code = result.result_code
|
|
267
|
+
if result_code == ResultCode.PASSED:
|
|
268
|
+
self._pass_count += 1
|
|
269
|
+
elif result_code == ResultCode.ERRORED:
|
|
270
|
+
self._error_count += 1
|
|
271
|
+
elif result_code == ResultCode.FAILED:
|
|
272
|
+
self._failure_count += 1
|
|
273
|
+
elif result_code == ResultCode.SKIPPED:
|
|
274
|
+
self._skip_count += 1
|
|
275
|
+
else:
|
|
276
|
+
self._unknown_count += 1
|
|
277
|
+
finally:
|
|
278
|
+
self._lock.release()
|
|
279
|
+
|
|
280
|
+
self.catalog_output_directory()
|
|
281
|
+
|
|
282
|
+
return
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def update_summary(self):
|
|
286
|
+
"""
|
|
287
|
+
Writes the current summary state to the summary CSV file.
|
|
288
|
+
|
|
289
|
+
This method serializes the internal summary dictionary to CSV format
|
|
290
|
+
and writes it to the configured summary_filename. The CSV file contains
|
|
291
|
+
a header row and a single data row.
|
|
292
|
+
|
|
293
|
+
:returns: None
|
|
294
|
+
|
|
295
|
+
:raises: ResultRecordingError if the summary file cannot be written.
|
|
296
|
+
"""
|
|
297
|
+
summary_filename = self._render_info.summary_filename
|
|
298
|
+
|
|
299
|
+
try:
|
|
300
|
+
with open(summary_filename, 'w', newline='') as sout:
|
|
301
|
+
writer = csv.writer(sout)
|
|
302
|
+
writer.writerow(SUMMARY_CSV_HEADERS)
|
|
303
|
+
|
|
304
|
+
# Build the summary row
|
|
305
|
+
detail = self._summary.get("detail", {})
|
|
306
|
+
build = self._summary.get("build", {})
|
|
307
|
+
pipeline = self._summary.get("pipeline", {})
|
|
308
|
+
job = self._summary.get("job", {})
|
|
309
|
+
|
|
310
|
+
row = [
|
|
311
|
+
_value_to_csv_str(self._summary.get("version", "")),
|
|
312
|
+
_value_to_csv_str(self._summary.get("title", "")),
|
|
313
|
+
_value_to_csv_str(self._summary.get("runid", "")),
|
|
314
|
+
_value_to_csv_str(self._summary.get("start", "")),
|
|
315
|
+
_value_to_csv_str(self._summary.get("stop", "")),
|
|
316
|
+
_value_to_csv_str(self._summary.get("result", "")),
|
|
317
|
+
_value_to_csv_str(self._summary.get("apod", "")),
|
|
318
|
+
_value_to_csv_str(detail.get("errors", 0)),
|
|
319
|
+
_value_to_csv_str(detail.get("failed", 0)),
|
|
320
|
+
_value_to_csv_str(detail.get("skipped", 0)),
|
|
321
|
+
_value_to_csv_str(detail.get("passed", 0)),
|
|
322
|
+
_value_to_csv_str(detail.get("total", 0)),
|
|
323
|
+
_value_to_csv_str(build.get("branch", "")),
|
|
324
|
+
_value_to_csv_str(build.get("build", "")),
|
|
325
|
+
_value_to_csv_str(build.get("flavor", "")),
|
|
326
|
+
_value_to_csv_str(build.get("release", "")),
|
|
327
|
+
_value_to_csv_str(build.get("url", "")),
|
|
328
|
+
_value_to_csv_str(pipeline.get("id", "")),
|
|
329
|
+
_value_to_csv_str(pipeline.get("name", "")),
|
|
330
|
+
_value_to_csv_str(pipeline.get("instance", "")),
|
|
331
|
+
_value_to_csv_str(job.get("id", "")),
|
|
332
|
+
_value_to_csv_str(job.get("name", "")),
|
|
333
|
+
_value_to_csv_str(job.get("type", "")),
|
|
334
|
+
_value_to_csv_str(job.get("owner", ""))
|
|
335
|
+
]
|
|
336
|
+
|
|
337
|
+
writer.writerow(row)
|
|
338
|
+
except OSError as err:
|
|
339
|
+
errmsg = f"Failed to write summary to '{summary_filename}'."
|
|
340
|
+
raise ResultRecordingError(
|
|
341
|
+
errmsg,
|
|
342
|
+
file_path=summary_filename,
|
|
343
|
+
operation="writing summary CSV",
|
|
344
|
+
original_error=err
|
|
345
|
+
) from err
|
|
346
|
+
|
|
347
|
+
self.catalog_output_directory()
|
|
348
|
+
|
|
349
|
+
return
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def write_consolidated_results(self, root_node: dict):
|
|
353
|
+
"""
|
|
354
|
+
Writes the consolidated results tree to the consolidated results CSV file.
|
|
355
|
+
|
|
356
|
+
This method flattens the hierarchical result tree and writes all results
|
|
357
|
+
as CSV rows to the configured consolidated_results_filename.
|
|
358
|
+
|
|
359
|
+
:param root_node: A dictionary representing the root of the consolidated
|
|
360
|
+
result tree.
|
|
361
|
+
|
|
362
|
+
:returns: None
|
|
363
|
+
|
|
364
|
+
:raises: ResultRecordingError if the consolidated results file cannot be written.
|
|
365
|
+
"""
|
|
366
|
+
consolidated_filename = self._render_info.consolidated_results_filename
|
|
367
|
+
|
|
368
|
+
try:
|
|
369
|
+
with open(consolidated_filename, 'w+', newline='') as rout:
|
|
370
|
+
writer = csv.writer(rout)
|
|
371
|
+
writer.writerow(RESULT_CSV_HEADERS)
|
|
372
|
+
|
|
373
|
+
# Flatten the tree and write all results
|
|
374
|
+
self._write_node_to_csv(writer, root_node)
|
|
375
|
+
|
|
376
|
+
except OSError as err:
|
|
377
|
+
errmsg = f"Failed to write consolidated results to '{consolidated_filename}'."
|
|
378
|
+
raise ResultRecordingError(
|
|
379
|
+
errmsg,
|
|
380
|
+
file_path=consolidated_filename,
|
|
381
|
+
operation="writing consolidated results CSV",
|
|
382
|
+
original_error=err
|
|
383
|
+
) from err
|
|
384
|
+
|
|
385
|
+
self.catalog_output_directory(force=True)
|
|
386
|
+
|
|
387
|
+
return
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def _write_node_to_csv(self, writer: csv.writer, node: dict):
|
|
391
|
+
"""
|
|
392
|
+
Recursively writes a node and its children to CSV.
|
|
393
|
+
|
|
394
|
+
:param writer: The CSV writer to use.
|
|
395
|
+
:param node: The node dictionary to write.
|
|
396
|
+
"""
|
|
397
|
+
# Write the current node
|
|
398
|
+
row = _result_dict_to_csv_row(node)
|
|
399
|
+
writer.writerow(row)
|
|
400
|
+
|
|
401
|
+
# Write child items if present
|
|
402
|
+
if "items" in node:
|
|
403
|
+
for item in node["items"]:
|
|
404
|
+
self._write_node_to_csv(writer, item)
|
|
405
|
+
|
|
406
|
+
# Write tasking groups if present
|
|
407
|
+
if "tasking_groups" in node:
|
|
408
|
+
for tg in node["tasking_groups"]:
|
|
409
|
+
self._write_node_to_csv(writer, tg)
|
|
410
|
+
|
|
411
|
+
# Write taskings if present
|
|
412
|
+
if "taskings" in node:
|
|
413
|
+
for tasking in node["taskings"]:
|
|
414
|
+
self._write_node_to_csv(writer, tasking)
|