Repository navigation
feat(cli): compute product commands - #555
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cyro292
left a comment
There was a problem hiding this comment.
Review: changes requested. All SDK calls match 6.3.2, and the 215 new tests pass. The problems are in edge-case handling, grouped below.
1. API URL precedence 🔴
options.py:600:MOBILERUN_BASE_URLnow wins overMOBILERUN_API_BASE_URLfor every existing command. On base, the legacy variable won.mobilerun envstill reports only the legacy one, so it can show a different endpoint than the one actually used.function.py:233:run --localwith a cloud device sets onlyMOBILERUN_API_BASE_URLfor the child process.mobilerun_functionsreadsMOBILERUN_BASE_URLfirst, so the API key can go to an inherited host instead of--api-url. Fix: set both variables.
2. Wait and poll failures lose state 🔴
function.py:373: if the completion poll fails after the run was created, the run ID is dropped. Callers may then start a duplicate run.sandbox.py:164: if a status request times out, the command exits 1 with "Request timed out". It should take the pending path, which keeps the command ID and exits 124.function.py:532:_poll_untiltreats anyAPIErroras "still pending" and exits 0. A 403 is hidden.function.py:599: push pollslatest_version, not the version it just created. If another push lands in between, a rejected v2 can exit 0.function.py:373:--waitpolls even when the create response is already terminal. If that poll times out, a finished run is reported as "still running" with exit 124.function.py:385:--timeoutdoesn't bound the command. The log wait adds up to 60s after it.
3. Output fidelity 🟠
routine.py:165:pull -o routine.jsonwrites YAML, thencheckandpushreject the file. Fix: infer the format from the suffix.sandbox.py:170:rstrip+emitrewrites remote stdout:XandX\n\nboth becomeX\n. This breaks pipes.options.py:262: redaction collapses whitespace in--jsonerror details, so keys like"a b"and"a b"merge.routine.py:57: a 422 with non-dictdetailsexits 3 with no output.function.py:72:check -jprints no JSON whenmobilerun-functionsis missing.function.py:662:show --versioncrashes ondata: null, which the SDK allows.
4. Local device selection 🟠
function.py:213:-P ioswithout-dselects no device, butREADME.md:379says it does. Either make it select a device or fix the docs.
5. Files 🟡
options.py:748: the no---forcepath publishes withos.link, which should fail on filesystems without hard links, such as exFAT or some network mounts. Written files also end up with mode 0600. (Derived from the code, not run.)sandbox.py:212,239: uploads and downloads buffer the whole file in memory.
6. YAML 🟡
documents.py:117: explicit tags bypass the YAML 1.2 rules:!!float 1:30becomes90.0.- PyYAML is imported but not declared; it only arrives through
llama-index-core. It also now loads on every CLI startup viatree.py.
Nits and open questions
routine.py:237: the enqueue-failure message prints a literalID.routine.py:227: ❓ keyed runs may record queue failures on the execution instead of settingenqueueFailed, so a failed enqueue may still exit 0. Not checked against the live API.
Verification: 215/215 new tests pass on SDK 6.3.2. Ruff and Black are clean. I couldn't reproduce the "1,281 passed" claim: the full -k cli run gave 1,276 passed, 8 failed, and all 8 also fail on base. The PR has no test job in CI.
|
Thanks for the thorough review. I checked every point against the code. Fixes are in 024b5bd and c59f8a0 (develop merged in 72a42d5); status per point: 1. API URL precedence
2. Wait and poll failuresAll fixed:
3. Output fidelityAll fixed: 4. Local device selectionI fixed the code to match the README: 5. Files
6. YAML
Nits and open questions
VerificationYou're right about the count. This round: Could you take another look? |
Cyro292
left a comment
There was a problem hiding this comment.
Thanks, the happy path looks good and the offline tests pass (799/799 on SDK 6.3.2). A few things to fix before merge:
Important
push crashes on a data: null version response (mobilerun/cli/function.py:639)
SDK 6.3.2 allows data: null when the version is read back. Right now that becomes an AttributeError, so the user never sees the function ID and version that were already created. They will likely push again and create a duplicate.
Fix: handle the missing record explicitly, and print both the function ID and the version ID so the user can inspect the upload instead of re-pushing.
Minor
Sandbox output loses ANSI sequences when redirected (mobilerun/cli/sandbox.py:180)
click.echo strips ANSI codes when stdout/stderr isn't a TTY, so mobilerun sandbox exec ... > out.log doesn't contain the exact remote output. The existing regression test covers trailing newlines, not exact stream content.
Fix: pass color=True for both remote streams, and add a test with escape sequences.
Misleading pending-validation hint (mobilerun/cli/function.py:173)
The hint tells users to rerun check --remote, but that starts a new validation instead of checking the printed ID.
Fix: drop the retry instruction, or point to a way to retrieve that validation ID. Please also update README.md:403 and :417 to distinguish pending --no-wait from exit 124, and describe the shared completion/log budget.
Structure
mobilerun/cli/options.py:742: file publishing and filesystem fallback logic (refuse_existing,write_file) now live in the Click options module. Please move them together into a small, focused CLI file utility.mobilerun/cli/function.py:507:_print_functionhas one caller. Use the existingprint_modelswith a single item instead.
Cyro292
left a comment
There was a problem hiding this comment.
Correction to my earlier review: I'm withdrawing the data: null point on push (mobilerun/cli/function.py:639). The server contract requires data, and a missing version returns 404, not 200 with data: null. Only the generated SDK type allows None, so the crash can't happen in practice.
Small remaining ask on that path: when polling the new version fails (404, network error), the SDK error path (function.py:552) prints the function ID but not the version number. Printing both would let users inspect the upload instead of pushing again.
The other minor points from my earlier review (ANSI output with color=True, the pending-validation hint plus the README, and moving the file helpers / replacing _print_function) are non-blocking. Approving.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Summary
The CLI manages Serverless Functions, routines, and sandboxes through the published SDK, including creation, execution, inspection, and cleanup flows.
Changes
Run.wait_logs(). Configure completion waits with--timeout; missing logs preserve finished run results and exit codes.--allwhen deleting a function by name.--yes/--no-inputacross the compute commands.mobilerun-sdk>=6.3.2,<7, tested with the PyPI 6.3.2 release. Advertisesandbox deleteand retainstopas a hidden alias of the same command.waitS=0so server-side waiting cannot bypass the CLI completion timeout.Testing
uv run pytest tests -q -k cli: 1,316 passed, 4 failed (2,032 deselected); the same four failures also fail on develop:test_android_device_selection.py::test_device_command_with_multiple_devices_raises_click_error,test_cloud_cli.py::test_cloud_listing_errors_are_failures,test_cloud_cli.py::test_devices_cloud_missing_key_exits_nonzero,test_cloud_cli.py::test_local_listing_uses_local_scope.Runtime
Verified against the API on 2026-11-24: cloud runs succeeded with inherited device environment settings and a custom wait timeout. A quiet function completed with empty stdout/stderr; the API still published a small runtime log, so
logs=noneis covered with generated SDK responses. Unsafe delete commands exited 2; selected version deletion was explicit. Sandbox stdout/stderr, exit code 7, and exact binary transfer were verified. D2–D4 checks on SDK 6.3.2 verified both timeout paths return 124, normal commands return 0/7, and the hidden alias behaves like delete. Created functions and routines were deleted and all sandboxes stopped.🤖 Generated with Claude Code