• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

llnl-asr / dftracer-utils / 38033748054

10 Oct 2026 07:14AM UTC coverage: 62.608% (+5.2%) from 57.391%
38033748054

push

github

rayandrew
ci: shard the test job

The coverage jobs ran 64 minutes of C++ tests in one process. Each shard
runs every n-th test with ctest -I, the Python tests and the type check
run in shard 1 only, and each shard uploads its own coverage report to
Coveralls, which merges the parallel uploads.

117733 of 235605 branches covered (49.97%)

Branch coverage included in aggregate %.

102379 of 115969 relevant lines covered (88.28%)

3014114.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.19
/src/dftracer/utils/python/streaming_iterator.cpp
1
#include <dftracer/utils/core/common/config.h>
2
#include <dftracer/utils/python/py_errors.h>
3
#include <dftracer/utils/python/py_runtime_mixin.h>
4
#include <dftracer/utils/python/py_type_helpers.h>
5

6
#define PY_SSIZE_T_CLEAN
7
#include <Python.h>
8
#include <dftracer/utils/python/dataframe.h>
9
#include <dftracer/utils/python/py_method.h>
10
#include <dftracer/utils/python/streaming_iterator.h>
11
#include <dftracer/utils/python/trace_reader_iterator.h>
12

13
namespace dftracer::utils::python {
14

15
static PyObject* ArrowStreamingIterator_new(PyTypeObject* type,
43 ✔
16
                                            PyObject* /*args*/,
17
                                            PyObject* /*kwds*/) {
18
    ArrowStreamingIteratorObject* self =
19
        (ArrowStreamingIteratorObject*)type->tp_alloc(type, 0);
43 ✔
20
    if (self) {
43 !
21
        // Allocate C++ state separately to avoid layout issues
22
        self->cpp_state = new ArrowStreamingIteratorState();
43 ✔
23
    }
24
    return (PyObject*)self;
43 ✔
25
}
26

27
static void ArrowStreamingIterator_dealloc(ArrowStreamingIteratorObject* self) {
43 ✔
28
    if (self->cpp_state) {
43 !
29
        // Cancel the stream if still running
30
        if (self->cpp_state->cancel) {
43 !
31
            self->cpp_state->cancel();
43 ✔
32
        }
33
        delete self->cpp_state;
43 !
34
        self->cpp_state = nullptr;
43 ✔
35
    }
36
    Py_TYPE(self)->tp_free((PyObject*)self);
43 ✔
37
}
43 ✔
38

39
static PyObject* ArrowStreamingIterator_iter(PyObject* self) {
43 !
40
    Py_INCREF(self);
41
    return self;
43 ✔
42
}
43

44
#ifdef DFTRACER_UTILS_ENABLE_ARROW
45
// The next Arrow batch of a pull_next producer, wrapped in a capsule.
46
static PyObject* next_batch(ArrowStreamingIteratorObject* self) {
×
47
    std::optional<ArrowExportResult> result;
×
48
    if (!run_blocking_r([&] { return self->cpp_state->pull_next(); }, result))
×
49
        return NULL;
×
50

51
    if (!result.has_value()) {
×
52
        // Check for error
53
        if (self->cpp_state->get_error) {
×
54
            auto ex = self->cpp_state->get_error();
×
55
            if (ex) {
×
56
                try {
57
                    std::rethrow_exception(ex);
×
58
                } catch (const std::exception& e) {
×
59
                    set_typed_py_error(e);
×
60
                    return NULL;
×
61
                } catch (...) {
×
62
                    PyErr_SetString(PyExc_RuntimeError,
×
63
                                    "Unknown error in streaming iterator");
64
                    return NULL;
×
65
                }
×
66
            }
67
        }
×
68
        // Normal completion
69
        return NULL;  // StopIteration
×
70
    }
71

72
    // Wrap the ArrowExportResult in an ArrowBatchCapsule
73
    ArrowBatchCapsuleObject* obj =
74
        (ArrowBatchCapsuleObject*)ArrowBatchCapsuleType.tp_alloc(
×
75
            &ArrowBatchCapsuleType, 0);
76
    if (!obj) return NULL;
×
77
    obj->result = new ArrowExportResult(std::move(*result));
×
78
    return (PyObject*)obj;
×
79
}
×
80
#endif
81

82
static PyObject* ArrowStreamingIterator_next(
53,694 ✔
83
    ArrowStreamingIteratorObject* self) {
84
    if (!self->cpp_state || !self->cpp_state->pull_df) {
53,694 !
85
#ifdef DFTRACER_UTILS_ENABLE_ARROW
86
        if (self->cpp_state && self->cpp_state->pull_next)
×
87
            return next_batch(self);
×
88
#endif
89
        PyErr_SetString(PyExc_RuntimeError, "Iterator not initialized");
×
90
        return NULL;
×
91
    }
92

93
    // Native-DataFrame path: pull a DataFrame chunk (GIL released) and wrap it,
94
    // so the stream never crosses Arrow.
95
    std::optional<dftracer::utils::dataframe::DataFrame> df;
53,694 ✔
96
    if (!run_blocking_r([&] { return self->cpp_state->pull_df(); }, df))
107,388 !
97
        return NULL;
×
98
    if (!df.has_value()) {
53,694 ✔
99
        if (self->cpp_state->get_error) {
43 !
100
            if (auto ex = self->cpp_state->get_error()) {
43 !
101
                try {
102
                    std::rethrow_exception(ex);
×
103
                } catch (const std::exception& e) {
×
104
                    set_typed_py_error(e);
×
105
                    return NULL;
×
106
                } catch (...) {
×
107
                    PyErr_SetString(PyExc_RuntimeError,
×
108
                                    "Unknown error in streaming iterator");
109
                    return NULL;
×
110
                }
×
111
            }
43 !
112
        }
113
        return NULL;  // StopIteration
43 ✔
114
    }
115
    return wrap_dataframe(std::move(*df));
53,651 !
116
}
53,694 ✔
117

118
static PyObject* ArrowStreamingIterator_cancel(
×
119
    ArrowStreamingIteratorObject* self, PyObject* Py_UNUSED(args)) {
120
    if (self->cpp_state && self->cpp_state->cancel) {
×
121
        self->cpp_state->cancel();
×
122
    }
123
    Py_RETURN_NONE;
×
124
}
125

126
static PyMethodDef ArrowStreamingIterator_methods[] = {
127
    {"cancel", DFTU_PYCFUNCTION(ArrowStreamingIterator_cancel), METH_NOARGS,
128
     "Cancel the streaming iterator."},
129
    {NULL}};
130

131
PyTypeObject ArrowStreamingIteratorType = {
132
    PyVarObject_HEAD_INIT(NULL, 0) "dftracer_utils_ext._ArrowStreamingIterator",
133
    sizeof(ArrowStreamingIteratorObject),       /* tp_basicsize */
134
    0,                                          /* tp_itemsize */
135
    (destructor)ArrowStreamingIterator_dealloc, /* tp_dealloc */
136
    0,                                          /* tp_vectorcall_offset */
137
    0,                                          /* tp_getattr */
138
    0,                                          /* tp_setattr */
139
    0,                                          /* tp_as_async */
140
    0,                                          /* tp_repr */
141
    0,                                          /* tp_as_number */
142
    0,                                          /* tp_as_sequence */
143
    0,                                          /* tp_as_mapping */
144
    0,                                          /* tp_hash */
145
    0,                                          /* tp_call */
146
    0,                                          /* tp_str */
147
    0,                                          /* tp_getattro */
148
    0,                                          /* tp_setattro */
149
    0,                                          /* tp_as_buffer */
150
    Py_TPFLAGS_DEFAULT,                         /* tp_flags */
151
    "Streaming Arrow batch iterator.\n\n"
152
    "Yields ArrowBatch objects as they become available from the C++ "
153
    "pipeline.\n"
154
    "Call cancel() to stop the stream early.", /* tp_doc */
155
    0,                                         /* tp_traverse */
156
    0,                                         /* tp_clear */
157
    0,                                         /* tp_richcompare */
158
    0,                                         /* tp_weaklistoffset */
159
    ArrowStreamingIterator_iter,               /* tp_iter */
160
    (iternextfunc)ArrowStreamingIterator_next, /* tp_iternext */
161
    ArrowStreamingIterator_methods,            /* tp_methods */
162
    0,                                         /* tp_members */
163
    0,                                         /* tp_getset */
164
    0,                                         /* tp_base */
165
    0,                                         /* tp_dict */
166
    0,                                         /* tp_descr_get */
167
    0,                                         /* tp_descr_set */
168
    0,                                         /* tp_dictoffset */
169
    0,                                         /* tp_init */
170
    0,                                         /* tp_alloc */
171
    ArrowStreamingIterator_new,                /* tp_new */
172
};
173

174
int init_arrow_streaming_iterator(PyObject* m) {
7 ✔
175
    if (register_type(m, &ArrowStreamingIteratorType,
7 ✔
176
                      "_ArrowStreamingIterator") < 0)
7 !
177
        return -1;
×
178

179
    return 0;
7 ✔
180
}
181

182
}  // namespace dftracer::utils::python
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc