Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: indexing
Signed-off-by: Rob Howley <howley.robert@gmail.com>
  • Loading branch information
robhowley committed Oct 12, 2024
commit b3b7ed1dd3ab7d252985c875ebcdcb4776bd9fc8
46 changes: 24 additions & 22 deletions sdk/python/feast/infra/online_stores/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ async def online_read_async(

deserialize = TypeDeserializer().deserialize

def to_tbl_resp(raw_client_response):
return {
"entity_id": deserialize(raw_client_response["entity_id"]),
"event_ts": deserialize(raw_client_response["event_ts"]),
"values": deserialize(raw_client_response["values"]),
}

batches = []
entity_id_batches = []
while True:
batch = list(itertools.islice(entity_ids_iter, batch_size))
Expand All @@ -310,36 +318,30 @@ async def online_read_async(
entity_id_batch = self._to_client_batch_get_payload(
online_config, table_name, batch
)
batches.append(batch)
entity_id_batches.append(entity_id_batch)
Comment on lines +312 to +322
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

construct the batches of ids/entity_ids that we'll be looking up


async with self._get_aiodynamodb_client(online_config.region) as client:

async def get_and_format(entity_id_batch):
def to_tbl_resp(raw_client_response):
return {
"entity_id": deserialize(raw_client_response["entity_id"]),
"event_ts": deserialize(raw_client_response["event_ts"]),
"values": deserialize(raw_client_response["values"]),
}

response = await client.batch_get_item(
RequestItems=entity_id_batch,
)
return self._process_batch_get_response(
table_name,
response,
entity_ids,
batch,
to_tbl_response=to_tbl_resp,
)

result_batches = await asyncio.gather(
response_batches = await asyncio.gather(
*[
get_and_format(entity_id_batch)
client.batch_get_item(
RequestItems=entity_id_batch,
)
for entity_id_batch in entity_id_batches
]
)
Comment on lines +325 to +332
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make those batch requests in parallel.

note: gather maintains order


result_batches = []
for batch, response in zip(batches, response_batches):
result_batch = self._process_batch_get_response(
table_name,
response,
entity_ids,
batch,
to_tbl_response=to_tbl_resp,
)
result_batches.append(result_batch)
Comment on lines +335 to +343
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

format the responses to the final format. we iterate through the list three times in stead of one, but make up for it in asyncing the batches


return list(itertools.chain(*result_batches))

def _get_aioboto_session(self):
Expand Down