-
Notifications
You must be signed in to change notification settings - Fork 102
Merge jupyterlab-kernel-usage #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidbrochart
merged 49 commits into
jupyter-server:master
from
davidbrochart:jupyterlab-kernel-usage
Dec 15, 2022
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
51a9667
initial commit
echarles 47d344e
add Makefile
echarles 7d6d580
refactor react state
echarles 9a7f312
add a timer with react hook to ensure the panel is refreshed - fixes …
echarles f8831be
panel content for #4 and #7
echarles 0b75795
new icon fixes #3
echarles 4130bb6
ensure minimal ipykernel version - fixes #8
echarles fb853b5
format cpu to 1 decimal - fixes #2
echarles c502e13
better format the memory numbers - fixes #1
echarles fc3c993
bump version to 0.2.0
echarles e7d1816
better format for the memory
echarles 36d46b5
bump versoin to 0.3.0
echarles 9615ee3
update preview image
echarles 0344355
lint
echarles 659e1b7
tune the panel layout
echarles 9f8d62b
Merge pull request #12 from Quansight/fix/panel-layout
echarles 82a8389
show a message is kernel usage is not available
echarles cfe4033
Merge pull request #13 from Quansight/fix/kernel-usage-not-available
echarles 14ae0ee
Add PID
echarles 966d6f5
Merge pull request #14 from Quansight/feat/pid
echarles eb33ff9
readme: add ipykernel requirement - closes #8
echarles 0444216
release: 0.4.0
echarles 35eae6c
remove old kernel poll
echarles c24ad0c
Merge pull request #17 from Quansight/fix/remove-old-kernel
echarles 80d7dc0
don't throw timeout exception
echarles 38e4a50
remove logging
echarles b98c9f8
Merge pull request #18 from Quansight/fix/deadlock
echarles 7ab05a4
Pool only the active kernel and if the sidebar is visible
echarles 17f53e0
Merge pull request #19 from Quansight/feat/avoid-constant-pooling
echarles c2a81ad
lint
echarles ba84246
polish the ui and add cpu_count
echarles 193c6a3
Merge pull request #21 from Quansight/feat/ui-polish
echarles b22e7f8
release: 0.5.0
echarles f9e0a04
Fix issues related to fronted querying too often.
krassowski 4970166
Limit the backend timeout to 1+2+3=6 seconds total
krassowski 77a67e2
Clear kernel ID if disposed
krassowski 683b470
Merge jupyterlab-kernel-usage
davidbrochart 27d392f
Add ipykernel dependency
davidbrochart 74a391c
Update README
davidbrochart 1a28826
Add 'jupyterlab-kernel-usage/' from commit 'b22e7f8b35f1adf7a14f0ff2d…
davidbrochart 22f4c31
Merge pull request #24 from krassowski/fix-request-issues
krassowski 0bc37bf
Pin ipykernel>=6.11.0
davidbrochart b63f052
Merge commit '22f4c31825d52543a0fd19020aad81d94d4bf842' into jupyterl…
davidbrochart 657b727
Remove jupyterlab-kernel-usage
davidbrochart 6703e02
Include changes from https://github.com/Quansight/jupyterlab-kernel-u…
davidbrochart 640c7c4
Lint
davidbrochart ec56106
Remove @jupyterlab/launcher dependency
davidbrochart 9bfbcb5
Review
davidbrochart 22d4e68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
/** | ||
* The type of unit used for reporting memory usage. | ||
*/ | ||
export type MemoryUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB'; | ||
|
||
/** | ||
* The number of bytes in each memory unit. | ||
*/ | ||
export const MEMORY_UNIT_LIMITS: { | ||
readonly [U in MemoryUnit]: number; | ||
} = { | ||
B: 1, | ||
KB: 1024, | ||
MB: 1048576, | ||
GB: 1073741824, | ||
TB: 1099511627776, | ||
PB: 1125899906842624, | ||
}; | ||
|
||
export function formatForDisplay(numBytes: number | undefined): string { | ||
const lu = convertToLargestUnit(numBytes); | ||
return lu[0].toFixed(2) + ' ' + lu[1]; | ||
} | ||
|
||
/** | ||
* Given a number of bytes, convert to the most human-readable | ||
* format, (GB, TB, etc). | ||
*/ | ||
export function convertToLargestUnit( | ||
numBytes: number | undefined | ||
): [number, MemoryUnit] { | ||
if (!numBytes) { | ||
return [0, 'B']; | ||
} | ||
if (numBytes < MEMORY_UNIT_LIMITS.KB) { | ||
return [numBytes, 'B']; | ||
} else if ( | ||
MEMORY_UNIT_LIMITS.KB === numBytes || | ||
numBytes < MEMORY_UNIT_LIMITS.MB | ||
) { | ||
return [numBytes / MEMORY_UNIT_LIMITS.KB, 'KB']; | ||
} else if ( | ||
MEMORY_UNIT_LIMITS.MB === numBytes || | ||
numBytes < MEMORY_UNIT_LIMITS.GB | ||
) { | ||
return [numBytes / MEMORY_UNIT_LIMITS.MB, 'MB']; | ||
} else if ( | ||
MEMORY_UNIT_LIMITS.GB === numBytes || | ||
numBytes < MEMORY_UNIT_LIMITS.TB | ||
) { | ||
return [numBytes / MEMORY_UNIT_LIMITS.GB, 'GB']; | ||
} else if ( | ||
MEMORY_UNIT_LIMITS.TB === numBytes || | ||
numBytes < MEMORY_UNIT_LIMITS.PB | ||
) { | ||
return [numBytes / MEMORY_UNIT_LIMITS.TB, 'TB']; | ||
} else { | ||
return [numBytes / MEMORY_UNIT_LIMITS.PB, 'PB']; | ||
} | ||
} |
This file contains hidden or 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,44 @@ | ||
import { URLExt } from '@jupyterlab/coreutils'; | ||
import { ServerConnection } from '@jupyterlab/services'; | ||
|
||
/** | ||
* Call the API extension | ||
* | ||
* @param endPoint API REST end point for the extension | ||
* @param init Initial values for the request | ||
* @returns The response body interpreted as JSON | ||
*/ | ||
export async function requestAPI<T>( | ||
endPoint = '', | ||
init: RequestInit = {} | ||
): Promise<T> { | ||
const settings = ServerConnection.makeSettings(); | ||
const requestUrl = URLExt.join( | ||
settings.baseUrl, | ||
'jupyterlab_kernel_usage', // API Namespace | ||
endPoint | ||
); | ||
|
||
let response: Response; | ||
try { | ||
response = await ServerConnection.makeRequest(requestUrl, init, settings); | ||
} catch (error) { | ||
throw new ServerConnection.NetworkError(error as any); | ||
} | ||
|
||
let data: any = await response.text(); | ||
|
||
if (data.length > 0) { | ||
try { | ||
data = JSON.parse(data); | ||
} catch (error) { | ||
console.log('Not a JSON response body.', response); | ||
} | ||
} | ||
|
||
if (!response.ok) { | ||
throw new ServerConnection.ResponseError(response, data.message || data); | ||
} | ||
|
||
return data; | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.