Skip to content

Commit b7211bf

Browse files
committed
Merge remote-tracking branch 'origin/main' into coding-agents-in-sandbox
2 parents 3a5d52a + 3ff646c commit b7211bf

46 files changed

Lines changed: 6760 additions & 7 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test SDK Reference Generator
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "sdk-reference-generator/**"
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "20"
20+
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9
25+
26+
- name: Install dependencies
27+
working-directory: sdk-reference-generator
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Run tests
31+
working-directory: sdk-reference-generator
32+
run: pnpm test
33+
34+
- name: TypeScript check
35+
working-directory: sdk-reference-generator
36+
run: npx tsc --noEmit
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Sync SDK Reference Documentation
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
sdk:
7+
description: "SDK to generate (see sdks.config.ts for available SDKs, or use 'all')"
8+
required: true
9+
default: "all"
10+
type: string
11+
version:
12+
description: "Version to generate (all, latest, or specific like v2.9.0)"
13+
required: true
14+
default: "latest"
15+
type: string
16+
limit:
17+
description: "Limit number of versions to generate (default: 5)"
18+
required: false
19+
default: 5
20+
type: number
21+
force:
22+
description: "Force regeneration of existing versions"
23+
required: false
24+
default: false
25+
type: boolean
26+
27+
repository_dispatch:
28+
types: [sdk-release]
29+
30+
# prevent concurrent runs that could conflict
31+
concurrency:
32+
group: sdk-reference-${{ github.ref }}
33+
cancel-in-progress: false
34+
35+
jobs:
36+
generate:
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 30
39+
permissions:
40+
contents: write
41+
42+
steps:
43+
- name: Checkout docs repo
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
53+
- name: Install pnpm
54+
uses: pnpm/action-setup@v4
55+
with:
56+
version: 9
57+
58+
- name: Cache pnpm dependencies
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
~/.pnpm-store
63+
sdk-reference-generator/node_modules
64+
key: ${{ runner.os }}-pnpm-${{ hashFiles('sdk-reference-generator/pnpm-lock.yaml') }}
65+
restore-keys: |
66+
${{ runner.os }}-pnpm-
67+
68+
- name: Setup Python
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: "3.11"
72+
cache: "pip"
73+
74+
- name: Install generator dependencies
75+
working-directory: sdk-reference-generator
76+
run: pnpm install --frozen-lockfile
77+
78+
- name: Install Python dependencies
79+
run: pip install -r requirements.txt
80+
81+
- name: Determine SDK and Version
82+
id: params
83+
env:
84+
EVENT_NAME: ${{ github.event_name }}
85+
INPUT_SDK: ${{ github.event.inputs.sdk }}
86+
INPUT_VERSION: ${{ github.event.inputs.version }}
87+
INPUT_LIMIT: ${{ github.event.inputs.limit }}
88+
INPUT_FORCE: ${{ github.event.inputs.force }}
89+
PAYLOAD_SDK: ${{ github.event.client_payload.sdk }}
90+
PAYLOAD_VERSION: ${{ github.event.client_payload.version }}
91+
PAYLOAD_LIMIT: ${{ github.event.client_payload.limit }}
92+
run: |
93+
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
94+
SDK="$INPUT_SDK"
95+
VERSION="$INPUT_VERSION"
96+
LIMIT="$INPUT_LIMIT"
97+
FORCE="$INPUT_FORCE"
98+
elif [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
99+
SDK="$PAYLOAD_SDK"
100+
VERSION="${PAYLOAD_VERSION:-latest}"
101+
LIMIT="${PAYLOAD_LIMIT:-5}"
102+
FORCE="false"
103+
fi
104+
105+
echo "sdk=${SDK:-all}" >> $GITHUB_OUTPUT
106+
echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
107+
echo "limit=${LIMIT:-5}" >> $GITHUB_OUTPUT
108+
echo "force=${FORCE:-false}" >> $GITHUB_OUTPUT
109+
110+
- name: Generate SDK Reference
111+
working-directory: sdk-reference-generator
112+
env:
113+
SDK_NAME: ${{ steps.params.outputs.sdk }}
114+
SDK_VERSION: ${{ steps.params.outputs.version }}
115+
LIMIT: ${{ steps.params.outputs.limit }}
116+
FORCE: ${{ steps.params.outputs.force }}
117+
FORCE_COLOR: "2"
118+
run: |
119+
ARGS="--sdk $SDK_NAME --version $SDK_VERSION"
120+
121+
if [[ -n "$LIMIT" && "$LIMIT" != "0" ]]; then
122+
ARGS="$ARGS --limit $LIMIT"
123+
fi
124+
125+
if [[ "$FORCE" == "true" ]]; then
126+
ARGS="$ARGS --force"
127+
fi
128+
129+
pnpm run generate $ARGS
130+
131+
- name: Commit and push changes
132+
id: commit
133+
env:
134+
SDK_NAME: ${{ steps.params.outputs.sdk }}
135+
SDK_VERSION: ${{ steps.params.outputs.version }}
136+
run: |
137+
git config user.name "github-actions[bot]"
138+
git config user.email "github-actions[bot]@users.noreply.github.com"
139+
140+
git add docs/sdk-reference/
141+
git add docs.json
142+
143+
if git diff --staged --quiet; then
144+
echo "No changes to commit"
145+
echo "changes=false" >> $GITHUB_OUTPUT
146+
else
147+
git commit -m "docs: update SDK reference for $SDK_NAME $SDK_VERSION"
148+
git push
149+
echo "changes=true" >> $GITHUB_OUTPUT
150+
fi
151+
152+
- name: Summary
153+
env:
154+
SDK_NAME: ${{ steps.params.outputs.sdk }}
155+
SDK_VERSION: ${{ steps.params.outputs.version }}
156+
LIMIT: ${{ steps.params.outputs.limit }}
157+
CHANGES: ${{ steps.commit.outputs.changes }}
158+
run: |
159+
echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
160+
echo "" >> $GITHUB_STEP_SUMMARY
161+
echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
162+
echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
163+
echo "| SDK | $SDK_NAME |" >> $GITHUB_STEP_SUMMARY
164+
echo "| Version | $SDK_VERSION |" >> $GITHUB_STEP_SUMMARY
165+
echo "| Limit | ${LIMIT:-No limit} |" >> $GITHUB_STEP_SUMMARY
166+
echo "| Changes committed | $CHANGES |" >> $GITHUB_STEP_SUMMARY
167+
echo "" >> $GITHUB_STEP_SUMMARY
168+
169+
if [[ "$CHANGES" == "true" ]]; then
170+
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
171+
echo '```' >> $GITHUB_STEP_SUMMARY
172+
echo "Total MDX files: $(find docs/sdk-reference -type f -name '*.mdx' | wc -l)" >> $GITHUB_STEP_SUMMARY
173+
echo '```' >> $GITHUB_STEP_SUMMARY
174+
fi

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
.idea
22
.DS_Store
3+
4+
node_modules
5+
6+
# Generated SDK navigation (intermediate file)
7+
sdk_navigation.json

.mintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sdk-reference-generator/
2+
3+
scripts/

docs.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,9 @@
210210
{
211211
"group": "Troubleshooting",
212212
"pages": [
213-
{
214-
"group": "Templates",
215-
"pages": [
216-
"docs/troubleshooting/templates/build-authentication-error",
217-
"docs/troubleshooting/templates/49999-port-not-open"
218-
]
219-
}
213+
"docs/troubleshooting/templates/build-authentication-error",
214+
"docs/troubleshooting/templates/49999-port-not-open",
215+
"docs/troubleshooting/pip-install-error"
220216
]
221217
}
222218
]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: "pip install fails during template build"
3+
sidebarTitle: pip install fails during template build
4+
---
5+
6+
When building a template that installs large Python packages like PyTorch with CUDA dependencies, `pip install` can fail with one of two errors:
7+
8+
- **`MemoryError`** — pip tries to serialize large wheel files into memory for caching, exceeding available RAM.
9+
- **`OSError: [Errno 28] No space left on device`** — downloaded wheels fill up the `/tmp` directory.
10+
11+
**Example errors**
12+
13+
```txt
14+
File "pip/_vendor/cachecontrol/serialize.py", line 70, in dumps
15+
return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
16+
MemoryError
17+
```
18+
19+
```txt
20+
ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device
21+
```
22+
23+
## Cause
24+
25+
The build environment mounts `/tmp` as a [tmpfs](https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html) — a RAM-backed filesystem capped at ~3.9 GB. pip downloads all wheels to `/tmp/pip-*` before installing them. PyTorch with CUDA dependencies totals ~4.1 GB of downloads, which exceeds this limit.
26+
27+
## Solution 1: Redirect pip's temp directory to disk (recommended)
28+
29+
Set the `TMPDIR` environment variable to a disk-backed path so pip downloads don't go through the RAM-backed `/tmp`. Combined with `--no-cache-dir`, this avoids both the disk space and memory issues.
30+
31+
<CodeGroup>
32+
```typescript JavaScript & TypeScript
33+
const template = Template()
34+
.runCmd('TMPDIR=/var/tmp pip install --no-cache-dir torch sentence-transformers')
35+
```
36+
```python Python
37+
template = (
38+
Template()
39+
.run_cmd("TMPDIR=/var/tmp pip install --no-cache-dir torch sentence-transformers")
40+
)
41+
```
42+
</CodeGroup>
43+
44+
## Solution 2: Install CPU-only PyTorch
45+
46+
E2B sandboxes don't have GPUs, so there's no reason to download CUDA dependencies. Installing the CPU-only variant of PyTorch reduces the download from ~4.1 GB to ~189 MB, avoiding the `/tmp` size limit entirely.
47+
48+
<CodeGroup>
49+
```typescript JavaScript & TypeScript
50+
const template = Template()
51+
.runCmd('pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu')
52+
.runCmd('echo "torch" > /tmp/constraints.txt && pip install --no-cache-dir -c /tmp/constraints.txt sentence-transformers')
53+
```
54+
```python Python
55+
template = (
56+
Template()
57+
.run_cmd("pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu")
58+
.run_cmd('echo "torch" > /tmp/constraints.txt && pip install --no-cache-dir -c /tmp/constraints.txt sentence-transformers')
59+
)
60+
```
61+
</CodeGroup>
62+
63+
The constraints file in the second step prevents pip from replacing the CPU-only torch with the CUDA version when installing packages that depend on PyTorch.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Python dependencies for SDK reference generation
2+
pydoc-markdown>=4.8.2
3+
poetry>=1.8.0
4+

scripts/generate-mcp-servers.sh

100644100755
File mode changed.

sdk-reference-generator/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
*.log
4+

0 commit comments

Comments
 (0)