-
Notifications
You must be signed in to change notification settings - Fork 6
Add create_diff to the clients to manually create a diff between two times.
#531
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
…time range filtering
WalkthroughAdds synchronous and asynchronous create_diff methods that accept branch, name, from_time, to_time, and wait_until_completion (returns task id when non-blocking or ok boolean when completed). Extends synchronous and asynchronous get_diff_summary to accept optional name, from_time, to_time (validated, serialized via ISO) and passes them as GraphQL variables. Updates GraphQL DiffTree query to accept these inputs. Maps top-level NodeDiff.action from node status. Updates tests to expect UPDATED top-level actions and adds a changelog entry. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying infrahub-sdk-python with
|
| Latest commit: |
c7db393
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://486e2c36.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://atg-20250904-diff.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## stable #531 +/- ##
==========================================
- Coverage 75.98% 75.55% -0.43%
==========================================
Files 100 100
Lines 9369 8899 -470
Branches 1932 1748 -184
==========================================
- Hits 7119 6724 -395
+ Misses 1727 1693 -34
+ Partials 523 482 -41
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 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: 4
🧹 Nitpick comments (2)
changelog/529.added.md (1)
1-2: Confirm changelog fragment number and note behavioral change in NodeDiff.action.
- The file is named 529.added.md while this PR is #531—confirm whether 529 is intentional (e.g., towncrier/issue id) or should be 531 to avoid release note tooling misses.
- Please also note in the changelog that NodeDiff.action is now derived from status (previously action/None). This is a user-visible change.
infrahub_sdk/client.py (1)
1154-1176: Confirm server input field: wait_until_completion vs background_execution.Comment suggests background_execution is still the server field. If so, swap to background_execution = not wait_until_completion (or add compat shim) until the server changes.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
changelog/529.added.md(1 hunks)infrahub_sdk/client.py(4 hunks)infrahub_sdk/diff.py(2 hunks)tests/unit/sdk/test_diff_summary.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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:
tests/unit/sdk/test_diff_summary.pyinfrahub_sdk/diff.pyinfrahub_sdk/client.py
tests/unit/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Place and write unit tests under tests/unit/ (isolated component tests)
Files:
tests/unit/sdk/test_diff_summary.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/sdk/test_diff_summary.py
infrahub_sdk/client.py
📄 CodeRabbit inference engine (CLAUDE.md)
infrahub_sdk/client.py: Use HTTPX for transport with proxy support (single proxy or HTTP/HTTPS mounts)
Support authentication via API tokens or JWT with automatic refresh
Files:
infrahub_sdk/client.py
🧬 Code graph analysis (1)
infrahub_sdk/client.py (2)
infrahub_sdk/graphql.py (3)
Mutation(170-201)render(158-167)render(178-201)infrahub_sdk/diff.py (2)
NodeDiff(10-16)get_diff_summary_query(38-74)
⏰ 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). (2)
- GitHub Check: unit-tests (3.13)
- GitHub Check: integration-tests-latest-infrahub
🔇 Additional comments (5)
infrahub_sdk/diff.py (2)
40-41: LGTM: Query now supports optional name/from_time/to_time.
124-124: Behavior change: action now mirrors node.status.Good alignment with server payload, but this changes client-observable values. Ensure downstream consumers expect UPDATED/ADDED/REMOVED and not None.
tests/unit/sdk/test_diff_summary.py (1)
112-112: LGTM: Expected actions updated to UPDATED at top-level.Matches the new mapping in diff.py.
Also applies to: 127-127, 143-143
infrahub_sdk/client.py (2)
8-8: LGTM: datetime import required for new APIs.
28-28: LGTM: Using MUTATION_QUERY_TASK for background mode selection set.
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
♻️ Duplicate comments (2)
infrahub_sdk/client.py (2)
1154-1177: Bug: create_diff runs on default branch; pass branch_name to scope the mutation.Without branch_name, DiffUpdate may execute against the default branch even when a different branch is intended.
Apply:
- response = await self.execute_graphql(query=query.render(), tracker="mutation-diff-update") + response = await self.execute_graphql( + query=query.render(), + branch_name=branch, + tracker="mutation-diff-update", + )
2327-2350: Bug: create_diff (sync) also needs branch scoping.Same issue as async: mutation is executed without branch_name.
Apply:
- response = self.execute_graphql(query=query.render(), tracker="mutation-diff-update") + response = self.execute_graphql( + query=query.render(), + branch_name=branch, + tracker="mutation-diff-update", + )
🧹 Nitpick comments (2)
infrahub_sdk/client.py (2)
1157-1166: Optional: enforce timezone-aware datetimes to avoid ambiguous ranges.If from_time/to_time are naive, .isoformat() may be interpreted inconsistently by the API. Either require tz-aware or normalize to UTC.
Apply one of:
if from_time > to_time: raise ValueError("from_time must be <= to_time") + if from_time.tzinfo is None or to_time.tzinfo is None: + raise ValueError("from_time and to_time must be timezone-aware")Or normalize:
+ from datetime import timezone + from_time = from_time.astimezone(timezone.utc) + to_time = to_time.astimezone(timezone.utc)
2330-2339: Optional: enforce timezone-aware datetimes (sync).Mirror the async guard/normalization to avoid ambiguous naive times.
Apply one of:
if from_time > to_time: raise ValueError("from_time must be <= to_time") + if from_time.tzinfo is None or to_time.tzinfo is None: + raise ValueError("from_time and to_time must be timezone-aware")or normalize to UTC as shown in the async comment.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
infrahub_sdk/client.py(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/client.py
infrahub_sdk/client.py
📄 CodeRabbit inference engine (CLAUDE.md)
infrahub_sdk/client.py: Use HTTPX for transport with proxy support (single proxy or HTTP/HTTPS mounts)
Support authentication via API tokens or JWT with automatic refresh
Files:
infrahub_sdk/client.py
🧬 Code graph analysis (1)
infrahub_sdk/client.py (2)
infrahub_sdk/graphql.py (3)
Mutation(170-201)render(158-167)render(178-201)infrahub_sdk/diff.py (2)
NodeDiff(10-16)get_diff_summary_query(38-74)
⏰ 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). (6)
- GitHub Check: unit-tests (3.12)
- GitHub Check: unit-tests (3.13)
- GitHub Check: unit-tests (3.11)
- GitHub Check: unit-tests (3.10)
- GitHub Check: integration-tests-latest-infrahub
- GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
infrahub_sdk/client.py (4)
8-8: LGTM: datetime import added for new APIs.
28-28: LGTM: task query import wired.
1181-1205: Good: open-ended time filters and order validation handled; variables passed correctly.
2354-2378: Good: sync get_diff_summary parity with async (open-ended range + validation).
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.
LGTM, though it would be good with some integration tests as well so we can validate that the new methods are working as intended.
|
@ogenstad Yes I was unsure if they would be required as we dont have any integration tests for a similar API (branch create). |
Summary by CodeRabbit