haystack-ml-stack 0.3.1__tar.gz → 0.3.3__tar.gz

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.
Files changed (24) hide show
  1. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/PKG-INFO +1 -1
  2. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/pyproject.toml +1 -1
  3. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/__init__.py +1 -1
  4. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/app.py +2 -1
  5. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/generated/v1/features_pb2.py +2 -2
  6. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/generated/v1/features_pb2.pyi +15 -15
  7. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/utils.py +1 -1
  8. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack.egg-info/PKG-INFO +1 -1
  9. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/tests/test_utils.py +52 -0
  10. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/README.md +0 -0
  11. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/setup.cfg +0 -0
  12. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/_serializers.py +0 -0
  13. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/cache.py +0 -0
  14. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/dynamo.py +0 -0
  15. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/exceptions.py +0 -0
  16. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/generated/__init__.py +0 -0
  17. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/generated/v1/__init__.py +0 -0
  18. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/model_store.py +0 -0
  19. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack/settings.py +0 -0
  20. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack.egg-info/SOURCES.txt +0 -0
  21. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack.egg-info/dependency_links.txt +0 -0
  22. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack.egg-info/requires.txt +0 -0
  23. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/src/haystack_ml_stack.egg-info/top_level.txt +0 -0
  24. {haystack_ml_stack-0.3.1 → haystack_ml_stack-0.3.3}/tests/test_serializers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haystack-ml-stack
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Functions related to Haystack ML
5
5
  Author-email: Oscar Vega <oscar@haystack.tv>
6
6
  License: MIT
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "haystack-ml-stack"
8
- version = "0.3.1"
8
+ version = "0.3.3"
9
9
  description = "Functions related to Haystack ML"
10
10
  readme = "README.md"
11
11
  authors = [{ name = "Oscar Vega", email = "oscar@haystack.tv" }]
@@ -11,4 +11,4 @@ from ._serializers import SerializerRegistry, FeatureRegistryId
11
11
 
12
12
  __all__ = [*__all__, "SerializerRegistry", "FeatureRegistryId"]
13
13
 
14
- __version__ = "0.3.1"
14
+ __version__ = "0.3.3"
@@ -6,6 +6,7 @@ from http import HTTPStatus
6
6
  from typing import Any, Dict, List, Optional
7
7
  import time
8
8
  from contextlib import asynccontextmanager, AsyncExitStack
9
+ import traceback
9
10
 
10
11
  import aiobotocore.session
11
12
  from aiobotocore.config import AioConfig
