Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: importing HPCToolkit data into Hatchet #126

Merged
merged 15 commits into from
May 30, 2024
50 changes: 39 additions & 11 deletions hatchet/graphframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@
# SPDX-License-Identifier: MIT

import copy
import json
import sys
import traceback

from collections import defaultdict

import pandas as pd
import numpy as np
import multiprocess as mp
import json
import numpy as np
import pandas as pd

from .node import Node
from .graph import Graph
from .external.console import ConsoleRenderer
from .frame import Frame
from .graph import Graph
from .node import Node
from .query import (
is_hatchet_query,
AbstractQuery,
ObjectQuery,
parse_string_dialect,
QueryEngine,
AbstractQuery,
is_hatchet_query,
parse_string_dialect,
)
from .external.console import ConsoleRenderer
from .util.dot import trees_to_dot
from .util.deprecated import deprecated_params
from .util.dot import trees_to_dot

try:
from .cython_modules.libs import graphframe_modules as _gfm_cy
Expand Down Expand Up @@ -110,6 +109,35 @@ def from_hpctoolkit(dirname):

return HPCToolkitReader(dirname).read()

@staticmethod
def from_hpctoolkit_latest(
dirname: str,
max_depth: int = None,
min_percentage_of_application_time: int = None,
min_percentage_of_parent_time: int = None,
):
"""
Read an HPCToolkit database directory into a new GraphFrame

Arguments:
dirname (str): directory of an HPCToolkit performance database
max_depth (int): maximum depth that nodes in the CCT can have to be imported in Hatchet
min_percentage_of_application_time (int): minimum percentage of application time that nodes in the CCT must have to be imported in Hatchet
min_percentage_of_parent_time (int): minimum percentage of parent time that nodes in the CCT must have to be imported in Hatchet

Returns:
(GraphFrame): new GraphFrame containing HPCToolkit profile data
"""
ilumsden marked this conversation as resolved.
Show resolved Hide resolved
# import this lazily to avoid circular dependencies
from .readers.hpctoolkit_reader_latest import HPCToolkitReaderLatest

return HPCToolkitReaderLatest(
dirname,
max_depth=max_depth,
min_application_percentage_time=min_percentage_of_application_time,
min_parent_percentage_time=min_percentage_of_parent_time,
).read()

@staticmethod
def from_caliper(filename_or_stream, query=None):
"""Read in a Caliper .cali or .json file.
Expand Down
Loading
Loading