Skip to content

Feat/wasm catalogue#77

Open
mathleur wants to merge 4 commits intofeat/rust_stac_cataloguefrom
feat/wasm_catalogue
Open

Feat/wasm catalogue#77
mathleur wants to merge 4 commits intofeat/rust_stac_cataloguefrom
feat/wasm_catalogue

Conversation

@mathleur
Copy link
Member

Description

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a client-side Rust/WebAssembly (WASM) implementation of the STAC catalogue traversal logic, and updates the web UI flow to support a “region selection” step at the end of catalogue navigation.

Changes:

  • Introduce a new qubed_wasm crate (wasm-bindgen) that implements STAC-like responses in the browser.
  • Add a WASM bootstrapper (catalogue_wasm.js) and wire it into the browse page, updating app.js to prefer WASM when available.
  • Restructure the region-selection UI into a step-based flow shown after catalogue traversal completes.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
stac_server/templates/index.html Adds WASM status badge, moves region-selection UI into main step flow, loads the WASM bootstrapper module.
stac_server/static/catalogue_wasm.js Loads/initializes the WASM module, fetches arena JSON + language metadata, exposes window.__wasmCatalogue.
stac_server/static/app.js Uses WASM catalogue when available; introduces region-selection step and defers viewer start to the WASM bootstrapper.
stac_server/main.py Adds endpoints to support WASM data/language loading; changes/omits several prior API endpoints.
qubed_wasm/src/lib.rs Implements browser-side STAC traversal and response construction in Rust, exported via wasm-bindgen.
qubed_wasm/build.sh Adds a wasm-pack build script to emit the web bundle into stac_server/static/wasm.
qubed_wasm/Cargo.toml New crate manifest for the WASM package.
qubed/src/qube.rs Adds leaf_dimensions() helper used by the WASM traversal logic.
qubed/Cargo.toml Makes rayon optional for wasm compatibility.
Cargo.toml Adds qubed_wasm to the workspace members.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +55
// 2. Ask the server which data files to load
const metaResp = await fetch("/api/v2/data_files");
if (!metaResp.ok) {
console.warn("[wasm] /api/v2/data_files returned", metaResp.status, "— falling back to server-side STAC");
return;
}
const dataFiles = await metaResp.json(); // array of URL strings
console.log("[wasm] Data files:", dataFiles);

// 3. Load each data file into the catalogue
let first = true;
for (const url of dataFiles) {
const resp = await fetch(url);
if (!resp.ok) {
console.warn(`[wasm] Could not fetch ${url} (${resp.status}) – skipping`);
continue;
}
// The arena JSON endpoint returns a parsed JSON object; wasm expects a string
const arenaJson = await resp.text();
if (first) {
catalogue.load(arenaJson);
first = false;
} else {
catalogue.append(arenaJson);
}
console.log(`[wasm] Loaded ${url}`);
}

if (catalogue.is_empty()) {
console.warn("[wasm] Catalogue empty after loading — falling back to server-side STAC");
return;
}
Comment on lines +15 to +19
import init, { WasmCatalogue } from "/static/wasm/qubed_wasm.js";

async function initWasm() {
try {
// 1. Initialise the WASM binary
Comment on lines +163 to 167
# ---------------------------------------------------------------------------
# Admin endpoint – push new/updated data into the running catalogue
# ---------------------------------------------------------------------------

@app.post("/api/v2/polytope/query")
Comment on lines +150 to +152
data_path = prefix / file_path
if not data_path.exists():
raise HTTPException(status_code=404, detail=f"Data file {file_path} not found")
):
global qube
qube.append(PyQube.from_arena_json(json.dumps(body_json)))
return {"nodes": len(qube)}
@@ -410,352 +353,42 @@ async def select(
return qube.select(request).to_json()


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants