Skip to content

Commit

Permalink
Merge pull request #112 from sift-stack/python/bug-channel-cache
Browse files Browse the repository at this point in the history
python(bug): fix download bug for same channel requested
  • Loading branch information
solidiquis authored Oct 29, 2024
2 parents bb0736b + fc0ba19 commit 7cd121d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions python/lib/sift_py/data/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,19 @@ async def _load_channels(
if chans.get(fqn) is None:
channels_to_retrieve.append(fqn)

sift_channels = await self._get_channels_by_asset_id_and_channel_fqns(
asset.asset_id, channels_to_retrieve
)
sift_channels = []
if len(channels_to_retrieve) > 0:
sift_channels = await self._get_channels_by_asset_id_and_channel_fqns(
asset.asset_id, channels_to_retrieve
)

channels = defaultdict(list)

for c in sift_channels:
channels[channel_fqn(c.name, c.component)].append(c)

self._cached_channels[asset.name].update(channels)
if len(channels) > 0:
self._cached_channels[asset.name].update(channels)

return self._cached_channels[asset.name]

Expand Down Expand Up @@ -422,7 +425,7 @@ async def _get_runs_by_names(self, run_names: Set[str]) -> List[Run]:
async def _get_channels_by_asset_id_and_channel_fqns(
self, asset_id: str, channel_fqns: List[str]
) -> List[Channel]:
if len(asset_id) == 0:
if len(asset_id) == 0 or len(channel_fqns) == 0:
return []

channels: List[Channel] = []
Expand Down

0 comments on commit 7cd121d

Please sign in to comment.