-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dynamic updateFrequency via settingsRegistry (#182)
* add dynamic updateFrequency via settingsRegistry * update default to 100ms * fix size constraint class issue
- Loading branch information
1 parent
b103605
commit 20789f0
Showing
16 changed files
with
447 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"title": "jupyterlab-nvdashboard", | ||
"description": "Settings for the jupyterlab-nvdashboard extension.", | ||
"type": "object", | ||
"properties": { | ||
"updateFrequency": { | ||
"type": "integer", | ||
"title": "Frequency of Updates", | ||
"description": "The frequency of updates for the GPU Dashboard widgets, in milliseconds.", | ||
"default": 100, | ||
"minimum": 1 | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
export const BAR_COLOR_LINEAR_RANGE: string[] = ['#ff7900', '#b30000']; | ||
export const GPU_COLOR_CATEGORICAL_RANGE: string[] = ['#fecc5c', '#bd0026']; | ||
export const PLUGIN_ID = 'jupyterlab-nvdashboard'; | ||
export const PLUGIN_ID_CONFIG = `${PLUGIN_ID}:config`; | ||
export const PLUGIN_ID_OPEN_SETTINGS = `${PLUGIN_ID}:open-settings`; | ||
export const WIDGET_TRACKER_NAME = 'gpu-dashboard-widgets'; | ||
export const COMMAND_OPEN_SETTINGS = 'settingeditor:open'; | ||
export const COMMAND_OPEN_WIDGET = 'gpu-dashboard-widget:open'; | ||
export const DEFAULT_UPDATE_FREQUENCY = 100; // ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ISettingRegistry } from '@jupyterlab/settingregistry'; | ||
import { SetStateAction, useEffect } from 'react'; | ||
import { DEFAULT_UPDATE_FREQUENCY, PLUGIN_ID_CONFIG } from './constants'; | ||
|
||
function loadSettingRegistry( | ||
settingRegistry: ISettingRegistry, | ||
setUpdateFrequency: { | ||
(value: SetStateAction<number>): void; | ||
(arg0: number): void; | ||
} | ||
) { | ||
useEffect(() => { | ||
const loadSettings = async () => { | ||
try { | ||
const settings = await settingRegistry.load(PLUGIN_ID_CONFIG); | ||
const loadedUpdateFrequency = | ||
(settings.get('updateFrequency').composite as number) || | ||
DEFAULT_UPDATE_FREQUENCY; | ||
setUpdateFrequency(loadedUpdateFrequency); | ||
|
||
settings.changed.connect(() => { | ||
setUpdateFrequency( | ||
(settings.get('updateFrequency').composite as number) || | ||
DEFAULT_UPDATE_FREQUENCY | ||
); | ||
}); | ||
} catch (error) { | ||
console.error(`An error occurred while loading settings: ${error}`); | ||
} | ||
}; | ||
loadSettings(); | ||
}, []); | ||
} | ||
|
||
export default loadSettingRegistry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ILabShell, JupyterFrontEnd } from '@jupyterlab/application'; | ||
import { ISettingRegistry } from '@jupyterlab/settingregistry'; | ||
import { MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils'; | ||
|
||
export interface IChartProps { | ||
settingRegistry: ISettingRegistry; | ||
} | ||
|
||
export interface IControlProps { | ||
app: JupyterFrontEnd; | ||
labShell: ILabShell; | ||
tracker: WidgetTracker; | ||
settingRegistry: ISettingRegistry; | ||
} | ||
|
||
export interface IWidgetInfo { | ||
id: string; | ||
title: string; | ||
instance: MainAreaWidget; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.