Skip to content

Instantly share code, notes, and snippets.

View matthewchoy88's full-sized avatar

Matthew Choy matthewchoy88

View GitHub Profile

Keybase proof

I hereby claim:

  • I am matthewchoy88 on github.
  • I am matthewchoy (https://keybase.io/matthewchoy) on keybase.
  • I have a public key ASC7XwGD8I2M-ylHvfY_SmXK7sHwVFAAoW-ov0eO3OB36Qo

To claim this, I am signing this object:

@matthewchoy88
matthewchoy88 / magic.py
Last active July 4, 2023 02:12
Databricks notebook magic command to catch cell errors
from pyspark.dbutils import DBUtils
from pyspark.sql import SparkSession
import json
from IPython.core.magic import register_cell_magic
from IPython import get_ipython
from IPython.core.magics.execution import capture_output
# Register the %%job_wrapper_handle notebook magic
# This runs a cells contents in a try-except block and on exception exits the notebook gracefully to the parent job.
@register_cell_magic('job_wrapper_handle')