Bootstrap runner for Flywheel provisioned GPU instances
Project description
Bootstrap
This package hosts the BYOC bootstrapper that:
- Ensures Codex is available (prefers release tarball; skips install if already
on
PATH). - Fetches the bootstrap payload for a run from the Flywheel backend.
- Launches
codex execwith the provided prompt/config and streams logs. - Collects artifacts (manifest-on-exit) and reports completion or error back to the backend.
Configuration
Bootstrap reads the user's Codex config.toml (Codex schema). See:
- Codex config basics: https://developers.openai.com/codex/config-basic
- Codex config reference: https://developers.openai.com/codex/config-reference
Flywheel adds a small extension under [flywheel] and requires one of:
[flywheel]
# inline instructions (host-specific tips, paths, sandbox notes)
workspace_instructions = """
Use /mnt/work as your workspace. Write artifacts under ./artifacts.
"""
# or: reference a file (relative paths are resolved against the config file directory)
workspace_instructions_file = "workspace_notes.md"
Rules:
- At least one of
workspace_instructionsorworkspace_instructions_fileis required; otherwise bootstrap exits before contacting the server. - If both are set, the file wins and the inline value is ignored (warns once).
- File contents must be non-empty; the path is resolved relative to the config file if not absolute.
Bootstrap also reads a few optional Codex config fields because they affect workspace + sandbox behavior:
cd/workspace_dir(run working directory; defaults to~/.flywheel/runs/<run_id>)sandbox_modeand[sandbox_workspace_write].writable_roots
Prompt assembly written to flywheel_prompt.txt:
- Flywheel engineer context (logging/artifact expectations).
- Task Description (prompt fetched from the server).
- Workspace Instructions (resolved from config as above).
Full example config (recommended starting point):
Update the paths and instructions for your machine.
End-to-end flow (bootstrap.sh → Python bootstrapper)
-
User runs the bootstrapper on their BYOC machine:
BOOTSTRAP_PACKAGE="${FLYWHEEL_BOOTSTRAP_PACKAGE:-flywheel-bootstrap}" uvx --no-cache --from "$BOOTSTRAP_PACKAGE" flywheel-bootstrap \ --run-id <id> --token <token> --config /path/to/config.toml [--server <url>]
Optional: if you have this repo checked out, you can run
project/bootstrap/bootstrap.sh, which installsuvxif missing and then runs the same command. It defaultsFLYWHEEL_BOOTSTRAP_PACKAGEto the localproject/bootstrappath. -
Python entrypoint (
python -m bootstrap):- Parses args/env: requires run id + token, required
--config, optional--server(defaulthttp://localhost:8000). - Loads Codex config.toml, enforces presence of workspace instructions (inline or file), extracts workspace/sandbox settings.
- Parses args/env: requires run id + token, required
-
Workspace resolution:
- Uses
cd/workspace_dirfrom config if set; otherwise~/.flywheel/runs/<run_id>. - Creates the workspace and validates the artifact manifest path is inside sandbox
writable_rootswhen sandboxing is enabled; else exits with an error.
- Uses
-
Codex availability:
- If
BOOTSTRAP_MOCK_CODEXis set, skips install and runs a mock flow. - Else, if
codexis already on PATH, reuse it; otherwise download the Codex release tarball to the workspace/run root and mark it executable.
- If
-
Fetch bootstrap payload:
GET <server>/runs/<run_id>/bootstrapwithX-Run-Token; payload contains the task prompt.
-
Build prompt file:
- Combine base Flywheel engineer context, “Task Description” (server prompt), and “Workspace Instructions” (user config) into
flywheel_prompt.txtin the workspace.
- Combine base Flywheel engineer context, “Task Description” (server prompt), and “Workspace Instructions” (user config) into
-
Launch Codex:
- Run
codex exec --json --cd <workspace> --skip-git-repo-check flywheel_prompt.txtwith envFLYWHEEL_RUN_ID/TOKEN/SERVER. - Start a heartbeat thread posting
/runs/{id}/heartbeatevery 30s. - Stream Codex stdout lines as logs to
/runs/{id}/logs; capture Codexrun_idif emitted. - Oversized log messages are dropped and replaced with a placeholder entry; if a proxy
returns
413, the bootstrap treats it as non-fatal and emits the placeholder.
- Run
-
After Codex exits:
- If code persistence is enabled, bootstrap commits/pushes non-artifact changes:
- Excludes manifest-declared artifact paths from the git commit
- Skips oversized files (default cap: 95 MiB, configurable via
FLYWHEEL_GIT_MAX_COMMIT_FILE_SIZE_BYTES)
- Artifact files referenced by
payload.path/payload.fileare embedded into artifact payloads when they are below the transfer threshold (default: 16 MiB, configurable viaFLYWHEEL_ARTIFACT_BLOB_THRESHOLD_BYTES). - Read
flywheel_artifacts.json; if empty and Codexrun_idis known, attempt onecodex resume <id>then re-read. - POST artifacts to
/runs/{id}/artifacts; POST/completeon exit 0, else/errorwith the exit code. - Stop/join the heartbeat thread.
- If code persistence is enabled, bootstrap commits/pushes non-artifact changes:
-
Mock mode (
BOOTSTRAP_MOCK_CODEX=1):- Sends a heartbeat, a few logs, writes a mock artifact manifest, returns 0 (used in e2e tests).
Next steps
- Iterate on prompts / general polish.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flywheel_bootstrap_staging-0.1.9.202602071759.tar.gz.
File metadata
- Download URL: flywheel_bootstrap_staging-0.1.9.202602071759.tar.gz
- Upload date:
- Size: 59.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00ae2e66b79fcba4bd99f00004600229eaa93c7f497a147647965b57c5a04789
|
|
| MD5 |
e370620bdd29f8ae3b1db95170b9c2d0
|
|
| BLAKE2b-256 |
37d836936ad1138099c50c440e1038b440823ba30d02c12bea5310743cd0ef1b
|
File details
Details for the file flywheel_bootstrap_staging-0.1.9.202602071759-py3-none-any.whl.
File metadata
- Download URL: flywheel_bootstrap_staging-0.1.9.202602071759-py3-none-any.whl
- Upload date:
- Size: 36.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76f2e71b90cc93fde3a3098b2890a4d8b58936085a10e0afda65d43ea80d1875
|
|
| MD5 |
9bce161a93ae5a316d0168ad36277811
|
|
| BLAKE2b-256 |
b7f8355068eaaa1f7869a0d915b470c2708dbaf63a919864189c2cb8bb01fb17
|