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

llnl / dftracer-utils / 28693295402

04 Jul 2026 03:17AM UTC coverage: 52.408% (+0.1%) from 52.278%
28693295402

push

github

hariharan-devarajan
feat: silence noisy warnings on aarch64

37318 of 92666 branches covered (40.27%)

Branch coverage included in aggregate %.

33462 of 42389 relevant lines covered (78.94%)

20557.64 hits per line

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

33.9
/src/dftracer/utils/python/utilities/reconstruction_planner.cpp
1
#include <dftracer/utils/core/runtime.h>
2
#include <dftracer/utils/python/py_dict_helpers.h>
3
#include <dftracer/utils/python/py_list_helpers.h>
4
#include <dftracer/utils/python/py_runtime_mixin.h>
5
#include <dftracer/utils/python/py_type_helpers.h>
6
#include <dftracer/utils/python/runtime.h>
7
#include <dftracer/utils/python/utilities/reconstruction_planner.h>
8
#include <dftracer/utils/utilities/composites/dft/reorganize/reconstruction_planner.h>
9

10
#include <string>
11
#include <vector>
12

13
using dftracer::utils::Runtime;
14
using namespace dftracer::utils::utilities::composites::dft::reorganize;
15

16
DFTRACER_UTILS_RUNTIME_BACKED_SLOTS(ReconstructionPlanner,
12✔
17
                                    ReconstructionPlannerObject)
18

19
static PyObject *ReconstructionPlanner_plan(ReconstructionPlannerObject *self,
4✔
20
                                            PyObject *args, PyObject *kwds) {
21
    using dftracer::utils::coro::CoroTask;
22

23
    static const char *kwlist[] = {"reorganized_files", "index_dir", NULL};
24
    PyObject *files_obj;
25
    const char *index_dir = "";
4✔
26

27
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|s", (char **)kwlist,
4!
28
                                     &files_obj, &index_dir))
29
        return NULL;
×
30

31
    std::vector<std::string> files;
4✔
32
    if (!parse_str_list(files_obj, "reorganized_files", files)) return NULL;
4!
33

34
    ReconstructionPlannerInput input;
4✔
35
    input.reorganized_files = std::move(files);
4✔
36
    input.index_dir = index_dir;
4!
37

38
    ReconstructionPlan plan;
4✔
39
    auto *plan_p = &plan;
4✔
40
    ReconstructionPlannerInput input_copy = input;
4!
41

42
    if (!run_blocking([&] {
6!
43
            Runtime *rt = resolve_runtime(self);
4!
44
            auto task = [plan_p, input_copy]() -> CoroTask<void> {
18!
45
                ReconstructionPlannerUtility util;
6!
46
                *plan_p = co_await util.process(input_copy);
8!
47
            };
12!
48
            rt->submit(task(), "reconstruction-planner").get();
4!
49
        })) {
4✔
50
        return NULL;
×
51
    }
52

53
    // files dict: original_path -> reconstruction info
54
    PyObject *py_files = PyDict_New();
4!
55
    if (!py_files) return NULL;
4✔
56

57
    for (const auto &[orig_path, recon] : plan.files) {
4!
58
        // checkpoint_segments: int -> list of segment dicts
59
        PyObject *py_segs = PyDict_New();
×
60
        if (!py_segs) {
×
61
            Py_DECREF(py_files);
×
62
            return NULL;
×
63
        }
64

65
        for (const auto &[cp_idx, seg_list] : recon.checkpoint_segments) {
×
66
            PyObject *py_seg_list =
67
                PyList_New(static_cast<Py_ssize_t>(seg_list.size()));
×
68
            if (!py_seg_list) {
×
69
                Py_DECREF(py_segs);
×
70
                Py_DECREF(py_files);
×
71
                return NULL;
×
72
            }
73
            for (std::size_t si = 0; si < seg_list.size(); si++) {
×
74
                const auto &seg = seg_list[si];
×
75
                PyObject *sd = PyDict_New();
×
76
                if (!sd) {
×
77
                    Py_DECREF(py_seg_list);
×
78
                    Py_DECREF(py_segs);
×
79
                    Py_DECREF(py_files);
×
80
                    return NULL;
×
81
                }
82
                dict_set_steal(sd, "reorg_file",
×
83
                               PyUnicode_FromString(seg.reorg_file.c_str()));
×
84
                dict_set_steal(sd, "output_line_start",
×
85
                               PyLong_FromLong(seg.output_line_start));
×
86
                dict_set_steal(sd, "output_line_end",
×
87
                               PyLong_FromLong(seg.output_line_end));
×
88
                dict_set_steal(sd, "source_checkpoint",
×
89
                               PyLong_FromLong(seg.source_checkpoint));
×
90
                dict_set_steal(sd, "event_count",
×
91
                               PyLong_FromLong(seg.event_count));
×
92
                PyList_SetItem(py_seg_list, static_cast<Py_ssize_t>(si), sd);
×
93
            }
94
            PyObject *py_cp_key = PyLong_FromLong(cp_idx);
×
95
            PyDict_SetItem(py_segs, py_cp_key, py_seg_list);
×
96
            Py_DECREF(py_cp_key);
×
97
            Py_DECREF(py_seg_list);
×
98
        }
99

100
        PyObject *py_recon = PyDict_New();
×
101
        if (!py_recon) {
×
102
            Py_DECREF(py_segs);
×
103
            Py_DECREF(py_files);
×
104
            return NULL;
×
105
        }
106
        dict_set_steal(py_recon, "original_path",
×
107
                       PyUnicode_FromString(recon.original_path.c_str()));
×
108
        dict_set_steal(py_recon, "num_checkpoints",
×
109
                       PyLong_FromLong(recon.num_checkpoints));
×
110
        dict_set_steal(py_recon, "event_hash",
×
111
                       PyUnicode_FromString(recon.event_hash.c_str()));
×
112
        PyDict_SetItemString(py_recon, "checkpoint_segments", py_segs);
×
113
        Py_DECREF(py_segs);
×
114

115
        PyDict_SetItemString(py_files, orig_path.c_str(), py_recon);
×
116
        Py_DECREF(py_recon);
×
117
    }
