Skip to content

Core

The core package (jumper_extension.core) defines the domain model, configuration, and parsing logic that underpin the JUmPER IPython extension. For the public Python API of PerfmonitorService, see the Python API section; the content below focuses on supporting modules and helper functions and is generated directly from the code.

State

The state module contains dataclasses describing runtime settings for monitoring, automatic reports, and exported or loaded variables.

Configuration and state models for the JUmPER core.

This module defines dataclasses that hold runtime configuration for monitoring, performance reports, and names of exported or loaded variables.

ExportVars dataclass

Names of variables used when exporting data frames.

Attributes:

Name Type Description
perfdata str

Variable name for exported performance data.

cell_history str

Variable name for exported cell history.

Source code in jumper_extension/core/state.py
13
14
15
16
17
18
19
20
21
22
23
@dataclass
class ExportVars:
    """Names of variables used when exporting data frames.

    Attributes:
        perfdata: Variable name for exported performance data.
        cell_history: Variable name for exported cell history.
    """

    perfdata: str = "perfdata_df"
    cell_history: str = "cell_history_df"

LoadedVars dataclass

Names of variables used when loading data frames.

Attributes:

Name Type Description
perfdata str

Variable name for loaded performance data.

cell_history str

Variable name for loaded cell history.

Source code in jumper_extension/core/state.py
26
27
28
29
30
31
32
33
34
35
36
@dataclass
class LoadedVars:
    """Names of variables used when loading data frames.

    Attributes:
        perfdata: Variable name for loaded performance data.
        cell_history: Variable name for loaded cell history.
    """

    perfdata: str = "loaded_perfdata_df"
    cell_history: str = "loaded_cell_history_df"

PerfomanceReports dataclass

Configuration for automatic per-cell performance reports.

Attributes:

Name Type Description
enabled bool

Whether per-cell reports are enabled.

level str

Monitoring level used when generating reports.

text bool

If True, use text reports instead of HTML.

Source code in jumper_extension/core/state.py
39
40
41
42
43
44
45
46
47
48
49
50
51
@dataclass
class PerfomanceReports:
    """Configuration for automatic per-cell performance reports.

    Attributes:
        enabled: Whether per-cell reports are enabled.
        level: Monitoring level used when generating reports.
        text: If True, use text reports instead of HTML.
    """

    enabled: bool = False
    level: str = "process"
    text: bool = False

PerformanceMonitoring dataclass

Configuration for the performance monitoring loop.

Attributes:

Name Type Description
default_interval float

Default sampling interval in seconds.

user_interval Optional[float]

User-provided interval overriding the default.

running bool

Whether monitoring is currently running.

Source code in jumper_extension/core/state.py
54
55
56
57
58
59
60
61
62
63
64
65
66
@dataclass
class PerformanceMonitoring:
    """Configuration for the performance monitoring loop.

    Attributes:
        default_interval: Default sampling interval in seconds.
        user_interval: User-provided interval overriding the default.
        running: Whether monitoring is currently running.
    """

    default_interval: float = 1.0
    user_interval: Optional[float] = None
    running: bool = False

Settings dataclass

Top-level configuration container for the extension.

Groups performance reports, monitoring configuration, and variable names used when exporting or loading data.

Attributes:

Name Type Description
perfreports PerfomanceReports

Settings for per-cell performance reports.

monitoring PerformanceMonitoring

Settings for the monitoring loop.

export_vars ExportVars

Names for exported data variables.

loaded_vars LoadedVars

Names for loaded data variables.

Source code in jumper_extension/core/state.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@dataclass
class Settings:
    """Top-level configuration container for the extension.

    Groups performance reports, monitoring configuration, and variable
    names used when exporting or loading data.

    Attributes:
        perfreports: Settings for per-cell performance reports.
        monitoring: Settings for the monitoring loop.
        export_vars: Names for exported data variables.
        loaded_vars: Names for loaded data variables.
    """

    perfreports: PerfomanceReports = field(default_factory=PerfomanceReports)
    monitoring: PerformanceMonitoring = field(default_factory=PerformanceMonitoring)
    export_vars: ExportVars = field(default_factory=ExportVars)
    loaded_vars: LoadedVars = field(default_factory=LoadedVars)

    def snapshot(self) -> "Settings":
        """Return a deep copy of the current settings.

        Returns:
            Settings: Independent copy of the current configuration.
        """
        return copy.deepcopy(self)

snapshot()

