Skip to content

Commit d1dcb98

Browse files
committed
expose translate_json_to_html so that it can be used with object profiles
1 parent fc81a29 commit d1dcb98

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

duckdb/query_graph/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .__main__ import translate_json_to_html
2+
3+
__all__ = ["translate_json_to_html"]

duckdb/query_graph/__main__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,16 @@ def gather_timing_information(json: str, query_timings: object) -> None: # noqa
485485
get_child_timings(json["children"][0], query_timings)
486486

487487

488-
def translate_json_to_html(input_file: str, output_file: str) -> None: # noqa: D103
488+
def translate_json_to_html(input_file: str = None, input_text: str = None, output_file: str = "profile.html") -> None: # noqa: D103
489489
query_timings = AllTimings()
490-
with open_utf8(input_file, "r") as f:
491-
text = f.read()
490+
if input_text is not None:
491+
text = input_text
492+
elif input_file is not None:
493+
with open_utf8(input_file, "r") as f:
494+
text = f.read()
495+
else:
496+
print("please provide either input file or input text")
497+
exit(1)
492498

493499
html_output = generate_style_html(text, True)
494500
highlight_metric_grid = generate_metric_grid_html(text)

0 commit comments

Comments
 (0)