cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Azure Databricks job and exception handling

lcalca95
New Contributor II

Hi,

I'm working on Azure Databricks and I created two jobs, one based on a python wheel and the other based on a notebook, with the same code. The code get data from Azure blob storage, process data with pyspark and send data to EventHub. The whole code is wrapped in a try / except, like this one:

# import libraries
from opencensus.ext.azure.log_exporter import AzureLogHandler
import logging
 
# add before def main()..
logger = logging.getLogger()
logger.addHandler(
    AzureLogHandler(
        connection_string = 'my-connection-string'
    )
)
 
if __name__ == '__main__':
    try:
        main() # main code: get data, process data, send data to eventhub
    except Exception as e:
        msg = str(getattr(e, 'message', repr(e)))
        logger.exception(msg)

I tried to generate an exception to test logging in App Insights for both the wheel based job and the notebook based job, and I noticed that even if they worked fine the first one (wheel job) return "failed" in the end, instead the second one (notebook job) return "succeded".

Does someone knows why the behavior changes in relation to the job "format"?

Thanks for the help!

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group