Return a deep copy of the current settings.

Returns:

Name Type Description
Settings Settings

Independent copy of the current configuration.

Source code in jumper_extension/core/state.py
88
89
90
91
92
93
94
def snapshot(self) -> "Settings":
    """Return a deep copy of the current settings.

    Returns:
        Settings: Independent copy of the current configuration.
    """
    return copy.deepcopy(self)

Parsers

Module containing parser utilities for the JUmPER extension.

ArgParsers dataclass

Configuration for command-line argument parsers.

Source code in jumper_extension/core/parsers.py
11
12
13
14
15
16
17
18
19
20
21
22
@dataclass
class ArgParsers:
    """Configuration for command-line argument parsers."""
    perfreport: argparse.ArgumentParser
    auto_perfreports: argparse.ArgumentParser
    perfmonitor_plot: argparse.ArgumentParser
    export_perfdata: argparse.ArgumentParser
    export_cell_history: argparse.ArgumentParser
    import_perfdata: argparse.ArgumentParser
    import_cell_history: argparse.ArgumentParser
    export_session: argparse.ArgumentParser
    import_session: argparse.ArgumentParser

build_export_session_parser()

Build parser for exporting a full session package.

Usage examples in magics

%export_session # uses default directory name %export_session my_dir # export into directory %export_session my_session.zip # export and zip (auto-detected by .zip extension)

Source code in jumper_extension/core/parsers.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def build_export_session_parser() -> argparse.ArgumentParser:
    """Build parser for exporting a full session package.

    Usage examples in magics:
      %export_session                        # uses default directory name
      %export_session my_dir                 # export into directory
      %export_session my_session.zip         # export and zip (auto-detected by .zip extension)
    """
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "path",
        nargs="?",
        default=None,
        help="Target directory or .zip path (defaults to jumper-session-<timestamp>)",
    )
    return parser

build_import_session_parser()

Build parser for importing a full session package from directory or zip.

Source code in jumper_extension/core/parsers.py
134
135
136
137
138
139
140
141
142
def build_import_session_parser() -> argparse.ArgumentParser:
    """Build parser for importing a full session package from directory or zip."""
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "path",
        type=str,
        help="Path to exported session directory or .zip archive",
    )
    return parser

build_perfreport_parser()

Build an ArgumentParser instance for JUmPER commands.

Source code in jumper_extension/core/parsers.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def build_perfreport_parser() -> argparse.ArgumentParser:
    """Build an ArgumentParser instance for JUmPER commands."""
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument(
        "--cell",
        type=str,
        help="Cell index or range (e.g., 5, 2:8, :5)"
    )
    parser.add_argument(
        "--level",
        default="process",
        choices=get_available_levels(),
        help="Performance level",
    )
    parser.add_argument(
        "--text",
        action="store_true",
        help="Show report in text format"
    )
    return parser

parse_arguments(parser, line)

Parse common command line arguments for JUmPER commands.

Parameters:

Name Type Description Default
line str

The command line string to parse

required
parser ArgumentParser

Optional existing ArgumentParser instance

required

Returns:

Type Description
Optional[Namespace]

Parsed arguments or None if parsing failed

Source code in jumper_extension/core/parsers.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def parse_arguments(parser: argparse.ArgumentParser, line: str) -> Optional[argparse.Namespace]:
    """Parse common command line arguments for JUmPER commands.

    Args:
        line: The command line string to parse
        parser: Optional existing ArgumentParser instance

    Returns:
        Parsed arguments or None if parsing failed
    """
    try:
        args = (
            parser.parse_args(shlex.split(line))
            if line
            else parser.parse_args([])
        )
    except Exception:
        args = None
    return args

parse_cell_range(cell_str, cell_history_length)

Parse a cell range string into start and end indices.

Parameters:

Name Type Description Default
cell_str str

String representing cell range (e.g., "1:3", "5", ":10")

required
cell_history_length int

Length of cell history

required

Returns:

Type Description
Optional[Tuple[int, int]]

Tuple of (start_idx, end_idx) or None if invalid

