Skip to content

Commit

Permalink
raise exception instead (#1862)
Browse files Browse the repository at this point in the history
  • Loading branch information
madhur-ob authored May 27, 2024
1 parent 34ecc5a commit b512656
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions metaflow/runner/nbrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
DEFAULT_DIR = tempfile.gettempdir()


class NBRunnerInitializationError(Exception):
"""Custom exception for errors during NBRunner initialization."""

pass


def get_current_cell(ipython):
if ipython:
return ipython.history_manager.input_hist_raw[-1]
Expand Down Expand Up @@ -53,10 +59,9 @@ def __init__(

ipython = get_ipython()
except ModuleNotFoundError:
print(
"'nbrun' requires an interactive python environment (such as Jupyter)"
raise NBRunnerInitializationError(
"'NBRunner' requires an interactive Python environment (such as Jupyter)"
)
return

self.cell = get_current_cell(ipython)
self.flow = flow
Expand Down

0 comments on commit b512656

Please sign in to comment.