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

llnl / dftracer-utils / 28496595030

01 Jul 2026 05:50AM UTC coverage: 50.727% (-1.6%) from 52.278%
28496595030

Pull #83

github

web-flow
Merge 8f1ff4df5 into 2efed6649
Pull Request #83: refactor and improve code QoL

31872 of 80367 branches covered (39.66%)

Branch coverage included in aggregate %.

770 of 1591 new or added lines in 85 files covered. (48.4%)

5070 existing lines in 182 files now uncovered.

32742 of 47009 relevant lines covered (69.65%)

9887.52 hits per line

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

63.33
/src/dftracer/utils/python/utilities/metadata_collector.cpp
1
#define PY_SSIZE_T_CLEAN
2
#include <dftracer/utils/core/common/archive_format.h>
3
#include <dftracer/utils/core/coro/task.h>
4
#include <dftracer/utils/core/runtime.h>
5
#include <dftracer/utils/python/py_dict_helpers.h>
6
#include <dftracer/utils/python/py_runtime_mixin.h>
7
#include <dftracer/utils/python/py_type_helpers.h>
8
#include <dftracer/utils/python/runtime.h>
9
#include <dftracer/utils/python/utilities/metadata_collector.h>
10
#include <dftracer/utils/utilities/composites/dft/internal/utils.h>
11
#include <dftracer/utils/utilities/composites/dft/metadata_collector_utility.h>
12

13
#include <string>
14

15
using dftracer::utils::get_format_name;
16
using dftracer::utils::Runtime;
17
using dftracer::utils::coro::CoroTask;
18
using namespace dftracer::utils::utilities::composites::dft;
19

20
static Runtime *get_runtime(MetadataCollectorObject *self) {
4✔
21
    return resolve_runtime(self);
4✔
22
}
23

24
static void MetadataCollector_dealloc(MetadataCollectorObject *self) {
4✔
25
    runtime_backed_dealloc(self);
4✔
26
}
4✔
27

28
static PyObject *MetadataCollector_new(PyTypeObject *type, PyObject *args,
4✔
29
                                       PyObject *kwds) {
30
    return runtime_backed_new<MetadataCollectorObject>(type, args, kwds);
4✔
31
}
32

33
static int MetadataCollector_init(MetadataCollectorObject *self, PyObject *args,
4✔
34
                                  PyObject *kwds) {
35
    return runtime_backed_init(self, args, kwds);
4✔
36
}
37

38
static PyObject *MetadataCollector_collect(MetadataCollectorObject *self,
4✔
39
                                           PyObject *args, PyObject *kwds) {
40
    static const char *kwlist[] = {"file_path", "index_dir", NULL};
41
    const char *file_path;
42
    const char *index_dir = "";
4✔
43
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|s", (char **)kwlist,
4!
44
                                     &file_path, &index_dir))
45
        return NULL;
×
46

47
    std::string file_path_str(file_path);
4✔
48
    std::string index_dir_str(index_dir);
4!
49
    MetadataCollectorUtilityOutput output;
4✔
50

51
    if (!run_blocking([&] {
8!
52
            Runtime *rt = get_runtime(self);
4✔
53

54
            MetadataCollectorUtilityInput input;
4✔
55
            input.file_path = file_path_str;
4!
56
            input.index_path = dftracer::utils::utilities::composites::dft::
4!
57
                internal::determine_index_path(file_path_str, index_dir_str);
4✔
58

59
            auto *out_p = &output;
4✔
60
            auto input_copy = input;
4!
61
            auto task = [out_p, input_copy]() -> CoroTask<void> {
32!
62
                MetadataCollectorUtility util;
12!
63
                *out_p = co_await util.process(input_copy);
16!
64
            };
12!
65
            rt->submit(task(), "metadata-collector").get();
4!
66
        })) {
4✔
UNCOV
67
        return NULL;
×
68
    }
69

70
    PyObject *d = PyDict_New();
4!
71
    if (!d) return NULL;
4!
72

73
    int rc = 0;
4✔
74
    rc |= dict_set_str(d, "file_path", output.file_path.c_str());
4!
75
    rc |= dict_set_str(d, "index_path", output.index_path.c_str());
4!
76
    rc |= dict_set_f64(d, "size_mb", output.size_mb);
4!
77
    rc |= dict_set_size(d, "start_line", output.start_line);
4!
78
    rc |= dict_set_size(d, "end_line", output.end_line);
4!
79
    rc |= dict_set_size(d, "valid_events", output.valid_events);
