Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Thanks for your interest in contributing!

- Development setup:
- Node 20+ and Python 3.12+
- Node 20+ and Python 3.10+ (CI tests 3.10, 3.11, 3.12)
- npm ci
- npm run check:all
- Common tasks:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ You can cap payload sizes with `TYWRAP_CODEC_MAX_BYTES` (responses) and `TYWRAP_
```typescript
import { PyodideBridge } from 'tywrap/pyodide';
const bridge = new PyodideBridge({
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/'
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.28.0/full/'
});
await bridge.init();
```
Expand Down
8 changes: 0 additions & 8 deletions ROADMAP.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default defineConfig({
{
"runtime": {
"pyodide": {
"indexURL": "https://cdn.jsdelivr.net/pyodide/",
"indexURL": "https://cdn.jsdelivr.net/pyodide/v0.28.0/full/",
"packages": ["numpy", "scipy", "matplotlib"]
}
}
Expand Down Expand Up @@ -266,8 +266,6 @@ Use presets to opt into richer mappings for common ecosystems.
}
```

### Development Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `hotReload` | `boolean` | `false` | Enable hot reloading |
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async function demo() {
},
"runtime": {
"pyodide": {
"indexURL": "https://cdn.jsdelivr.net/pyodide/",
"indexURL": "https://cdn.jsdelivr.net/pyodide/v0.28.0/full/",
"packages": ["numpy", "scipy"]
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/runtimes/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ npm install tywrap pyodide
},
"runtime": {
"pyodide": {
"indexURL": "https://cdn.jsdelivr.net/pyodide/",
"indexURL": "https://cdn.jsdelivr.net/pyodide/v0.28.0/full/",
"packages": ["numpy", "matplotlib", "scipy"]
}
}
Expand All @@ -39,7 +39,7 @@ import { setRuntimeBridge } from 'tywrap/runtime';
import { array } from './generated/numpy.generated.js';

const bridge = new PyodideBridge({
indexURL: 'https://cdn.jsdelivr.net/pyodide/',
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.28.0/full/',
packages: ['numpy']
});

Expand Down
30 changes: 28 additions & 2 deletions docs/type-mapping-matrix.md
Copy link
Owner Author

Choose a reason for hiding this comment

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

TODO in future PR: automate generation of this file.

Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,33 @@ Enable presets via `types.presets` in your config to opt into additional mapping

| Python Type | TypeScript Type | Notes |
|-------------|----------------|-------|
| `torch.Tensor` | `{ data: unknown, shape: number[], dtype?: string, device?: string }` | Tensor metadata + decoded data |
| `torch.Tensor` | Nested ndarray envelope with tensor metadata | See structure below |

Torch tensors are wrapped in a special envelope containing an ndarray:
```typescript
{
__tywrap__: 'torch.tensor',
encoding: 'ndarray',
value: {
__tywrap__: 'ndarray',
encoding: 'json' | 'arrow',
value: number[] | Uint8Array,
shape: number[],
dtype: string
},
device: string // e.g., 'cpu'
}
```

### pydantic preset

| Python Type | TypeScript Type | Notes |
|-------------|----------------|-------|
| `pydantic.BaseModel` | Serialized dict | Via `model_dump(by_alias=True, mode='json')` |
| Fields with aliases | Uses alias name | `by_alias=True` default |

Pydantic v2 models are serialized using `model_dump()` with `by_alias=True` and `mode='json'`
to ensure JSON-safe output. Nested models are recursively serialized.

### sklearn preset

Expand Down Expand Up @@ -322,4 +348,4 @@ Planned improvements to the type mapping system:

---

*This document is automatically updated as the type mapping system evolves. Last updated: 2024.*
*Last updated: January 2026.*
2 changes: 1 addition & 1 deletion src/runtime/pyodide-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface PyodideInstance {
// =============================================================================

/** Default Pyodide CDN URL */
const DEFAULT_INDEX_URL = 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/';
const DEFAULT_INDEX_URL = 'https://cdn.jsdelivr.net/pyodide/v0.28.0/full/';

/**
* Bootstrap Python code that sets up the dispatch function.
Expand Down
4 changes: 2 additions & 2 deletions test/runtime_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Runtime Configuration', () => {
const indexURL = (transport as any).indexURL;
const packages = (transport as any).packages;

expect(indexURL).toBe('https://cdn.jsdelivr.net/pyodide/v0.24.1/full/');
expect(indexURL).toBe('https://cdn.jsdelivr.net/pyodide/v0.28.0/full/');
expect(packages).toEqual([]);
});

Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Runtime Configuration', () => {
it('should validate CDN URLs', () => {
const validURLs = [
'https://cdn.jsdelivr.net/pyodide/',
'https://unpkg.com/pyodide@0.24.1/',
'https://unpkg.com/pyodide@0.28.0/',
'https://custom-cdn.example.com/pyodide/',
'http://localhost:8080/pyodide/', // For development
];
Expand Down
8 changes: 4 additions & 4 deletions test/runtime_pyodide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('Pyodide Runtime Bridge', () => {
const result = await bridge.call('math', 'sqrt', [16]);
expect(result).toBe(4);
expect(mockLoadPyodide).toHaveBeenCalledWith({
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/',
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.28.0/full/',
});
});

Expand All @@ -133,7 +133,7 @@ describe('Pyodide Runtime Bridge', () => {
it('should initialize with pre-loaded packages', async () => {
const packages = ['numpy', 'pandas'];
bridge = new PyodideBridge({
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/',
indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.28.0/full/',
packages,
});

Expand Down Expand Up @@ -675,8 +675,8 @@ describe('Pyodide Runtime Bridge', () => {
describe('CDN and Loading Configurations', () => {
it('should handle different CDN URLs', async () => {
const customCDNs = [
'https://cdn.jsdelivr.net/pyodide/v0.24.1/',
'https://unpkg.com/pyodide@0.24.1/',
'https://cdn.jsdelivr.net/pyodide/v0.28.0/',
'https://unpkg.com/pyodide@0.28.0/',
'https://custom-cdn.example.com/pyodide/',
];

Expand Down
Loading