forked from ibis-project/ibis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_matrix.py
48 lines (32 loc) · 1.18 KB
/
gen_matrix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations
from pathlib import Path
import mkdocs_gen_files
import pandas as pd
import ibis
import ibis.expr.operations as ops
def get_backends():
entry_points = sorted(ep.name for ep in ibis.util.backend_entry_points())
return [(backend, getattr(ibis, backend)) for backend in entry_points]
def get_leaf_classes(op):
for child_class in op.__subclasses__():
if not child_class.__subclasses__():
yield child_class
else:
yield from get_leaf_classes(child_class)
INTERNAL_OPS = {
# Never translates into anything
ops.UnresolvedExistsSubquery,
ops.UnresolvedNotExistsSubquery,
ops.ScalarParameter,
}
PUBLIC_OPS = (frozenset(get_leaf_classes(ops.Value))) - INTERNAL_OPS
def main():
support = {"operation": [f"{op.__module__}.{op.__name__}" for op in PUBLIC_OPS]}
support.update(
(name, list(map(backend.has_operation, PUBLIC_OPS)))
for name, backend in get_backends()
)
df = pd.DataFrame(support).set_index("operation").sort_index()
with mkdocs_gen_files.open(Path("backends", "raw_support_matrix.csv"), "w") as f:
df.to_csv(f, index_label="FullOperation")
main()