4!
80
    rc |= dict_set_f64(d, "size_per_line", output.size_per_line);
4!
81
    rc |= dict_set_bool(d, "success", output.success);
4!
82
    rc |= dict_set_bool(d, "has_index", output.has_index);
4!
83
    rc |= dict_set_bool(d, "index_valid", output.index_valid);
4!
84
    rc |= dict_set_u64(d, "compressed_size", output.compressed_size);
4!
85
    rc |= dict_set_u64(d, "uncompressed_size", output.uncompressed_size);
4!
86
    rc |= dict_set_u64(d, "num_lines", output.num_lines);
4!
87
    rc |= dict_set_u64(d, "checkpoint_size", output.checkpoint_size);
4!
88
    rc |= dict_set_size(d, "num_checkpoints", output.num_checkpoints);
4!
89
    rc |= dict_set_str(d, "format", get_format_name(output.format));
4!
90
    rc |= dict_set_str(d, "error_message", output.error_message.c_str());
4!
91

92
    if (rc != 0) {
4!
NEW
93
        Py_DECREF(d);
×
NEW
94
        return NULL;
×
95
    }
96

97
    return d;
4✔
98
}
4✔
99

100
static PyObject *MetadataCollector_call(PyObject *self, PyObject *args,
1✔
101
                                        PyObject *kwds) {
102
    return MetadataCollector_collect((MetadataCollectorObject *)self, args,
2✔
103
                                     kwds);
1✔
104
}
105

106
static PyMethodDef MetadataCollector_methods[] = {
107
    {"process", (PyCFunction)MetadataCollector_collect,
108
     METH_VARARGS | METH_KEYWORDS,
109
     "Collect metadata from a trace file.\n"
110
     "\n"
111
     "Args:\n"
112
     "    file_path (str): Path to the trace file.\n"
113
     "    index_dir (str): Directory for .dftindex stores.\n"},
114
    {NULL}};
115

116
PyTypeObject MetadataCollectorType = {
117
    PyVarObject_HEAD_INIT(
118
        NULL, 0) "dftracer_utils_ext.MetadataCollectorUtility", /* tp_name */
119
    sizeof(MetadataCollectorObject),          /* tp_basicsize */
120
    0,                                        /* tp_itemsize */
121
    (destructor)MetadataCollector_dealloc,    /* tp_dealloc */
122
    0,                                        /* tp_vectorcall_offset */
123
    0,                                        /* tp_getattr */
124
    0,                                        /* tp_setattr */
125
    0,                                        /* tp_as_async */
126
    0,                                        /* tp_repr */
127
    0,                                        /* tp_as_number */
128
    0,                                        /* tp_as_sequence */
129
    0,                                        /* tp_as_mapping */
130
    0,                                        /* tp_hash */
131
    MetadataCollector_call,                   /* tp_call */
132
    0,                                        /* tp_str */
133
    0,                                        /* tp_getattro */
134
    0,                                        /* tp_setattro */
135
    0,                                        /* tp_as_buffer */
136
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
137
    "MetadataCollectorUtility(runtime: Runtime | None = None)\n"
138
    "--\n\n"
139
    "Collect metadata from a DFTracer trace file.\n\n"
140
    "Args:\n"
141
    "    runtime (Runtime or None): Runtime for thread pool control.\n"
142
    "\n"
143
    "process(file_path, index_dir='') -> dict\n"
144
    "    file_path (str): Path to the trace file.\n"
145
    "    index_dir (str): Directory for .dftindex stores.\n",
146
    0,                                /* tp_traverse */
147
    0,                                /* tp_clear */
148
    0,                                /* tp_richcompare */
149
    0,                                /* tp_weaklistoffset */
150
    0,                                /* tp_iter */
151
    0,                                /* tp_iternext */
152
    MetadataCollector_methods,        /* tp_methods */
153
    0,                                /* tp_members */
154
    0,                                /* tp_getset */
155
    0,                                /* tp_base */
156
    0,                                /* tp_dict */
157
    0,                                /* tp_descr_get */
158
    0,                                /* tp_descr_set */
159
    0,                                /* tp_dictoffset */
160
    (initproc)MetadataCollector_init, /* tp_init */
161
    0,                                /* tp_alloc */
162
    MetadataCollector_new,            /* tp_new */
163
};
164

165
int init_metadata_collector(PyObject *m) {
1✔
166
    if (register_type(m, &MetadataCollectorType, "MetadataCollectorUtility") <
1!
167
        0)
UNCOV
168
        return -1;
×
169

170
    return 0;
1✔
171
}
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