Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/+batch.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Create a new batch while fetching relationships instead of using the reusing the same one.
14 changes: 5 additions & 9 deletions infrahub_sdk/node/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any

from ..batch import InfrahubBatch
from ..exceptions import (
Error,
UninitializedError,
Expand Down Expand Up @@ -163,12 +164,9 @@ async def fetch(self) -> None:
for peer in self.peers:
if not peer.id or not peer.typename:
raise Error("Unable to fetch the peer, id and/or typename are not defined")
if peer.typename not in ids_per_kind_map:
ids_per_kind_map[peer.typename] = [peer.id]
else:
ids_per_kind_map[peer.typename].append(peer.id)
ids_per_kind_map[peer.typename].append(peer.id)

batch = await self.client.create_batch()
batch = InfrahubBatch(max_concurrent_execution=self.client.max_concurrent_execution)
for kind, ids in ids_per_kind_map.items():
batch.add(
task=self.client.filters,
Expand Down Expand Up @@ -289,11 +287,9 @@ def fetch(self) -> None:
for peer in self.peers:
if not peer.id or not peer.typename:
raise Error("Unable to fetch the peer, id and/or typename are not defined")
if peer.typename not in ids_per_kind_map:
ids_per_kind_map[peer.typename] = [peer.id]
else:
ids_per_kind_map[peer.typename].append(peer.id)
ids_per_kind_map[peer.typename].append(peer.id)

# Unlike Async, no need to create a new batch from scratch because we are not using a semaphore
batch = self.client.create_batch()
for kind, ids in ids_per_kind_map.items():
batch.add(
Expand Down