Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`--json` output is not valid JSON for `search --export`, `image upload <dir>`, `model upload` and `version download`

未关闭
#546 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@cdeil 已经在做这个了。

开始于 2026年10月7日。

  • #547 来自 @cdeil —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
cli

调研方向

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

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

roboflow/roboflow-python 的其他 Issue

查看 roboflow/roboflow-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。