Repository navigation
Fix multi-fact queries on PostgreSQL and ORDER BY position #2540
Workflow file for this run
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
| name: Pyodide Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| test-pyodide: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install uv | |
| id: uv | |
| uses: ./.github/actions/setup-uv | |
| with: | |
| enable-cache: true | |
| suffix: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index || 0 }} | |
| - name: Build sidemantic wheel | |
| run: uv build | |
| - name: Inspect wheel metadata | |
| run: | | |
| python - <<'PY' | |
| import re | |
| from email.parser import Parser | |
| from pathlib import Path | |
| from zipfile import ZipFile | |
| wheel = next(Path("dist").glob("*.whl")) | |
| with ZipFile(wheel) as archive: | |
| metadata_name = next(name for name in archive.namelist() if name.endswith(".dist-info/METADATA")) | |
| metadata = Parser().parsestr(archive.read(metadata_name).decode()) | |
| print(metadata) | |
| requires = metadata.get_all("Requires-Dist", []) | |
| extras = set(metadata.get_all("Provides-Extra", [])) | |
| heavy_optional = ("textual", "pyarrow", "mcp", "riffq", "altair", "vl-convert-python", "sidemantic-dax") | |
| for requirement in requires: | |
| name = re.split(r"[<>=!~;\[ ]", requirement.strip(), maxsplit=1)[0] | |
| if name in heavy_optional: | |
| assert "extra ==" in requirement, requirement | |
| assert "serve" in extras | |
| assert "workbench" in extras | |
| PY | |
| - name: Install Pyodide and dependencies | |
| run: npm install pyodide glob | |
| - name: Test sidemantic in Pyodide | |
| run: | | |
| cat > test_pyodide.mjs << 'EOF' | |
| import { loadPyodide } from 'pyodide'; | |
| import { readFileSync } from 'fs'; | |
| import { globSync } from 'glob'; | |
| async function main() { | |
| const pyodide = await loadPyodide(); | |
| console.log('Loading Pyodide packages (pydantic has compatible typing-extensions)...'); | |
| await pyodide.loadPackage(['micropip', 'pydantic', 'pyyaml', 'jinja2']); | |
| // Find the built wheel | |
| const wheels = globSync('dist/*.whl'); | |
| if (wheels.length === 0) { | |
| throw new Error('No wheel file found in dist/'); | |
| } | |
| const wheelPath = wheels[0]; | |
| console.log(`Installing local wheel: ${wheelPath}`); | |
| // Load wheel into Pyodide virtual filesystem | |
| const wheelData = readFileSync(wheelPath); | |
| const wheelName = wheelPath.split('/').pop(); | |
| pyodide.FS.writeFile(`/tmp/${wheelName}`, wheelData); | |
| console.log('Installing sidemantic with the documented Pyodide no-deps path...'); | |
| await pyodide.runPythonAsync(` | |
| import micropip | |
| # Install missing pure-Python deps | |
| await micropip.install(['sqlglot', 'lkml', 'inflect'], deps=False) | |
| # Install sidemantic from local wheel without deps | |
| await micropip.install('emfs:/tmp/` + wheelName + `', deps=False) | |
| `); | |
| console.log('Testing basic imports...'); | |
| await pyodide.runPythonAsync(` | |
| from sidemantic import Model, Dimension, Metric, Relationship, SemanticLayer | |
| from sidemantic.core.semantic_graph import SemanticGraph | |
| from sidemantic.loaders import load_from_directory | |
| print('✓ Core imports successful') | |
| # Test creating a model (doesn't need duckdb) | |
| model = Model( | |
| name="test", | |
| table="test_table", | |
| primary_key="id", | |
| dimensions=[ | |
| Dimension(name="name", type="categorical", sql="name") | |
| ], | |
| metrics=[ | |
| Metric(name="count", agg="count") | |
| ], | |
| relationships=[ | |
| Relationship(name="other", type="many_to_one", foreign_key="other_id") | |
| ] | |
| ) | |
| print('✓ Model creation successful') | |
| # Test semantic graph (doesn't need duckdb) | |
| graph = SemanticGraph() | |
| graph.add_model(model) | |
| print('✓ SemanticGraph successful') | |
| layer = SemanticLayer() | |
| layer.graph.add_model(model) | |
| assert callable(load_from_directory) | |
| print('✓ SemanticLayer and loader imports successful') | |
| print('All Pyodide imports and basic operations work!') | |
| `); | |
| } | |
| main().catch(err => { | |
| console.error(err); | |
| process.exit(1); | |
| }); | |
| EOF | |
| node test_pyodide.mjs | |
| - name: Save completed build caches | |
| if: ${{ !cancelled() }} | |
| uses: ./.github/actions/save-build-caches | |
| with: | |
| uv-key: ${{ steps.uv.outputs.cache-key }} |