Skip to content

Commit 71c530d

Browse files
yeldarbyclaude
andcommitted
fix(cli): address Codex review - flag collision, missing args, compat
1. Remove -w from _reorder_argv global flags — it collides with deployment's -w/--wait_on_pending (boolean). --workspace long form is still reordered safely. Prevents deployment add -w from being misinterpreted as workspace flag. 2. Forward annotation_group to workspace.search_export() in _do_export. Also add -g/--annotation-group flag to the canonical search command (was only on the hidden search-export alias). 3. Restore -M shorthand on upload alias for backwards compat with scripts using `roboflow upload ... -M '{"key":"val"}'`. 283 tests pass, all linting clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7b4a4b1 commit 71c530d

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

roboflow/cli/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ def _reorder_argv(argv: list[str]) -> list[str]:
145145
e.g. ``roboflow project list --json``. This helper transparently
146146
re-orders the argv so those flags are consumed by the root parser.
147147
"""
148-
global_flags_with_value = {"--api-key", "-k", "--workspace", "-w"}
148+
# Note: -w is intentionally excluded — it collides with deployment's
149+
# -w/--wait_on_pending (boolean). --workspace (long form) is safe.
150+
global_flags_with_value = {"--api-key", "-k", "--workspace"}
149151
global_flags_bool = {"--json", "-j", "--quiet", "-q", "--version"}
150152

151153
reordered: list[str] = []

roboflow/cli/handlers/_aliases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def register(subparsers: argparse._SubParsersAction) -> None: # type: ignore[ty
4444
upload_p.add_argument("-r", "--retries", dest="num_retries", type=int, default=0, help="Retry count")
4545
upload_p.add_argument("-b", "--batch", dest="batch", help="Batch name")
4646
upload_p.add_argument("-t", "--tag", dest="tag_names", help="Comma-separated tag names")
47-
upload_p.add_argument("--metadata", dest="metadata", help="JSON metadata string")
47+
upload_p.add_argument("-M", "--metadata", dest="metadata", help="JSON metadata string")
4848
upload_p.add_argument("-c", "--concurrency", dest="concurrency", type=int, default=10, help="Upload concurrency")
4949
upload_p.add_argument("--is-prediction", dest="is_prediction", action="store_true", help="Mark as prediction")
5050
upload_p.set_defaults(func=_handle_upload)

roboflow/cli/handlers/search.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def register(subparsers: argparse._SubParsersAction) -> None: # type: ignore[ty
2525
search_parser.add_argument(
2626
"-d", "--dataset", dest="dataset", default=None, help="Limit to a specific dataset (project slug)"
2727
)
28+
search_parser.add_argument(
29+
"-g",
30+
"--annotation-group",
31+
dest="annotation_group",
32+
default=None,
33+
help="Limit export to a specific annotation group",
34+
)
2835
search_parser.add_argument("--name", dest="name", default=None, help="Optional name for the export")
2936
search_parser.add_argument(
3037
"--no-extract", dest="no_extract", action="store_true", default=False, help="Keep zip file, skip extraction"
@@ -91,6 +98,7 @@ def _do_export(args: argparse.Namespace, workspace: Any) -> None:
9198
format=args.format,
9299
location=args.location,
93100
dataset=args.dataset,
101+
annotation_group=getattr(args, "annotation_group", None),
94102
name=args.name,
95103
extract_zip=not args.no_extract,
96104
)

tests/cli/test_discovery.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def test_short_value_flag(self) -> None:
8484
self.assertEqual(result, ["-k", "abc123", "project", "list"])
8585

8686
def test_multiple_flags_mixed(self) -> None:
87+
# -w is NOT reordered (collides with deployment's -w/--wait_on_pending)
88+
# but --workspace (long form) and --json are reordered
8789
result = self._reorder(["project", "list", "--json", "-w", "my-ws"])
88-
self.assertEqual(result, ["--json", "-w", "my-ws", "project", "list"])
90+
self.assertEqual(result, ["--json", "project", "list", "-w", "my-ws"])
8991

9092
def test_value_flag_at_end_without_value(self) -> None:
9193
"""A value flag at the very end with no following arg should still be moved."""

0 commit comments

Comments
 (0)