How to use the hdijupyterutils.events.Events function in hdijupyterutils

To help you get started, we’ve selected a few hdijupyterutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter-incubator / sparkmagic / sparkmagic / sparkmagic / utils / sparkevents.py View on Github external
from . import configuration as conf
import sparkmagic.utils.constants as constants


def get_spark_events_handler():
    """
    Create an instance from the handler mentioned in the config file.
    """
    module, class_name = conf.events_handler_class().rsplit('.', 1)
    events_handler_module = importlib.import_module(module)
    events_handler = getattr(events_handler_module, class_name)
    handler = events_handler(constants.MAGICS_LOGGER_NAME, conf.logging_config())
    return handler


class SparkEvents(Events):
    def __init__(self):
        handler = get_spark_events_handler()
        super(SparkEvents, self).__init__(handler)
    

    def emit_library_loaded_event(self):
        event_name = constants.LIBRARY_LOADED_EVENT
        time_stamp = self.get_utc_date_time()

        kwargs_list = [(EVENT_NAME, event_name),
                       (TIMESTAMP, time_stamp)]

        self.send_to_handler(kwargs_list)

    def emit_cluster_change_event(self, cluster_dns_name, status_code, success, error_message):
        event_name = constants.CLUSTER_CHANGE_EVENT