-
Notifications
You must be signed in to change notification settings - Fork 6
Merge stable into develop #610
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
Conversation
Signed-off-by: Fatih Acar <fatih@opsmill.com>
WalkthroughA new task CLI command group is introduced to the infrahubctl tool. The implementation includes a list subcommand that displays tasks with filtering options by state, limit, and offset, and supports both table and JSON output formats. Documentation is added for the new command, and the CLI module is registered in the command structure. The task model's from_graphql method is updated to explicitly handle presence checks for related_nodes and logs fields. Unit tests validate the list command's behavior with various filtering and output scenarios. Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying infrahub-sdk-python with
|
| Latest commit: |
e3d2bff
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0259cebf.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://fac-merge-stable-into-develo.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## develop #610 +/- ##
===========================================
+ Coverage 75.13% 75.57% +0.43%
===========================================
Files 112 109 -3
Lines 10972 9384 -1588
Branches 2368 1869 -499
===========================================
- Hits 8244 7092 -1152
+ Misses 2138 1802 -336
+ Partials 590 490 -100
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 20 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/docs/infrahubctl/infrahubctl-task.mdx (1)
33-33: Consider rephrasing for grammatical completeness.While "Can be provided multiple times" is common in CLI documentation, it technically lacks a subject. Consider: "This option can be provided multiple times."
infrahub_sdk/ctl/task.py (1)
34-34: Pragma comment may be inaccurate.The
# pragma: no covercomment suggests this ValueError path won't be reached, buttest_task_list_invalid_statein the test file does successfully exercise this error path by passing an invalid state value. The ValueError is raised, caught by Typer, converted to a BadParameter, and displayed to the user. Consider removing the pragma comment.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
docs/docs/infrahubctl/infrahubctl-task.mdx(1 hunks)docs/sidebars-infrahubctl.ts(1 hunks)infrahub_sdk/ctl/cli_commands.py(2 hunks)infrahub_sdk/ctl/task.py(1 hunks)infrahub_sdk/task/models.py(1 hunks)tests/unit/ctl/test_task_app.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method
Files:
infrahub_sdk/ctl/task.pyinfrahub_sdk/ctl/cli_commands.pyinfrahub_sdk/task/models.pytests/unit/ctl/test_task_app.py
infrahub_sdk/ctl/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
infrahub_sdk/ctl/**/*.py: Build CLI commands with Typer
Organize and keep all CLI commands within infrahub_sdk/ctl/
Files:
infrahub_sdk/ctl/task.pyinfrahub_sdk/ctl/cli_commands.py
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (CLAUDE.md)
docs/**/*.{md,mdx}: Follow the Diataxis framework and classify docs as Tutorials, How-to guides, Explanation, or Reference
Structure How-to guides with required frontmatter and sections: introduction, prerequisites, step-by-step steps, validation, related resources
Structure Topics (Explanation) docs with introduction, concepts & definitions, background & context, architecture & design, connections, further reading
Use a professional, concise, informative tone with consistent structure across documents
Use proper language tags on all code blocks
Include both async and sync examples where applicable using the Tabs component
Add validation steps to guides to confirm success and expected outputs
Use callouts for warnings, tips, and important notes
Define new terms on first use and use domain-relevant terminology consistent with Infrahub’s model/UI
Conform to markdown style rules in .markdownlint.yaml and Vale styles in .vale/styles/
Files:
docs/docs/infrahubctl/infrahubctl-task.mdx
tests/unit/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Place and write unit tests under tests/unit/ (isolated component tests)
Files:
tests/unit/ctl/test_task_app.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Use the custom pytest plugin (infrahub_sdk.pytest_plugin) fixtures for clients, configuration, and Infrahub-specific testing
Files:
tests/unit/ctl/test_task_app.py
🧠 Learnings (3)
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/ctl/**/*.py : Build CLI commands with Typer
Applied to files:
infrahub_sdk/ctl/task.pyinfrahub_sdk/ctl/cli_commands.pydocs/sidebars-infrahubctl.tstests/unit/ctl/test_task_app.py
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/ctl/**/*.py : Organize and keep all CLI commands within infrahub_sdk/ctl/
Applied to files:
infrahub_sdk/ctl/task.pyinfrahub_sdk/ctl/cli_commands.pydocs/sidebars-infrahubctl.ts
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to infrahub_sdk/config.py : Environment variables for configuration must use the INFRAHUB_ prefix
Applied to files:
docs/sidebars-infrahubctl.ts
🧬 Code graph analysis (2)
infrahub_sdk/ctl/task.py (4)
infrahub_sdk/async_typer.py (2)
AsyncTyper(11-31)command(29-31)infrahub_sdk/task/models.py (3)
TaskFilter(65-76)Task(32-62)TaskState(9-18)infrahub_sdk/ctl/client.py (1)
initialize_client(10-25)infrahub_sdk/ctl/utils.py (2)
catch_exception(78-106)init_logging(42-50)
tests/unit/ctl/test_task_app.py (1)
infrahub_sdk/async_typer.py (1)
runner(17-18)
🪛 LanguageTool
docs/docs/infrahubctl/infrahubctl-task.mdx
[style] ~33-~33: To form a complete sentence, be sure to include a subject.
Context: ...s, --state TEXT: Filter by task state. Can be provided multiple times. * --limit ...
(MISSING_IT_THERE)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: unit-tests (3.12)
- GitHub Check: unit-tests (3.13)
- GitHub Check: unit-tests (3.9)
- GitHub Check: unit-tests (3.11)
- GitHub Check: unit-tests (3.10)
- GitHub Check: integration-tests-latest-infrahub
- GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
infrahub_sdk/task/models.py (1)
52-60: LGTM: Explicit key-presence checks improve robustness.The updated logic now ensures
related_nodesandlogskeys are deleted from the input data whenever they are present, even if their values are falsy (empty list, None, etc.). This is more defensive than relying solely ondata.get()truthiness and prevents potential issues with downstream code that might not expect these keys to remain.docs/sidebars-infrahubctl.ts (1)
27-27: LGTM: Sidebar entry correctly added.The new documentation entry for the task CLI is properly positioned alphabetically within the Commands category.
infrahub_sdk/ctl/cli_commands.py (2)
36-36: LGTM: Task CLI module imported correctly.The import follows the established pattern for other CLI modules in this file.
69-69: LGTM: Task CLI group registered properly.The registration follows the same pattern as other command groups (branch, schema, validate, etc.) and correctly exposes the task commands under the
infrahubctl tasknamespace.tests/unit/ctl/test_task_app.py (2)
20-44: LGTM: Well-structured test helper.The
_task_response()helper provides a realistic mock GraphQL response structure with all necessary fields for testing the task list functionality.
51-100: LGTM: Comprehensive test coverage for task list command.The test suite covers the key scenarios:
- Basic table rendering with task data
- JSON output format and content validation
- State filtering with empty results
- Error handling for invalid state values
This provides solid baseline coverage for the new CLI functionality.
infrahub_sdk/ctl/task.py (4)
20-22: LGTM: Command group callback properly defined.The callback provides the appropriate description for the task command group.
25-39: LGTM: State parsing with proper validation.The
_parse_stateshelper correctly normalizes input strings and converts them toTaskStateenum values, with clear error messages for invalid states using Typer'sBadParameterexception.
42-69: LGTM: Table rendering with proper formatting and empty-state handling.The
_render_tablehelper creates a well-structured Rich table with appropriate column styling and gracefully handles the empty tasks case.
72-110: LGTM: Comprehensive task listing command.The
list_taskscommand provides:
- Multiple filtering options (state, limit, offset)
- Optional inclusion of related nodes and logs
- Both table and JSON output formats
- Proper async implementation with AsyncTyper
- Error handling via
catch_exceptiondecoratorThe implementation follows established CLI patterns and coding guidelines.
Based on learnings
Summary by CodeRabbit
Release Notes
New Features
infrahubctl task listcommand to view and filter tasks by state, limit, offset, and other criteria; supports table and JSON output formats.Documentation