@@ -253,7 +254,7 @@ def create_app(
253
254
  model_output = model["predict"](model_input, model["params"])
254
255
  predict_end = time.perf_counter_ns()
255
256
  except Exception as e:
256
- logger.error("Model prediction failed: %s", e)
257
+ logger.error("Model prediction failed: \n%s", traceback.format_exc())
257
258
  raise HTTPException(
258
259
  status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
259
260
  detail="Model prediction failed",
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: features.proto
5
- # Protobuf Python Version: 6.33.4
5
+ # Protobuf Python Version: 6.33.2
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -13,7 +13,7 @@ _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
15
  33,
16
- 4,
16
+ 2,
17
17
  '',
18
18
  'features.proto'
19
19
  )
@@ -7,7 +7,7 @@ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
7
7
  DESCRIPTOR: _descriptor.FileDescriptor
8
8
 
9
9
  class EntryContextCounts(_message.Message):
10
- __slots__ = ("attempts", "watched")
10
+ __slots__ = ()
11
11
  ATTEMPTS_FIELD_NUMBER: _ClassVar[int]
12
12
  WATCHED_FIELD_NUMBER: _ClassVar[int]
13
13
  attempts: int
@@ -15,7 +15,7 @@ class EntryContextCounts(_message.Message):
15
15
  def __init__(self, attempts: _Optional[int] = ..., watched: _Optional[int] = ...) -> None: ...
16
16
 
17
17
  class SelectCounts(_message.Message):
18
- __slots__ = ("total_selects", "total_selects_and_watched", "total_browsed")
18
+ __slots__ = ()
19
19
  TOTAL_SELECTS_FIELD_NUMBER: _ClassVar[int]
20
20
  TOTAL_SELECTS_AND_WATCHED_FIELD_NUMBER: _ClassVar[int]
21
21
  TOTAL_BROWSED_FIELD_NUMBER: _ClassVar[int]
@@ -25,7 +25,7 @@ class SelectCounts(_message.Message):
25
25
  def __init__(self, total_selects: _Optional[int] = ..., total_selects_and_watched: _Optional[int] = ..., total_browsed: _Optional[int] = ...) -> None: ...
26
26
 
27
27
  class EntryContextPWatched(_message.Message):
28
- __slots__ = ("autoplay", "sel_thumb", "choose_next", "ch_swtch", "launch_first_in_session")
28
+ __slots__ = ()
29
29
  AUTOPLAY_FIELD_NUMBER: _ClassVar[int]
30
30
  SEL_THUMB_FIELD_NUMBER: _ClassVar[int]
31
31
  CHOOSE_NEXT_FIELD_NUMBER: _ClassVar[int]
@@ -39,7 +39,7 @@ class EntryContextPWatched(_message.Message):
39
39
  def __init__(self, autoplay: _Optional[_Union[EntryContextCounts, _Mapping]] = ..., sel_thumb: _Optional[_Union[EntryContextCounts, _Mapping]] = ..., choose_next: _Optional[_Union[EntryContextCounts, _Mapping]] = ..., ch_swtch: _Optional[_Union[EntryContextCounts, _Mapping]] = ..., launch_first_in_session: _Optional[_Union[EntryContextCounts, _Mapping]] = ...) -> None: ...
40
40
 
41
41
  class PositionPSelect(_message.Message):
42
- __slots__ = ("first_pos", "second_pos", "third_pos", "rest_pos")
42
+ __slots__ = ()
43
43
  FIRST_POS_FIELD_NUMBER: _ClassVar[int]
44
44
  SECOND_POS_FIELD_NUMBER: _ClassVar[int]
45
45
  THIRD_POS_FIELD_NUMBER: _ClassVar[int]
@@ -51,7 +51,7 @@ class PositionPSelect(_message.Message):
51
51
  def __init__(self, first_pos: _Optional[_Union[SelectCounts, _Mapping]] = ..., second_pos: _Optional[_Union[SelectCounts, _Mapping]] = ..., third_pos: _Optional[_Union[SelectCounts, _Mapping]] = ..., rest_pos: _Optional[_Union[SelectCounts, _Mapping]] = ...) -> None: ...
52
52
 
53
53
  class BrowsedDebiasedPositionPSelects(_message.Message):
54
- __slots__ = ("up_to_4_browsed", "all_browsed")
54
+ __slots__ = ()
55
55
  UP_TO_4_BROWSED_FIELD_NUMBER: _ClassVar[int]
56
56
  ALL_BROWSED_FIELD_NUMBER: _ClassVar[int]
57
57
  up_to_4_browsed: PositionPSelect
@@ -59,7 +59,7 @@ class BrowsedDebiasedPositionPSelects(_message.Message):
59
59
  def __init__(self, up_to_4_browsed: _Optional[_Union[PositionPSelect, _Mapping]] = ..., all_browsed: _Optional[_Union[PositionPSelect, _Mapping]] = ...) -> None: ...
60
60
 
61
61
  class StreamPSelect(_message.Message):
62
- __slots__ = ("version", "data")
62
+ __slots__ = ()
63
63
  VERSION_FIELD_NUMBER: _ClassVar[int]
64
64
  DATA_FIELD_NUMBER: _ClassVar[int]
65
65
  version: int
@@ -67,7 +67,7 @@ class StreamPSelect(_message.Message):
67
67
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Union[BrowsedDebiasedPositionPSelects, _Mapping]] = ...) -> None: ...
68
68
 
69
69
  class StreamPWatched(_message.Message):
70
- __slots__ = ("version", "data")
70
+ __slots__ = ()
71
71
  VERSION_FIELD_NUMBER: _ClassVar[int]
72
72
  DATA_FIELD_NUMBER: _ClassVar[int]
73
73
  version: int
@@ -75,7 +75,7 @@ class StreamPWatched(_message.Message):
75
75
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Union[EntryContextPWatched, _Mapping]] = ...) -> None: ...
76
76
 
77
77
  class UserPWatched(_message.Message):
78
- __slots__ = ("version", "data")
78
+ __slots__ = ()
79
79
  VERSION_FIELD_NUMBER: _ClassVar[int]
80
80
  DATA_FIELD_NUMBER: _ClassVar[int]
81
81
  version: int
@@ -83,9 +83,9 @@ class UserPWatched(_message.Message):
83
83
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Union[EntryContextPWatched, _Mapping]] = ...) -> None: ...
84
84
 
85
85
  class UserPersonalizingPWatched(_message.Message):
86
- __slots__ = ("version", "data")
86
+ __slots__ = ()
87
87
  class DataEntry(_message.Message):
88
- __slots__ = ("key", "value")
88
+ __slots__ = ()
89
89
  KEY_FIELD_NUMBER: _ClassVar[int]
90
90
  VALUE_FIELD_NUMBER: _ClassVar[int]
91
91
  key: str
@@ -98,7 +98,7 @@ class UserPersonalizingPWatched(_message.Message):
98
98
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Mapping[str, EntryContextPWatched]] = ...) -> None: ...
99
99
 
100
100
  class UserPSelect(_message.Message):
101
- __slots__ = ("version", "data")
101
+ __slots__ = ()
102
102
  VERSION_FIELD_NUMBER: _ClassVar[int]
103
103
  DATA_FIELD_NUMBER: _ClassVar[int]
104
104
  version: int