Source code in jumper_extension/core/parsers.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
def parse_cell_range(cell_str: str, cell_history_length: int) -> Optional[Tuple[int, int]]:
    """Parse a cell range string into start and end indices.

    Args:
        cell_str: String representing cell range (e.g., "1:3", "5", ":10")
        cell_history_length: Length of cell history

    Returns:
        Tuple of (start_idx, end_idx) or None if invalid
    """
    if not cell_str:
        return None

    try:
        max_idx = cell_history_length - 1
        if ":" in cell_str:
            start_str, end_str = cell_str.split(":", 1)
            start_idx = 0 if not start_str else int(start_str)
            end_idx = max_idx if not end_str else int(end_str)
        else:
            start_idx = end_idx = int(cell_str)

        if 0 <= start_idx <= end_idx <= max_idx:
            return start_idx, end_idx
    except (ValueError, IndexError, AttributeError):
        pass

    return None

Messages

The messages module defines error and info codes together with their human-readable message templates.

Message codes and templates used by the JUmPER extension.

This module defines enums for error and info codes, maps them to human-readable message templates, and exposes helpers for working with those messages.

ExtensionErrorCode

Bases: Enum

Error codes emitted by the extension.

Source code in jumper_extension/core/messages.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class ExtensionErrorCode(Enum):
    """Error codes emitted by the extension."""

    PYNVML_NOT_AVAILABLE = auto()
    NVIDIA_DRIVERS_NOT_AVAILABLE = auto()
    ADLX_NOT_AVAILABLE = auto()
    AMD_DRIVERS_NOT_AVAILABLE = auto()
    NO_PERFORMANCE_DATA = auto()
    INVALID_CELL_RANGE = auto()
    INVALID_INTERVAL_VALUE = auto()
    INVALID_METRIC_SUBSET = auto()
    NO_ACTIVE_MONITOR = auto()
    MONITOR_ALREADY_RUNNING = auto()
    UNSUPPORTED_FORMAT = auto()
    INVALID_LEVEL = auto()
    DEFINE_LEVEL = auto()
    NO_CELL_HISTORY = auto()

ExtensionInfoCode

Bases: Enum

Informational codes emitted by the extension.

Source code in jumper_extension/core/messages.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class ExtensionInfoCode(Enum):
    """Informational codes emitted by the extension."""

    IMPRECISE_INTERVAL = auto()
    MISSED_MEASUREMENTS = auto()
    PERFORMANCE_REPORTS_DISABLED = auto()
    EXTENSION_LOADED = auto()
    PERFORMANCE_REPORTS_ENABLED = auto()
    MONITOR_STARTED = auto()
    MONITOR_STOPPED = auto()
    EXPORT_SUCCESS = auto()
    PERFORMANCE_DATA_AVAILABLE = auto()
    HTML_REPORTS_NOT_AVAILABLE = auto()
    PLOTS_NOT_AVAILABLE = auto()
    SESSION_IMPORTED = auto()
    IMPORTED_SESSION_PLOT = auto()
    IMPORTED_SESSION_RESOURCES = auto()

get_jumper_process_error_hint()

Return a hint pointing to the error log file.

Returns:

Name Type Description
str str

Human-readable hint with the path to the error log file.

Source code in jumper_extension/core/messages.py
153
154
155
156
157
158
159
160
161
162
163
def get_jumper_process_error_hint() -> str:
    """Return a hint pointing to the error log file.

    Returns:
        str: Human-readable hint with the path to the error log file.
    """
    jumper_process_error_hint = (
        "\nHint: full error info saved to log file: "
        f"{LOGGING['handlers']['error_file']['filename']}"
    )
    return jumper_process_error_hint

Service helpers

The service itself is documented in the public API; this section exposes the helper functions that construct it.

build_perfmonitor_service(plots_disabled=False, plots_disabled_reason='Plotting not available.', display_disabled=False, display_disabled_reason='Display not available.')

Build a new :class:PerfmonitorService instance.

This factory configures the default monitor, visualizer, reporter, cell history, and script writer for use in Python code.

Parameters:

Name Type Description Default
plots_disabled bool

If True, disable plotting in the visualizer.

False
plots_disabled_reason str

Human-readable reason shown when plots are disabled.

'Plotting not available.'
display_disabled bool

If True, disable rich display for reports.

False
display_disabled_reason str

Human-readable reason shown when rich display is disabled.

'Display not available.'

Returns:

Name Type Description
PerfmonitorService PerfmonitorService

A fully initialized service instance.

Examples:

