11import os
22
33from tornado import ioloop
4- from traitlets import Bool , Float , Int , Union , default
4+ from traitlets import Bool
5+ from traitlets import default
6+ from traitlets import Float
7+ from traitlets import Int
8+ from traitlets import Union
59from traitlets .config import Configurable
610
711from nbresuse .prometheus import PrometheusHandler
@@ -17,21 +21,21 @@ def _jupyter_server_extension_paths():
1721 """
1822 Set up the server extension for collecting metrics
1923 """
20- return [{
21- 'module' : 'nbresuse' ,
22- }]
24+ return [{"module" : "nbresuse" }]
2325
2426
2527def _jupyter_nbextension_paths ():
2628 """
2729 Set up the notebook extension for displaying metrics
2830 """
29- return [{
30- "section" : "notebook" ,
31- "dest" : "nbresuse" ,
32- "src" : "static" ,
33- "require" : "nbresuse/main"
34- }]
31+ return [
32+ {
33+ "section" : "notebook" ,
34+ "dest" : "nbresuse" ,
35+ "src" : "static" ,
36+ "require" : "nbresuse/main" ,
37+ }
38+ ]
3539
3640
3741class ResourceUseDisplay (Configurable ):
@@ -49,7 +53,7 @@ class ResourceUseDisplay(Configurable):
4953 we will start warning the user when they use (128 - (128 * 0.1)) MB.
5054
5155 Set to 0 to disable warning.
52- """
56+ """ ,
5357 ).tag (config = True )
5458
5559 mem_limit = Union (
@@ -62,18 +66,18 @@ class ResourceUseDisplay(Configurable):
6266
6367 Defaults to reading from the `MEM_LIMIT` environment variable. If
6468 set to 0, the max memory available is displayed.
65- """
69+ """ ,
6670 ).tag (config = True )
6771
68- @default (' mem_limit' )
72+ @default (" mem_limit" )
6973 def _mem_limit_default (self ):
70- return int (os .environ .get (' MEM_LIMIT' , 0 ))
74+ return int (os .environ .get (" MEM_LIMIT" , 0 ))
7175
7276 track_cpu_percent = Bool (
7377 default_value = False ,
7478 help = """
7579 Set to True in order to enable reporting of CPU usage statistics.
76- """
80+ """ ,
7781 ).tag (config = True )
7882
7983 cpu_warning_threshold = Float (
@@ -86,7 +90,7 @@ def _mem_limit_default(self):
8690 we will start warning the user when they use (150 - (150 * 0.1)) %.
8791
8892 Set to 0 to disable warning.
89- """
93+ """ ,
9094 ).tag (config = True )
9195
9296 cpu_limit = Float (
@@ -98,19 +102,19 @@ def _mem_limit_default(self):
98102
99103 Defaults to reading from the `CPU_LIMIT` environment variable. If
100104 set to 0, the total CPU count available is displayed.
101- """
105+ """ ,
102106 ).tag (config = True )
103107
104- @default (' cpu_limit' )
108+ @default (" cpu_limit" )
105109 def _cpu_limit_default (self ):
106- return float (os .environ .get (' CPU_LIMIT' , 0 ))
110+ return float (os .environ .get (" CPU_LIMIT" , 0 ))
107111
108112
109113def load_jupyter_server_extension (nbapp ):
110114 """
111115 Called during notebook start
112116 """
113117 resuseconfig = ResourceUseDisplay (parent = nbapp )
114- nbapp .web_app .settings [' nbresuse_display_config' ] = resuseconfig
118+ nbapp .web_app .settings [" nbresuse_display_config" ] = resuseconfig
115119 callback = ioloop .PeriodicCallback (PrometheusHandler (nbapp ), 1000 )
116120 callback .start ()
0 commit comments