`--json` output is not valid JSON for `search --export`, `image upload <dir>`, `model upload` and `version download`
维护者通常 1 天内回复
评估
调研方向
Start with search.py::_do_export, image.py::_handle_upload_directory, model.py::_upload_model, and version.py::_download, then read CLI-COMMANDS.md and CLAUDE.md for the JSON-output contract and SDK-output guidance. The issue says the reporter is sending a PR right away, so check for that work before starting; done means each command's stdout parses with json.loads while progress and failure messages remain visible.
由索引模型根据 Issue 内容生成。
描述
CLI-COMMANDS.md describes --json as "Structured JSON output (for agents and piping)", and CLAUDE.md asks handlers to wrap SDK calls in suppress_sdk_output(). Four handlers call SDK methods that print to stdout outside such a block, so stdout is a mix of plain-text status lines and the pretty-printed JSON result, and json.loads(stdout) or | jq fails (roboflow 1.7.0 and current main; --quiet does not change it):
| Command | Handler → SDK call | Printed to stdout before the JSON |
|---|---|---|
search --export |
search.py::_do_export → Workspace.search_export() |
"Export started (id=...)...", "If this takes too long, ...", "Search export extracted to ..." |
image upload <dir> |
image.py::_handle_upload_directory → Workspace.upload_dataset() |
"Uploading to existing project ...", one [UPLOADED]/[DUPLICATE]/[ERR] line per image |
model upload |
model.py::_upload_model → Roboflow.workspace(), Workspace.project(), Version.deploy() / Workspace.deploy_model() |
"loading Roboflow workspace...", "loading Roboflow project..." (this handler does not use suppress_sdk_output() at all), "View the status of your deployment at: ...", "Share your model with the world at: ..." (or the error) |
version download |
version.py::_download → Version.download() |
when the format is generated on demand: "\rExporting format coco in progress : 40.0%", "\rVersion export complete for coco format" |
Example (offline: HTTP mocked with responses, command run with typer.testing.CliRunner):
$ roboflow --json search "project:my-project" --export -l out
Export started (id=exp1). Polling for completion...
If this takes too long, you can check the export status at: https://api.roboflow.com/my-workspace/search/export/exp1?api_key=YOUR_API_KEY
Search export extracted to /.../out
{
"status": "completed",
"path": "/.../out"
}
Proposal: in JSON mode, run these SDK calls inside contextlib.redirect_stdout(sys.stderr), so progress stays visible and stdout stays JSON, with one test per handler that parses stdout with json.loads. Simply suppressing the output with suppress_sdk_output() would hide the per-image [ERR] lines of image upload, which are currently its only failure signal (#545). A more general alternative: in JSON mode, redirect sys.stdout to stderr for the whole command and let output() write to the original stdout, which would also cover future handlers.
I'm sending a PR for the per-handler variant right away.
cc @yeldarby
- 主要语言
- Python
- 星标
- 633
- 派生
- 141
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 14
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
roboflow/roboflow-python 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
roboflow/roboflow-python#545 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
roboflow/roboflow-python#505 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 30/100
roboflow/roboflow-python#433 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
roboflow/roboflow-python#429 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 35/100
roboflow/roboflow-python#427 · 1 条评论 ·
维护者通常 1 天内回复
查看 roboflow/roboflow-python 的全部 Issue
相似的 Issue
-
area:space-accuracy good first issue track:data
难度 2/5 1-3 小时 新手友好度 85/100
Sara-Managed-Projects/space-radar#904 ·
维护者通常 1 天内回复