How to use the nbresuse.default_resources function in nbresuse

To help you get started, we’ve selected a few nbresuse 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 yuvipanda / nbresuse / nbresuse / __init__.py View on Github external
import os
import json
from notebook.utils import url_path_join
from notebook.base.handlers import IPythonHandler
from tornado import web, iostream
import asyncio
import pluggy
from nbresuse import hooks, default_resources
from collections import ChainMap


plugin_manager = pluggy.PluginManager('nbresuse')
plugin_manager.add_hookspecs(hooks)
# Register the resources nbresuse provides by default
plugin_manager.register(default_resources)


class MetricsHandler(IPythonHandler):
    def initialize(self, nbapp):
        self.set_header('content-type', 'text/event-stream')
        self.set_header('cache-control', 'no-cache')
        self.nbapp = nbapp

    @web.authenticated
    async def get(self):
        """
        Calculate and return current resource usage metrics
        """
        while True:
            metrics = {}
            for metric_response in plugin_manager.hook.nbresuse_add_resource(nbapp=self.nbapp):

nbresuse

Simple Jupyter extension to show how much resources (RAM) your notebook is using

BSD-2-Clause
Latest version published 4 years ago

Package Health Score

55 / 100
Full package analysis

Similar packages