Skip to content

Commit 76cd9d8

Browse files
committed
[WIP] Add async CI; Update interfaces; Handle timeout
1 parent e84824c commit 76cd9d8

24 files changed

Lines changed: 517 additions & 1278 deletions

js/example.mts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import dotenv from 'dotenv'
2+
3+
import { CodeInterpreter } from './dist'
4+
5+
dotenv.config()
6+
7+
const code = `
8+
import matplotlib.pyplot as plt
9+
import numpy as np
10+
11+
x = np.linspace(0, 20, 100)
12+
y = np.sin(x)
13+
14+
plt.plot(x, y)
15+
plt.show()
16+
17+
x = np.linspace(0, 10, 100)
18+
19+
plt.plot(x, y)
20+
plt.show()
21+
22+
import pandas
23+
pandas.DataFrame({"a": [1, 2, 3]})
24+
`
25+
26+
const sandbox = await CodeInterpreter.connect("", { debug: true })
27+
console.log(sandbox.sandboxID)
28+
29+
const execution = await sandbox.notebook.execCell(code, {
30+
onStdout(msg) {
31+
console.log('stdout', msg)
32+
},
33+
onStderr(msg) {
34+
console.log('stderr', msg)
35+
},
36+
})
37+
console.log(execution.results[0].formats())
38+
console.log(execution.results.length)

js/package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"@types/node": "^18.18.6",
3737
"@types/ws": "^8.5.10",
3838
"dotenv": "^16.4.5",
39-
"knip": "^5.23.2",
39+
"knip": "^5.25.1",
4040
"npm-check-updates": "^16.14.20",
4141
"tsup": "^8.1.0",
42-
"typescript": "^5.5.2",
43-
"vitest": "^1.6.0"
42+
"typescript": "^5.5.3",
43+
"vitest": "^2.0.1"
4444
},
4545
"files": [
4646
"dist",
@@ -61,18 +61,12 @@
6161
"vm"
6262
],
6363
"dependencies": {
64-
"e2b": "0.16.2-beta.17",
65-
"isomorphic-ws": "^5.0.0",
66-
"ws": "^8.17.1"
67-
},
68-
"optionalDependencies": {
69-
"bufferutil": "^4.0.8",
70-
"utf-8-validate": "^6.0.4"
64+
"e2b": "0.16.2-beta.17"
7165
},
7266
"engines": {
7367
"node": ">=18"
7468
},
7569
"browserslist": [
7670
"defaults"
7771
]
78-
}
72+
}

0 commit comments

Comments
 (0)