@@ -106,9 +106,9 @@ class UserPSelect(_message.Message):
106
106
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Union[BrowsedDebiasedPositionPSelects, _Mapping]] = ...) -> None: ...
107
107
 
108
108
  class UserPersonalizingPSelect(_message.Message):
109
- __slots__ = ("version", "data")
109
+ __slots__ = ()
110
110
  class DataEntry(_message.Message):
111
- __slots__ = ("key", "value")
111
+ __slots__ = ()
112
112
  KEY_FIELD_NUMBER: _ClassVar[int]
113
113
  VALUE_FIELD_NUMBER: _ClassVar[int]
114
114
  key: str
@@ -121,9 +121,9 @@ class UserPersonalizingPSelect(_message.Message):
121
121
  def __init__(self, version: _Optional[int] = ..., data: _Optional[_Mapping[str, BrowsedDebiasedPositionPSelects]] = ...) -> None: ...
122
122
 
123
123
  class StreamSimilarityScores(_message.Message):
124
- __slots__ = ("version", "data")
124
+ __slots__ = ()
125
125
  class DataEntry(_message.Message):
126
- __slots__ = ("key", "value")
126
+ __slots__ = ()
127
127
  KEY_FIELD_NUMBER: _ClassVar[int]
128
128
  VALUE_FIELD_NUMBER: _ClassVar[int]
129
129
  key: str
@@ -204,7 +204,7 @@ def device_watched_count_cleanups(
204
204
 
205
205
  counts_obj: StreamPWatched = stream.get(
206
206
  f"PWATCHED#24H#{device_type}", StreamPWatched()
207
- )
207
+ ).data
208
208
  if out is None:
209
209
  out = {}
210
210
  out = _cleanup_entry_context_counts(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haystack-ml-stack
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Functions related to Haystack ML
5
5
  Author-email: Oscar Vega <oscar@haystack.tv>
6
6
  License: MIT
@@ -372,6 +372,58 @@ def test_stream_pwatched_cleanup():
372
372
  assert (actual == expected).all()
373
373
 
374
374
 
375
+ def test_device_stream_pwatched_cleanup():
376
+ stream_pwatched_data = {
377
+ "version": 1,
378
+ "data": {
379
+ "autoplay": {"attempts": 1, "watched": 1},
380
+ "ch_swtch": {"attempts": 2, "watched": 0},
381
+ },
382
+ }
383
+ stream_pwatched = features_pb2_v1.StreamPWatched()
384
+ ProtoParseDict(js_dict=stream_pwatched_data, message=stream_pwatched)
385
+ stream = {"PWATCHED#24H#TV": stream_pwatched}
386
+ out = {}
387
+ utils.device_watched_count_cleanups(
388
+ stream=stream,
389
+ entry_contexts=["autoplay", "ch_swtch", "sel_thumb"],
390
+ device_type="TV",
391
+ out=out,
392
+ )
393
+ expected = pd.Series(
394
+ {
395
+ "STREAM_AUTOPLAY_TV_24H_TOTAL_ATTEMPTS": 1,
396
+ "STREAM_AUTOPLAY_TV_24H_TOTAL_WATCHED": 1,
397
+ "STREAM_CH_SWTCH_TV_24H_TOTAL_ATTEMPTS": 2,
398
+ "STREAM_CH_SWTCH_TV_24H_TOTAL_WATCHED": 0,
399
+ "STREAM_SEL_THUMB_TV_24H_TOTAL_ATTEMPTS": 0,
400
+ "STREAM_SEL_THUMB_TV_24H_TOTAL_WATCHED": 0,
401
+ }
402
+ )
403
+ actual = pd.Series(out).loc[expected.index]
404
+ assert (actual == expected).all()
405
+ stream = {"PWATCHED#24H#MOBILE": stream_pwatched}
406
+ out = {}
407
+ utils.device_watched_count_cleanups(
408
+ stream=stream,
409
+ entry_contexts=["autoplay", "ch_swtch", "sel_thumb"],
410
+ device_type="MOBILE",
411
+ out=out,
412
+ )
413
+ expected = pd.Series(
414
+ {
415
+ "STREAM_AUTOPLAY_MOBILE_24H_TOTAL_ATTEMPTS": 1,
416
+ "STREAM_AUTOPLAY_MOBILE_24H_TOTAL_WATCHED": 1,
417
+ "STREAM_CH_SWTCH_MOBILE_24H_TOTAL_ATTEMPTS": 2,
418
+ "STREAM_CH_SWTCH_MOBILE_24H_TOTAL_WATCHED": 0,
419
+ "STREAM_SEL_THUMB_MOBILE_24H_TOTAL_ATTEMPTS": 0,
420
+ "STREAM_SEL_THUMB_MOBILE_24H_TOTAL_WATCHED": 0,
421
+ }
422
+ )
423
+ actual = pd.Series(out).loc[expected.index]
424
+ assert (actual == expected).all()
425
+
426
+
375
427
  def test_stream_global_pselect_cleanup():
376
428
  stream_pselect_data = {
377
429
  "version": 1,