-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 20364a6
Showing
275 changed files
with
78,975 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 329586684616b8808802a9193d4ac9f2 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Empty file.
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 @@ | ||
lumen.holoviz.org |
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,57 @@ | ||
const appName = 'Lumen' | ||
const appCacheName = 'Lumen-0.6.0'; | ||
|
||
const preCacheFiles = []; | ||
|
||
const cachePatterns = ['https://cdn.holoviz.org/panel/1.3.1/dist/', 'https://cdn.bokeh.org/bokeh/', 'https://cdn.jsdelivr.net/pyodide/', 'https://files.pythonhosted.org/packages/', 'https://pypi.org/pypi/']; | ||
|
||
self.addEventListener('install', (e) => { | ||
console.log('[Service Worker] Install'); | ||
self.skipWaiting(); | ||
e.waitUntil((async () => { | ||
const cacheNames = await caches.keys(); | ||
for (const cacheName of cacheNames) { | ||
if (cacheName.startsWith(appName) && cacheName !== appCacheName) { | ||
console.log(`[Service Worker] Delete old cache ${cacheName}`); | ||
caches.delete(cacheName); | ||
} | ||
} | ||
const cache = await caches.open(appCacheName); | ||
if (preCacheFiles.length) { | ||
console.log('[Service Worker] Precaching '); | ||
} | ||
preCacheFiles.forEach(async (cacheFile) => { | ||
const request = new Request(cacheFile); | ||
const response = await fetch(request); | ||
if (response.ok || response.type == 'opaque') { | ||
cache.put(request, response); | ||
} | ||
}) | ||
})()); | ||
}); | ||
|
||
self.addEventListener('activate', (event) => { | ||
console.log('[Service Worker] Activating'); | ||
return self.clients.claim(); | ||
}); | ||
|
||
self.addEventListener('fetch', (e) => { | ||
if (e.request.method !== 'GET') { | ||
return | ||
} | ||
e.respondWith((async () => { | ||
const cache = await caches.open(appCacheName); | ||
let response = await cache.match(e.request); | ||
console.log(`[Service Worker] Fetching resource: ${e.request.url}`); | ||
if (response) { | ||
return response; | ||
} | ||
response = await fetch(e.request); | ||
if (!response.ok && !(response.type == 'opaque')) { | ||
throw Error(`[Service Worker] Fetching resource ${e.request.url} failed with response: ${response.status}`); | ||
} | ||
console.log(`[Service Worker] Caching new resource: ${e.request.url}`); | ||
cache.put(e.request, response.clone()); | ||
return response; | ||
})()); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
_sphinx_design_static/design-style.1e8bd061cd6da7fc9cf755528e8ffc24.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
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,27 @@ | ||
var sd_labels_by_text = {}; | ||
|
||
function ready() { | ||
const li = document.getElementsByClassName("sd-tab-label"); | ||
for (const label of li) { | ||
syncId = label.getAttribute("data-sync-id"); | ||
if (syncId) { | ||
label.onclick = onLabelClick; | ||
if (!sd_labels_by_text[syncId]) { | ||
sd_labels_by_text[syncId] = []; | ||
} | ||
sd_labels_by_text[syncId].push(label); | ||
} | ||
} | ||
} | ||
|
||
function onLabelClick() { | ||
// Activate other inputs with the same sync id. | ||
syncId = this.getAttribute("data-sync-id"); | ||
for (label of sd_labels_by_text[syncId]) { | ||
if (label === this) continue; | ||
label.previousElementSibling.checked = true; | ||
} | ||
window.localStorage.setItem("sphinx-design-last-tab", syncId); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", ready, 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 |
---|---|---|
@@ -0,0 +1,218 @@ | ||
importScripts("https://cdn.jsdelivr.net/pyodide/v0.23.1/full/pyodide.js"); | ||
|
||
const QUEUE = []; | ||
|
||
const REQUIRES = {} | ||
|
||
function sendPatch(patch, buffers, cell_id) { | ||
self.postMessage({ | ||
type: 'patch', | ||
patch: patch, | ||
buffers: buffers, | ||
id: cell_id | ||
}) | ||
} | ||
|
||
function sendStdout(cell_id, stdout) { | ||
self.postMessage({ | ||
type: 'stdout', | ||
content: stdout, | ||
id: cell_id | ||
}) | ||
} | ||
function sendStderr(cell_id, stderr) { | ||
self.postMessage({ | ||
type: 'stderr', | ||
content: stderr, | ||
id: cell_id | ||
}) | ||
} | ||
|
||
async function loadApplication(cell_id, path) { | ||
console.log("Loading pyodide!"); | ||
self.pyodide = await loadPyodide(); | ||
self.pyodide.globals.set("sendPatch", sendPatch); | ||
self.pyodide.globals.set("sendStdout", sendStdout); | ||
self.pyodide.globals.set("sendStderr", sendStderr); | ||
console.log("Loaded!"); | ||
await self.pyodide.loadPackage("micropip"); | ||
const packages = ['https://cdn.holoviz.org/panel/1.3.1/dist/wheels/bokeh-3.3.0-py3-none-any.whl', 'https://cdn.holoviz.org/panel/1.3.1/dist/wheels/panel-1.3.1-py3-none-any.whl', 'lumen==0.6.0', 'requests', 'pandas', 'pyodide-http', 'holoviews>=1.15.1']; | ||
if (path != null) { | ||
for (const key of Object.keys(REQUIRES)) { | ||
if (path.replace('.html', '').endsWith(key.replace('.md', ''))) { | ||
for (const req of REQUIRES[key]) { | ||
packages.push(req) | ||
} | ||
} | ||
} | ||
} | ||
|
||
await self.pyodide.runPythonAsync("") | ||
self.pyodide.runPython("import micropip") | ||
for (const pkg of packages) { | ||
self.postMessage({ | ||
type: 'loading', | ||
msg: `Loading ${pkg}`, | ||
id: cell_id | ||
}); | ||
await self.pyodide.runPythonAsync(` | ||
await micropip.install('${pkg}', keep_going=True); | ||
`); | ||
} | ||
console.log("Packages loaded!"); | ||
} | ||
|
||
const autodetect_deps_code = ` | ||
import json | ||
from panel.io.mime_render import find_imports | ||
json.dumps(find_imports(msg.to_py()['code']))` | ||
|
||
const exec_code = ` | ||
from functools import partial | ||
from panel.io.pyodide import pyrender | ||
from js import console | ||
msg = msg.to_py() | ||
code = msg['code'] | ||
stdout_cb = partial(sendStdout, msg['id']) | ||
stderr_cb = partial(sendStderr, msg['id']) | ||
target = f"output-{msg['id']}" | ||
pyrender(code, stdout_cb, stderr_cb, target)` | ||
|
||
const onload_code = ` | ||
msg = msg.to_py() | ||
if msg['mime'] == 'application/bokeh': | ||
from panel.io.pyodide import _link_docs_worker | ||
from panel.io.state import state | ||
doc = state.cache[f"output-{msg['id']}"] | ||
_link_docs_worker(doc, sendPatch, msg['id'], 'js')` | ||
|
||
const patch_code = ` | ||
import json | ||
from panel import state | ||
msg = msg.to_py() | ||
doc = state.cache[f"output-{msg['id']}"] | ||
doc.apply_json_patch(msg['patch'], setter='js')` | ||
|
||
const MESSAGES = { | ||
patch: patch_code, | ||
execute: exec_code, | ||
rendered: onload_code | ||
} | ||
|
||
self.onmessage = async (event) => { | ||
let resolveExecution, rejectExecution; | ||
const executing = new Promise(function(resolve, reject){ | ||
resolveExecution = resolve; | ||
rejectExecution = reject; | ||
}); | ||
|
||
const prev_msg = QUEUE[0] | ||
const msg = {...event.data, executing} | ||
QUEUE.unshift(msg) | ||
|
||
if (prev_msg) { | ||
self.postMessage({ | ||
type: 'loading', | ||
msg: 'Awaiting previous cells', | ||
id: msg.id | ||
}); | ||
await prev_msg.executing | ||
} | ||
|
||
// Init pyodide | ||
if (self.pyodide == null) { | ||
self.postMessage({ | ||
type: 'loading', | ||
msg: 'Loading pyodide', | ||
id: msg.id | ||
}); | ||
await loadApplication(msg.id, msg.path) | ||
self.postMessage({ | ||
type: 'loaded', | ||
id: msg.id | ||
}); | ||
} | ||
|
||
// Handle message | ||
if (!MESSAGES.hasOwnProperty(msg.type)) { | ||
console.warn(`Service worker received unknown message type '${msg.type}'.`) | ||
resolveExecution() | ||
self.postMessage({ | ||
type: 'idle', | ||
id: msg.id | ||
}); | ||
return | ||
} | ||
|
||
if (msg.type === 'execute') { | ||
let deps | ||
try { | ||
self.pyodide.globals.set('msg', msg) | ||
deps = self.pyodide.runPython(autodetect_deps_code) | ||
} catch(e) { | ||
deps = '[]' | ||
console.warn(`Auto-detection of dependencies failed with error: ${e}`) | ||
} | ||
for (const pkg of JSON.parse(deps)) { | ||
self.postMessage({ | ||
type: 'loading', | ||
msg: `Loading ${pkg}`, | ||
id: msg.id | ||
}); | ||
try { | ||
await self.pyodide.runPythonAsync(`await micropip.install('${pkg}', keep_going=True)`) | ||
} catch(e) { | ||
console.log(`Auto-detected dependency ${pkg} could not be installed.`) | ||
} | ||
} | ||
} | ||
|
||
try { | ||
self.pyodide.globals.set('msg', msg) | ||
let out = await self.pyodide.runPythonAsync(MESSAGES[msg.type]) | ||
resolveExecution() | ||
if (out == null) { | ||
out = new Map() | ||
} | ||
if (out.has('content')) { | ||
self.postMessage({ | ||
type: 'render', | ||
id: msg.id, | ||
content: out.get('content'), | ||
mime: out.get('mime_type') | ||
}); | ||
} | ||
if (out.has('stdout') && out.get('stdout').length) { | ||
self.postMessage({ | ||
type: 'stdout', | ||
content: out.get('stdout'), | ||
id: msg.id | ||
}); | ||
} | ||
if (out.has('stderr') && out.get('stderr').length) { | ||
self.postMessage({ | ||
type: 'stderr', | ||
content: out.get('stderr'), | ||
id: msg.id | ||
}); | ||
} | ||
self.postMessage({ | ||
type: 'idle', | ||
id: msg.id, | ||
uuid: msg.uuid | ||
}); | ||
} catch (e) { | ||
const traceback = `${e}` | ||
const tblines = traceback.split('\n') | ||
self.postMessage({ | ||
type: 'error', | ||
traceback: traceback, | ||
msg: tblines[tblines.length-2], | ||
id: msg.id | ||
}); | ||
resolveExecution() | ||
throw(e) | ||
} | ||
} |
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,14 @@ | ||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register(DOCUMENTATION_OPTIONS.URL_ROOT + 'PyodideServiceWorker.js').then(reg => { | ||
reg.onupdatefound = () => { | ||
const installingWorker = reg.installing; | ||
installingWorker.onstatechange = () => { | ||
if (installingWorker.state === 'installed' && | ||
navigator.serviceWorker.controller) { | ||
// Reload page if service worker is replaced | ||
location.reload(); | ||
} | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.