Skip to content

Commit

Permalink
Simplify initialization script
Browse files Browse the repository at this point in the history
  • Loading branch information
theodore-s-beers committed Dec 9, 2024
1 parent 4ab693f commit 94de7d7
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/pykubegrader/initialize.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import panel as pn
from IPython import get_ipython

# Initialize Panel extension
pn.extension()
from .telemetry import telemetry

# Import your telemetry
try:
from pykubegrader.telemetry import telemetry
except ImportError:
telemetry = None
print("Telemetry module not found. Ensure it is installed and accessible.")

# Check if in a Jupyter environment and set up pre-run event
# Check if in a Jupyter environment
ipython = get_ipython()
if ipython and telemetry:

if ipython is not None:
# Initialize Panel extension
pn.extension()

# Register telemetry with pre_run_cell event
ipython.events.register("pre_run_cell", telemetry)
print("Telemetry registered with pre_run_cell event.")

print("Setup completed successfully")
else:
print("Not in a Jupyter environment or telemetry unavailable.")
print("Setup unsuccessful. Are you in a Jupyter environment?")

0 comments on commit 94de7d7

Please sign in to comment.