haystack-ml-stack 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of haystack-ml-stack might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
1
  from .app import create_app
2
2
 
3
3
  __all__ = ["create_app"]
4
- __version__ = "0.1.0"
4
+ __version__ = "0.1.1"
@@ -9,15 +9,46 @@ logger = logging.getLogger(__name__)
9
9
  async def async_batch_get(
10
10
  dynamo_client, table_name: str, keys: List[Dict[str, Any]]
11
11
  ) -> List[Dict[str, Any]]:
12
- """Asynchronous batch_get_item with unprocessed keys handling."""
12
+ """
13
+ Asynchronous batch_get_item with chunking for requests > 100 keys
14
+ and handling for unprocessed keys.
15
+ """
13
16
  all_items: List[Dict[str, Any]] = []
14
- to_fetch = {table_name: {"Keys": keys}}
15
-
16
- while to_fetch:
17
- resp = await dynamo_client.batch_get_item(RequestItems=to_fetch)
18
- all_items.extend(resp["Responses"].get(table_name, []))
19
- unprocessed = resp.get("UnprocessedKeys", {})
20
- to_fetch = unprocessed if unprocessed.get(table_name) else {}
17
+ # DynamoDB's BatchGetItem has a 100-item limit per request.
18
+ CHUNK_SIZE = 100
19
+
20
+ # Split the keys into chunks of 100
21
+ for i in range(0, len(keys), CHUNK_SIZE):
22
+ chunk_keys = keys[i : i + CHUNK_SIZE]
23
+ to_fetch = {table_name: {"Keys": chunk_keys}}
24
+
25
+ # Inner loop to handle unprocessed keys for the current chunk
26
+ # Max retries of 3
27
+ retries = 3
28
+ while to_fetch and retries > 0:
29
+ retries -= 1
30
+ try:
31
+ resp = await dynamo_client.batch_get_item(RequestItems=to_fetch)
32
+
33
+ if "Responses" in resp and table_name in resp["Responses"]:
34
+ all_items.extend(resp["Responses"][table_name])
35
+
36
+ unprocessed = resp.get("UnprocessedKeys", {})
37
+ # If there are unprocessed keys, set them to be fetched in the next iteration
38
+ if unprocessed and unprocessed.get(table_name):
39
+ logger.warning(
40
+ "Retrying %d unprocessed keys.",
41
+ len(unprocessed[table_name]["Keys"]),
42
+ )
43
+ to_fetch = unprocessed
44
+ else:
45
+ # All keys in the chunk were processed, exit the inner loop
46
+ to_fetch = {}
47
+
48
+ except Exception as e:
49
+ logger.error("Error during batch_get_item for a chunk: %s", e)
50
+ # Stop trying to process this chunk on error and move to the next
51
+ to_fetch = {}
21
52
 
22
53
  return all_items
23
54
 
@@ -100,4 +131,4 @@ async def set_stream_features(
100
131
  "cache_ttl_in_seconds": int(parsed.get("cache_ttl_in_seconds", -1)),
101
132
  }
102
133
  if cache_key in cache_miss:
103
- cache_miss[cache_key][feature_name] = parsed.get("value")
134
+ cache_miss[cache_key][feature_name] = parsed.get("value")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haystack-ml-stack
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Functions related to Haystack ML
5
5
  Author-email: Oscar Vega <oscar@haystack.tv>
6
6
  License: MIT
@@ -0,0 +1,10 @@
1
+ haystack_ml_stack/__init__.py,sha256=8agfBhexMCMsnLx9WmLeKaLEILI5064mTlMnICXyTfU,75
2
+ haystack_ml_stack/app.py,sha256=GF2F3Qg0m0xyZ04tI2iW2Xmzr18NyyLI7dsfJ_LkByM,5221
3
+ haystack_ml_stack/cache.py,sha256=X5sWARTvxbkCnl6NdILa4lwDt7iAm5Wl9CcgoEv7E6s,506
4
+ haystack_ml_stack/dynamo.py,sha256=npYCoYwLs2PyxxjHGpZWkk-aEwKoD6rKx_3snrcO3YA,4544
5
+ haystack_ml_stack/model_store.py,sha256=ON1R1gl_TWhP20l383DwDPcuKEJJpmC1ziqSL4Mt-rw,1179
6
+ haystack_ml_stack/settings.py,sha256=2JH-H7NtKaVbc11jq4Yl3h5TjCve98g--8pqNvQjfj4,574
7
+ haystack_ml_stack-0.1.1.dist-info/METADATA,sha256=jgRcnCn2AYXTIzOFItk2yv8ZnRLaGR7c3GH5ZlwhdkM,3901
8
+ haystack_ml_stack-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ haystack_ml_stack-0.1.1.dist-info/top_level.txt,sha256=S3g0eH9BeMKygOIwmfB25jtCiAfj0b3CbwPTalcIwvc,18
10
+ haystack_ml_stack-0.1.1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- haystack_ml_stack/__init__.py,sha256=_XV9uYskJeiiu8Gj8k2Bxp2IWVgE3iJULbis-28n8D8,75
2
- haystack_ml_stack/app.py,sha256=GF2F3Qg0m0xyZ04tI2iW2Xmzr18NyyLI7dsfJ_LkByM,5221
3
- haystack_ml_stack/cache.py,sha256=X5sWARTvxbkCnl6NdILa4lwDt7iAm5Wl9CcgoEv7E6s,506
4
- haystack_ml_stack/dynamo.py,sha256=1WeQReIZHX3YvjC6abwznqN67-Lax_YEMJ9z_xqw0Z4,3312
5
- haystack_ml_stack/model_store.py,sha256=ON1R1gl_TWhP20l383DwDPcuKEJJpmC1ziqSL4Mt-rw,1179
6
- haystack_ml_stack/settings.py,sha256=2JH-H7NtKaVbc11jq4Yl3h5TjCve98g--8pqNvQjfj4,574
7
- haystack_ml_stack-0.1.0.dist-info/METADATA,sha256=Vs3t-nBxxmlBsZEnTKj0fOn1Ot2jKfD70nrKpQUg9dk,3901
8
- haystack_ml_stack-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- haystack_ml_stack-0.1.0.dist-info/top_level.txt,sha256=S3g0eH9BeMKygOIwmfB25jtCiAfj0b3CbwPTalcIwvc,18
10
- haystack_ml_stack-0.1.0.dist-info/RECORD,,