Skip to content

Conversation

@BeArchiTek
Copy link
Contributor

When using the InfrahubClientSync.filters() with parallel=True, the pagination was unstable, with some delta returned now and then.

When dumping the queries, every time this issue happens, it seems like we are doing 2 times the 2nd page and not the first one. Forcing offset=0 fixes it.

I am not sure why this issue was not present with the Async Client, considering both of them are using the same generate_query_data_init() ...

@BeArchiTek BeArchiTek requested a review from a team July 14, 2025 11:28
@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff           @@
##           stable     #468   +/-   ##
=======================================
  Coverage   75.64%   75.64%           
=======================================
  Files         100      100           
  Lines        8769     8769           
  Branches     1714     1714           
=======================================
  Hits         6633     6633           
  Misses       1660     1660           
  Partials      476      476           
Flag Coverage Δ
integration-tests 34.66% <0.00%> (+0.01%) ⬆️
python-3.10 47.91% <100.00%> (+0.02%) ⬆️
python-3.11 47.89% <100.00%> (ø)
python-3.12 47.89% <100.00%> (ø)
python-3.13 47.89% <100.00%> (+0.02%) ⬆️
python-3.9 46.58% <100.00%> (ø)
python-filler-3.12 25.25% <0.00%> (ø)

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

Files with missing lines Coverage Δ
infrahub_sdk/client.py 69.55% <100.00%> (ø)
infrahub_sdk/node/node.py 74.93% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

for page_number in range(1, total_pages + 1):
page_offset = (page_number - 1) * pagination_size
batch_process.add(task=process_page, node=node, page_offset=page_offset, page_number=page_number)
batch_process.add(task=process_page, page_offset=page_offset, page_number=page_number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the node parameter here as well as in the async version is that something that's related to this change?

Looking at your change it doesn't seem like node provided any value previously. However we're still setting node with:

node = InfrahubNodeSync(client=self, schema=schema, branch=branch)

I wonder if it makes sense to keep this, it's also a bit problematic as we're shadowing the node variable a bit further down in the method:

        if populate_store:
            for node in nodes:
                if node.id:
                    self.store.set(node=node)
            related_nodes = list(set(related_nodes))
            for node in related_nodes:
                if node.id:
                    self.store.set(node=node)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could let node or do it in another PR, while debugging, I saw that we have node set twice out of 4 times when using the function, so from my point of view the function signature was not matching the usage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can perhaps create a follow up issue to remove the node = parts in these two methods.

Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a newsfragment to indicate what was fixed?

for page_number in range(1, total_pages + 1):
page_offset = (page_number - 1) * pagination_size
batch_process.add(task=process_page, node=node, page_offset=page_offset, page_number=page_number)
batch_process.add(task=process_page, page_offset=page_offset, page_number=page_number)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can perhaps create a follow up issue to remove the node = parts in these two methods.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 14, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0dd2541
Status: ✅  Deploy successful!
Preview URL: https://66a124a2.infrahub-sdk-python.pages.dev
Branch Preview URL: https://bkr-fix-sync-parallel-filter.infrahub-sdk-python.pages.dev

View logs

@BeArchiTek BeArchiTek merged commit ec3627f into stable Jul 14, 2025
19 checks passed
@BeArchiTek BeArchiTek deleted the bkr-fix-sync-parallel-filters branch July 14, 2025 14:52
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.

3 participants