Skip to content

Conversation

@fatih-acar
Copy link
Contributor

@fatih-acar fatih-acar commented Nov 7, 2025

Summary by CodeRabbit

  • Refactor
    • Updated batch creation to use an asynchronous pattern, making create_batch() now an async method.
    • Simplified concurrent execution control by replacing internal semaphore handling with a direct max_concurrent_execution parameter.

It would make clients hang when using batches within batches.

Signed-off-by: Fatih Acar <fatih@opsmill.com>
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Walkthrough

The changes refactor the concurrent execution control mechanism in the Infrahub SDK. The async client no longer instantiates a semaphore for concurrent execution limits. Instead, the max_concurrent_execution parameter is passed directly to batch creation. The create_batch() method signature is updated to be asynchronous, and batch instantiation shifts from direct construction to client-provided factory method calls. This consolidates concurrent execution management and batch creation logic within the client layer.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Merge stable into develop' accurately describes the pull request's primary objective of merging changes from the stable branch into the develop branch.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fac-merge-stable-into-develop

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b52cd94 and 7b0e10d.

📒 Files selected for processing (2)
  • infrahub_sdk/client.py (1 hunks)
  • infrahub_sdk/node/relationship.py (1 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/node/relationship.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
🧠 Learnings (1)
📚 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: Maintain a dual client pattern: InfrahubClient (async) and InfrahubClientSync (sync) must provide identical interfaces

Applied to files:

  • infrahub_sdk/client.py
⏰ 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.10)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
infrahub_sdk/client.py (3)

2388-2397: LGTM: Sync client batch creation maintains consistency.

The synchronous client's create_batch method correctly mirrors the async client's changes while maintaining the dual client pattern. The docstring provides helpful context about thread pool execution.


1599-1602: Batch creation properly encapsulates semaphore management.

Verification confirms that InfrahubBatch correctly handles the max_concurrent_execution parameter at line 63: self.semaphore = semaphore or asyncio.Semaphore(value=max_concurrent_execution). The semaphore is created internally when not provided, and the client's refactored approach to pass max_concurrent_execution instead of managing semaphore creation directly is a sound design improvement.


1599-1602: Verification complete: No remaining direct batch instantiations outside client factory methods.

The refactoring is properly implemented. Batch classes are instantiated only through the client factory methods (create_batch() at line 1600 and create_batch() at line 2394), and no other code in the codebase directly instantiates InfrahubBatch or InfrahubBatchSync.

infrahub_sdk/node/relationship.py (1)

168-168: LGTM: Batch creation properly delegated to client.

The change from direct InfrahubBatch instantiation to await self.client.create_batch() correctly delegates batch creation to the client's factory method and properly uses await for the async operation.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7b0e10d
Status: ✅  Deploy successful!
Preview URL: https://5a349c40.infrahub-sdk-python.pages.dev
Branch Preview URL: https://fac-merge-stable-into-develo.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #605      +/-   ##
===========================================
- Coverage    76.44%   75.42%   -1.02%     
===========================================
  Files          112      108       -4     
  Lines        10856     9323    -1533     
  Branches      2335     1855     -480     
===========================================
- Hits          8299     7032    -1267     
+ Misses        1982     1802     -180     
+ Partials       575      489      -86     
Flag Coverage Δ
integration-tests 34.81% <100.00%> (-2.21%) ⬇️
python-3.10 48.51% <100.00%> (-2.20%) ⬇️
python-3.11 48.49% <100.00%> (+<0.01%) ⬆️
python-3.12 48.49% <100.00%> (-2.18%) ⬇️
python-3.13 48.47% <100.00%> (-2.22%) ⬇️
python-3.9 47.17% <100.00%> (?)
python-filler-3.12 24.44% <0.00%> (+0.76%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/client.py 68.02% <ø> (-3.11%) ⬇️
infrahub_sdk/node/relationship.py 73.41% <100.00%> (-0.16%) ⬇️

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fatih-acar fatih-acar merged commit 89426c6 into develop Nov 7, 2025
20 checks passed
@fatih-acar fatih-acar deleted the fac-merge-stable-into-develop branch November 7, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants