simonw / sqlite-comprehend

Tools for running data in a SQLite database through AWS Comprehend
Apache License 2.0
6 stars 0 forks source link

Handle errors #8

Closed simonw closed 2 years ago

simonw commented 2 years ago

The return value from the API includes this:

"ErrorList": [],

I've not been able to deliberately trigger an error, but this document on page 33 shows an example: https://docs.aws.amazon.com/comprehend/latest/dg/comprehend-dg.pdf

image

I should log these out to stderr if I ever see them.

simonw commented 2 years ago

It's frustrating that I can't figure out how to trigger errors.

Had a nasty thought: if there is an error, does this line of code work any more? https://github.com/simonw/sqlite-comprehend/blob/ea90d18f5567ad9b0c9b16b9b9eb3583b62cbcea/sqlite_comprehend/cli.py#L148-L152

What if the row with the errors isn't included in that list? The zip() will do the wrong thing.

I should look at those "Index" values instead for correlating results with input: https://github.com/simonw/sqlite-comprehend/blob/ea90d18f5567ad9b0c9b16b9b9eb3583b62cbcea/tests/test_sqlite_comprehend.py#L25-L50

simonw commented 2 years ago

I'm going to write a test that simulates what I think this would look like based on the AWS documentation.

simonw commented 2 years ago

Looks like my hunch is correct: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/comprehend.html#Comprehend.Client.batch_detect_entities says:

The result of calling the operation. The operation returns one object for each document that is successfully processed by the operation.

simonw commented 2 years ago

I fixed the zip() problem in this commit: https://github.com/simonw/sqlite-comprehend/commit/e0841464bbae5676783fc2825fcb2909168c1dfe#diff-ba49e584405b6da97a7f13447f39da0f999da4a348f908ceaa167bd30f4facd1L151