-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI: make the output of create
commands machine-readable
#8833
Conversation
WalkthroughThe changes focus on enhancing the machine-readability of CLI outputs for task and project creation commands. The modifications simplify the output to return only the resource ID when creating tasks or projects, removing additional descriptive text. This change is implemented across multiple files in the CVAT CLI, including command implementations and corresponding test files, with updates to how task and project IDs are extracted and displayed. Changes
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🔇 Additional comments (7)changelog.d/20241216_144316_roman_machine_readable_create.md (1)
The changelog entry effectively communicates the changes and their purpose, following the proper format and including all necessary details. tests/python/cli/test_cli_projects.py (2)
The change correctly handles the new simplified output format, properly removing trailing newlines before parsing the project ID.
The change maintains consistency with the previous test method in handling the simplified output format. cvat-cli/src/cvat_cli/_internal/commands_projects.py (1)
The change aligns with the PR objective of making the output machine-readable. Let's verify error handling remains intact: ✅ Verification successfulLGTM! Error handling is properly managed through the SDK layer. The error handling for the CLI command is properly managed through the SDK layer. The code shows:
🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check if error messages are properly handled and not affected by the output changes
# Search for error handling patterns in the codebase
rg -A 3 "raise|except" cvat-cli/src/cvat_cli/_internal/commands_projects.py
Length of output: 77 Script: #!/bin/bash
# Let's try a different approach to check error handling patterns
# First, let's see the entire file content to understand the context
cat cvat-cli/src/cvat_cli/_internal/commands_projects.py
Length of output: 2756 Script: #!/bin/bash
# Let's check the SDK implementation to understand error handling
# First, check the projects module in SDK
fd "projects.py" --exec cat {} \;
# Also check the base implementation for error handling patterns
fd "base.py" --exec cat {} \;
Length of output: 66710 tests/python/cli/test_cli_tasks.py (3)
The modification maintains consistency with the previous test case, using the same robust approach to extract the task ID.
The change maintains consistency with other task creation commands. However, since this uses a different command path (create-from-backup), let's verify its output format. ✅ Verification successfulLGTM! The task ID output format is consistent Looking at the implementation in 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that the task create-from-backup command outputs only the task ID
# Expected: Output should be a single line containing only digits
# Search for the backup creation command implementation
rg -l "def.*TaskCreateFromBackup"
# Search for print statements in backup creation
rg "print\(" --type py | rg -i "task.*backup.*create"
Length of output: 91 Script: #!/bin/bash
# Let's try a different approach to find the implementation
# First, let's find files related to task backup
fd -e py . | rg -i "task.*backup"
# Then, let's look for CLI command registration related to task backup
rg "def.*command.*backup" --type py
# Finally, let's look for any print statements or stdout writes in task-related CLI files
rg "print|stdout.write" "cli/tasks.py" "cli/task_backup.py" 2>/dev/null
Length of output: 131 Script: #!/bin/bash
# Let's look at the test file itself to understand the command being tested
cat "tests/python/cli/test_cli_tasks.py"
# Also search for any task-related CLI files in the codebase
fd -t f -e py | rg "task.*cli|cli.*task"
Length of output: 9261 Script: #!/bin/bash
# Let's examine the CLI implementation for task creation from backup
cat "cvat-cli/src/cvat_cli/_internal/commands_tasks.py"
Length of output: 16507
The change to ✅ Verification successfulBased on the code found, I can now generate the final response: The change to use The CLI command implementation in 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that the task create command outputs only the task ID
# Expected: Output should be a single line containing only digits
# Search for the task create command implementation
rg -l "def.*TaskCreate"
# Search for print statements in task creation
rg "print\(" --type py | rg -i "task.*create"
Length of output: 73 Script: #!/bin/bash
# Let's try a different approach to find the CLI command implementation
# First, find the CLI command file
fd "cli.py|tasks.py" --type f
# Then search for task creation related code
rg "task.*create" --type py -A 5
Length of output: 65665 Script: #!/bin/bash
# Let's check the CLI command implementation to verify the output format
rg -A 5 "def create_from_backup" cvat-cli/src/cvat_cli/_internal/commands_tasks.py
Length of output: 84 Script: #!/bin/bash
# Let's try finding the CLI command implementation in a different way
fd "commands_tasks.py" --type f --exec cat {}
Length of output: 16499 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The underlying SDK functions already emit human-friendly log messages with the ID of the created resource. Instead of printing largely the same message twice, we can just print the ID. That way, the CLI can be more easily integrated into other software.
99799df
to
67ed89e
Compare
Quality Gate passedIssues Measures |
create
commands machine-readablecreate
commands machine-readable
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #8833 +/- ##
===========================================
- Coverage 73.93% 73.89% -0.05%
===========================================
Files 409 409
Lines 43930 43930
Branches 3986 3986
===========================================
- Hits 32478 32460 -18
- Misses 11452 11470 +18
|
Motivation and context
The underlying SDK functions already emit human-friendly log messages with the ID of the created resource. Instead of printing largely the same message twice, we can just print the ID. That way, the CLI can be more easily integrated into other software.
How has this been tested?
CLI tests.
Checklist
develop
branch[ ] I have updated the documentation accordingly[ ] I have linked related issues (see GitHub docs)[ ] I have increased versions of npm packages if it is necessary(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Bug Fixes
Tests