>>> from jumper_extension.core.service import build_perfmonitor_service
>>> service = build_perfmonitor_service()
Source code in jumper_extension/core/service.py
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
def build_perfmonitor_service(
        plots_disabled: bool = False,
        plots_disabled_reason: str = "Plotting not available.",
        display_disabled: bool = False,
        display_disabled_reason: str = "Display not available."
) -> PerfmonitorService:
    """Build a new :class:`PerfmonitorService` instance.

    This factory configures the default monitor, visualizer, reporter,
    cell history, and script writer for use in Python code.

    Args:
        plots_disabled: If ``True``, disable plotting in the visualizer.
        plots_disabled_reason: Human-readable reason shown when plots
            are disabled.
        display_disabled: If ``True``, disable rich display for reports.
        display_disabled_reason: Human-readable reason shown when rich
            display is disabled.

    Returns:
        PerfmonitorService: A fully initialized service instance.

    Examples:
        >>> from jumper_extension.core.service import build_perfmonitor_service
        >>> service = build_perfmonitor_service()
    """
    settings = Settings()
    monitor = PerformanceMonitor()
    cell_history = CellHistory()
    visualizer = build_performance_visualizer(
        cell_history,
        plots_disabled=plots_disabled,
        plots_disabled_reason=plots_disabled_reason,
    )
    reporter = build_performance_reporter(
        cell_history,
        display_disabled=display_disabled,
        display_disabled_reason=display_disabled_reason,
    )
    script_writer = NotebookScriptWriter(cell_history)

    return PerfmonitorService(
        settings=settings,
        monitor=monitor,
        visualizer=visualizer,
        reporter=reporter,
        cell_history=cell_history,
        script_writer=script_writer,
    )

build_perfmonitor_magic_adapter(plots_disabled=False, plots_disabled_reason='Plotting not available.', display_disabled=False, display_disabled_reason='Display not available.')

Build a new :class:PerfmonitorMagicAdapter instance.

This factory constructs a :class:PerfmonitorService and wraps it with a string-based adapter suitable for IPython magics or other command-style interfaces.

Parameters:

Name Type Description Default
plots_disabled bool

If True, disable plotting in the visualizer.

False
plots_disabled_reason str

Human-readable reason shown when plots are disabled.

'Plotting not available.'
display_disabled bool

If True, disable rich display for reports.

False
display_disabled_reason str

Human-readable reason shown when rich display is disabled.

'Display not available.'

Returns:

Name Type Description
PerfmonitorMagicAdapter PerfmonitorMagicAdapter

Adapter instance wrapping the service.

Examples:

>>> from jumper_extension.core.service import (
...     build_perfmonitor_magic_adapter,
... )
>>> adapter = build_perfmonitor_magic_adapter()
Source code in jumper_extension/core/service.py
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
def build_perfmonitor_magic_adapter(
        plots_disabled: bool = False,
        plots_disabled_reason: str = "Plotting not available.",
        display_disabled: bool = False,
        display_disabled_reason: str = "Display not available."
) -> PerfmonitorMagicAdapter:
    """Build a new :class:`PerfmonitorMagicAdapter` instance.

    This factory constructs a :class:`PerfmonitorService` and wraps it
    with a string-based adapter suitable for IPython magics or other
    command-style interfaces.

    Args:
        plots_disabled: If ``True``, disable plotting in the visualizer.
        plots_disabled_reason: Human-readable reason shown when plots
            are disabled.
        display_disabled: If ``True``, disable rich display for reports.
        display_disabled_reason: Human-readable reason shown when rich
            display is disabled.

    Returns:
        PerfmonitorMagicAdapter: Adapter instance wrapping the service.

    Examples:
        >>> from jumper_extension.core.service import (
        ...     build_perfmonitor_magic_adapter,
        ... )
        >>> adapter = build_perfmonitor_magic_adapter()
    """
    service = build_perfmonitor_service(
        plots_disabled=plots_disabled,
        plots_disabled_reason=plots_disabled_reason,
        display_disabled=display_disabled,
        display_disabled_reason=display_disabled_reason,
    )

    parsers = ArgParsers(
        perfreport=build_perfreport_parser(),
        auto_perfreports=build_auto_perfreports_parser(),
        perfmonitor_plot=build_perfmonitor_plot_parser(),
        export_perfdata=build_export_perfdata_parser(),
        export_cell_history=build_export_cell_history_parser(),
        import_perfdata=build_import_perfdata_parser(),
        import_cell_history=build_import_cell_history_parser(),
        export_session=build_export_session_parser(),
        import_session=build_import_session_parser(),
    )

    return PerfmonitorMagicAdapter(
        service=service,
        parsers=parsers,
    )