Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Fix pyodide runner (#106)
Browse files Browse the repository at this point in the history
* Install pydantic separately

* Install earlier

* Underscore

* Update pyodite

* Install pinned pydantic

* Remove pin

* Pin

* Lower Pydantic pin

* Add pygments

* Fix multiqc.run

* Import ClConfig

* Suppress warning

* Better comments

* Remove warning supresion in favour of MultiQC update

* No version check

* Clean up
  • Loading branch information
vladsavelyev authored Sep 13, 2024
1 parent 8bf7160 commit 1b2deb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
11 changes: 8 additions & 3 deletions public/run_deps/pyodideWorker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
importScripts("https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js");
importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js");

async function loadAndRunPython() {
self.pyodide = await loadPyodide();
Expand All @@ -9,6 +9,11 @@ async function loadAndRunPython() {
console.log("colormath installed successfully");
await micropip.install("/run_deps/spectra-0.0.11-py3-none-any.whl");
console.log("spectra installed successfully");
await micropip.install("pygments"); // for some reason it needs to be installed separately
console.log("pygments installed successfully");
// MultiQC pins 2.7.1, and Pyodide only has 2.7.0, so we need to override here:
await micropip.install("pydantic==2.7.*"); // pyodide only has 2.7.0, not 2.7.1
console.log("pydantic installed successfully");

// Now we want to install multiqc with all other dependencies _except_ kaleido,
// which is not needed for the browser-based setup, and it doesn't have
Expand All @@ -17,14 +22,14 @@ async function loadAndRunPython() {
const response = await fetch(`https://pypi.org/pypi/multiqc/json`);
const packageData = await response.json();
let dependencies = packageData.info["requires_dist"];
// And excluding 'kaleido' (and 'Pillow', also needed only for flat plot export)
dependencies = dependencies.filter(dep => !dep.includes("kaleido") && !dep.includes("Pillow"));
// Removing all "extras" dependencies:
dependencies = dependencies.filter(dep => !dep.includes("; extra =="));
// Removing any other possible environment markers:
dependencies = dependencies.map(dep => dep.split(";")[0].trim());
// And installing the remaining dependencies one by one:
for (const dep of dependencies) {
if (dep.includes("pydantic")) continue // pydantic was already installed above
if (dep.includes("kaleido") || dep.includes("Pillow")) continue // only needed only for the flat plot export
console.log("Installing " + dep);
await micropip.install(dep);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/run/Runner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
pyodideWorker.postMessage({
code: `
import multiqc
multiqc.run('/data', no_ansi=True, force=True)
from multiqc.core.update_config import ClConfig
multiqc.run('/data', cfg=ClConfig(no_ansi=True, no_version_check=True, force=True))
`,
});
}
Expand All @@ -55,7 +56,7 @@ multiqc.run('/data', no_ansi=True, force=True)
function clean_stdout(line: string) {
line = line.replace(
/^ \/\/\/ MultiQC 🔍 (.+)/,
'\n<span class="slashes">///</span> <a href="https://multiqc.info/" target="_blank" >MultiQC</a> 🔍 <span>$1</span>\n'
'\n<span class="slashes">///</span> <a href="https://multiqc.info/" target="_blank" >MultiQC</a> 🔍 <span>$1</span>\n',
);
line = line.replace(/^(\| +.+ \|)/, "<span>$1</span>");
return line;
Expand Down
2 changes: 1 addition & 1 deletion src/multiqc_releases.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"latest":"v1.23","latest_published_at":"2024-07-09T18:04:00Z"}
{"latest":"v1.24.1","latest_published_at":"2024-08-21T11:27:14Z"}

0 comments on commit 1b2deb6

Please sign in to comment.