118

119
    PyObject *result = PyDict_New();
4!
120
    if (!result) {
4!
121
        Py_DECREF(py_files);
×
122
        return NULL;
×
123
    }
124
    PyDict_SetItemString(result, "files", py_files);
4!
125
    Py_DECREF(py_files);
2!
126
    dict_set_steal(result, "total_segments",
4!
127
                   PyLong_FromSize_t(plan.total_segments));
2!
128
    dict_set_steal(result, "total_events",
4!
129
                   PyLong_FromSize_t(plan.total_events));
2!
130
    return result;
4✔
131
}
4✔
132

133
static PyObject *ReconstructionPlanner_call(PyObject *self, PyObject *args,
2✔
134
                                            PyObject *kwds) {
135
    return ReconstructionPlanner_plan((ReconstructionPlannerObject *)self, args,
3✔
136
                                      kwds);
2✔
137
}
138

139
static PyMethodDef ReconstructionPlanner_methods[] = {
140
    {"process", (PyCFunction)ReconstructionPlanner_plan,
141
     METH_VARARGS | METH_KEYWORDS,
142
     "process(reorganized_files, index_dir='')\n"
143
     "--\n"
144
     "\n"
145
     "Build a reconstruction plan from reorganized files.\n"
146
     "\n"
147
     "Args:\n"
148
     "    reorganized_files (list[str]): Paths to reorganized files.\n"
149
     "    index_dir (str): Directory for .dftindex stores (default '').\n"
150
     "\n"
151
     "Returns:\n"
152
     "    dict: Reconstruction plan.\n"},
153
    {NULL} /* Sentinel */
154
};
155

156
PyTypeObject ReconstructionPlannerType = {
157
    PyVarObject_HEAD_INIT(
158
        NULL,
159
        0) "dftracer_utils_ext.ReconstructionPlannerUtility", /* tp_name */
160
    sizeof(ReconstructionPlannerObject),                      /* tp_basicsize */
161
    0,                                                        /* tp_itemsize */
162
    (destructor)ReconstructionPlanner_dealloc,                /* tp_dealloc */
163
    0,                                        /* tp_vectorcall_offset */
164
    0,                                        /* tp_getattr */
165
    0,                                        /* tp_setattr */
166
    0,                                        /* tp_as_async */
167
    0,                                        /* tp_repr */
168
    0,                                        /* tp_as_number */
169
    0,                                        /* tp_as_sequence */
170
    0,                                        /* tp_as_mapping */
171
    0,                                        /* tp_hash */
172
    ReconstructionPlanner_call,               /* tp_call */
173
    0,                                        /* tp_str */
174
    0,                                        /* tp_getattro */
175
    0,                                        /* tp_setattro */
176
    0,                                        /* tp_as_buffer */
177
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
178
    "ReconstructionPlannerUtility(runtime: Runtime | None = None)\n"
179
    "--\n"
180
    "\n"
181
    "Plan reconstruction of original files from reorganized trace files.\n"
182
    "\n"
183
    "Args:\n"
184
    "    runtime (Runtime or None): Runtime for thread pool control.\n"
185
    "        If None, uses the default global Runtime.\n"
186
    "\n"
187
    "process(reorganized_files, index_dir='') -> dict\n"
188
    "    reorganized_files (list[str]): Paths to reorganized trace files.\n"
189
    "    index_dir (str): Directory containing `.dftindex` stores.\n",
190
    /* tp_doc */
191
    0,                                    /* tp_traverse */
192
    0,                                    /* tp_clear */
193
    0,                                    /* tp_richcompare */
194
    0,                                    /* tp_weaklistoffset */
195
    0,                                    /* tp_iter */
196
    0,                                    /* tp_iternext */
197
    ReconstructionPlanner_methods,        /* tp_methods */
198
    0,                                    /* tp_members */
199
    0,                                    /* tp_getset */
200
    0,                                    /* tp_base */
201
    0,                                    /* tp_dict */
202
    0,                                    /* tp_descr_get */
203
    0,                                    /* tp_descr_set */
204
    0,                                    /* tp_dictoffset */
205
    (initproc)ReconstructionPlanner_init, /* tp_init */
206
    0,                                    /* tp_alloc */
207
    ReconstructionPlanner_new,            /* tp_new */
208
};
209

210
int init_reconstruction_planner(PyObject *m) {
2✔
211
    if (register_type(m, &ReconstructionPlannerType,
2✔
212
                      "ReconstructionPlannerUtility") < 0)
2✔
213
        return -1;
×
214

215
    return 0;
2✔
216
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc