chalkpy 2.93.3__py3-none-any.whl → 2.93.4__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.
chalk/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.93.3"
1
+ __version__ = "2.93.4"
@@ -405,12 +405,10 @@ class Feature(Generic[_TPrim, _TRich]):
405
405
 
406
406
  if offline_ttl is None:
407
407
  offline_ttl = timedelta(0)
408
- elif offline_ttl is ...:
409
- # Should we allow the offline_ttl to be set via the class decorator?
410
- offline_ttl = CHALK_MAX_TIMEDELTA
411
408
  elif isinstance(offline_ttl, str):
412
409
  offline_ttl = parse_chalk_duration(offline_ttl)
413
- self.offline_ttl = offline_ttl
410
+ if offline_ttl is not ...:
411
+ self.offline_ttl = offline_ttl
414
412
 
415
413
  self.cache_strategy = cache_strategy
416
414
 
@@ -179,6 +179,7 @@ class FeaturesImpl(metaclass=FeaturesMeta):
179
179
  __chalk_is_singleton__: ClassVar[bool]
180
180
  __chalk_etl_offline_to_online__: ClassVar[bool]
181
181
  __chalk_max_staleness__: ClassVar[timedelta]
182
+ __chalk_offline_ttl__: ClassVar[timedelta]
182
183
  __chalk_cache_strategy__: ClassVar[CacheStrategy]
183
184
  __chalk_namespace__: ClassVar[str]
184
185
  __chalk_primary__: ClassVar[Feature | None] = None # The primary key feature
@@ -34,7 +34,7 @@ from chalk.streams import Windowed
34
34
  from chalk.streams._windows import GroupByWindowed, get_name_with_duration
35
35
  from chalk.utils import notebook
36
36
  from chalk.utils.collections import ensure_tuple
37
- from chalk.utils.duration import Duration, parse_chalk_duration, parse_chalk_duration_s
37
+ from chalk.utils.duration import CHALK_MAX_TIMEDELTA, Duration, parse_chalk_duration, parse_chalk_duration_s
38
38
  from chalk.utils.metaprogramming import MISSING, set_new_attribute
39
39
  from chalk.utils.string import to_snake_case
40
40
  from chalk.stores.online_store_config import OnlineStoreConfig
@@ -65,6 +65,7 @@ def features(
65
65
  singleton: bool = False,
66
66
  cache_nulls: CacheNullsType = True,
67
67
  cache_defaults: CacheDefaultsType = True,
68
+ offline_ttl: Optional[Duration] = None,
68
69
  ) -> Callable[[Type[T]], Type[T]]: ...
69
70
 
70
71
 
@@ -84,6 +85,7 @@ def features(
84
85
  online_store_config: Optional[OnlineStoreConfig] = None,
85
86
  cache_nulls: CacheNullsType = True,
86
87
  cache_defaults: CacheDefaultsType = True,
88
+ offline_ttl: Optional[Duration] = None,
87
89
  ) -> Union[Callable[[Type[T]], Type[T]], Type[T]]:
88
90
  """Chalk lets you spell out your features directly in Python.
89
91
 
@@ -141,6 +143,8 @@ def features(
141
143
  The `cache_nulls` and `cache_defaults` options can be used together on the same feature with the
142
144
  following exceptions: if `cache_nulls=False`, then `cache_defaults` cannot be `"evict_defaults"`, and if
143
145
  `cache_nulls="evict_defaults"`, then `cache_defaults` cannot be `False`.
146
+ offline_ttl
147
+ Sets a maximum age for values eligible to be retrieved from the offline store, defined in relation to the query's current point-in-time.
144
148
  Other Parameters
145
149
  ----------------
146
150
  cls
@@ -186,6 +190,7 @@ def features(
186
190
  node=source_info and source_info.tree,
187
191
  )
188
192
  nonlocal max_staleness
193
+ nonlocal offline_ttl
189
194
  if name is not None and re.sub(r"[^a-z_0-9]", "", namespace) != namespace:
190
195
  error_builder.add_diagnostic(
191
196
  message=(
@@ -220,6 +225,19 @@ def features(
220
225
  raise_error=ValueError,
221
226
  code="13",
222
227
  )
228
+ if offline_ttl is None:
229
+ offline_ttl = CHALK_MAX_TIMEDELTA
230
+ else:
231
+ try:
232
+ offline_ttl = parse_chalk_duration(offline_ttl)
233
+ except ValueError as e:
234
+ error_builder.add_diagnostic(
235
+ message=f"Invalid 'offline_ttl'. {e.args[0]}",
236
+ label=f"invalid duration {offline_ttl}",
237
+ range=error_builder.decorator_kwarg_value_range(kwarg="offline_ttl"),
238
+ raise_error=ValueError,
239
+ code="13",
240
+ )
223
241
 
224
242
  cache_strategy = get_cache_strategy_from_cache_settings(
225
243
  cache_nulls=cache_nulls,
@@ -271,6 +289,7 @@ def features(
271
289
  tags=ensure_tuple(tags),
272
290
  etl_offline_to_online=etl_offline_to_online,
273
291
  max_staleness=max_staleness,
292
+ offline_ttl=offline_ttl,
274
293
  cache_strategy=cache_strategy,
275
294
  namespace=namespace,
276
295
  singleton=singleton,
@@ -419,6 +438,7 @@ def _get_field(
419
438
  class_tags: Optional[Tuple[str, ...]],
420
439
  class_etl_offline_to_online: bool,
421
440
  class_max_staleness: timedelta,
441
+ class_offline_ttl: timedelta,
422
442
  namespace: str,
423
443
  is_singleton: bool,
424
444
  class_cache_strategy: CacheStrategy = CacheStrategy.ALL,
@@ -521,6 +541,7 @@ def _get_field(
521
541
  class_tags=class_tags,
522
542
  class_etl_offline_to_online=class_etl_offline_to_online,
523
543
  class_max_staleness=class_max_staleness,
544
+ class_offline_ttl=class_offline_ttl,
524
545
  class_cache_strategy=class_cache_strategy,
525
546
  error_builder=error_builder,
526
547
  )
@@ -534,6 +555,7 @@ def _process_field(
534
555
  class_tags: Optional[Tuple[str, ...]],
535
556
  class_etl_offline_to_online: bool,
536
557
  class_max_staleness: timedelta,
558
+ class_offline_ttl: timedelta,
537
559
  error_builder: FeatureClassErrorBuilder,
538
560
  class_cache_strategy: CacheStrategy = CacheStrategy.ALL,
539
561
  ) -> Feature:
@@ -596,6 +618,10 @@ def _process_field(
596
618
  if not hasattr(f, "max_staleness"):
597
619
  f.max_staleness = class_max_staleness
598
620
 
621
+ # The attribute is not defined if the feature intends to use the class default
622
+ if not hasattr(f, "offline_ttl"):
623
+ f.offline_ttl = class_offline_ttl
624
+
599
625
  f_cache_nulls, f_cache_defaults = get_cache_settings_from_strategy(f.cache_strategy)
600
626
  class_cache_nulls, class_cache_defaults = get_cache_settings_from_strategy(class_cache_strategy)
601
627
 
@@ -800,6 +826,7 @@ def _process_class(
800
826
  tags: Tuple[str, ...],
801
827
  etl_offline_to_online: bool,
802
828
  max_staleness: timedelta,
829
+ offline_ttl: timedelta,
803
830
  namespace: str,
804
831
  singleton: bool,
805
832
  online_store_config: Optional[OnlineStoreConfig],
@@ -1123,6 +1150,7 @@ def _process_class(
1123
1150
  typ=int,
1124
1151
  pyarrow_dtype=pa.uint8(),
1125
1152
  max_staleness=None,
1153
+ offline_ttl=None,
1126
1154
  cache_strategy=CacheStrategy.ALL,
1127
1155
  etl_offline_to_online=False,
1128
1156
  is_autogenerated=True,
@@ -1204,6 +1232,7 @@ def _process_class(
1204
1232
  class_tags=tuple(cls.__chalk_tags__),
1205
1233
  class_etl_offline_to_online=cls.__chalk_etl_offline_to_online__,
1206
1234
  class_max_staleness=cls.__chalk_max_staleness__,
1235
+ class_offline_ttl=cls.__chalk_offline_ttl__,
1207
1236
  class_cache_strategy=cls.__chalk_cache_strategy__,
1208
1237
  )
1209
1238
 
@@ -1237,6 +1266,7 @@ def _process_class(
1237
1266
  set_new_attribute(cls=cls, name="__chalk_owner__", value=owner)
1238
1267
  set_new_attribute(cls=cls, name="__chalk_tags__", value=list(tags))
1239
1268
  set_new_attribute(cls=cls, name="__chalk_max_staleness__", value=max_staleness)
1269
+ set_new_attribute(cls=cls, name="__chalk_offline_ttl__", value=offline_ttl)
1240
1270
  set_new_attribute(cls=cls, name="__chalk_cache_strategy__", value=cache_strategy)
1241
1271
  set_new_attribute(cls=cls, name="__is_features__", value=True)
1242
1272
  set_new_attribute(cls=cls, name="__len__", value=_len_fn)
@@ -1270,6 +1300,7 @@ def _process_class(
1270
1300
  class_tags=tags,
1271
1301
  class_etl_offline_to_online=etl_offline_to_online,
1272
1302
  class_max_staleness=max_staleness,
1303
+ class_offline_ttl=offline_ttl,
1273
1304
  class_cache_strategy=cache_strategy,
1274
1305
  namespace=namespace,
1275
1306
  is_singleton=singleton,
@@ -1325,6 +1356,7 @@ def _process_class(
1325
1356
  class_tags=tags,
1326
1357
  class_etl_offline_to_online=etl_offline_to_online,
1327
1358
  class_max_staleness=max_staleness,
1359
+ class_offline_ttl=offline_ttl,
1328
1360
  class_cache_strategy=cache_strategy,
1329
1361
  error_builder=error_builder,
1330
1362
  )
@@ -1532,6 +1564,7 @@ def _class_setattr(
1532
1564
  class_tags=tuple(cls.__chalk_tags__),
1533
1565
  class_etl_offline_to_online=cls.__chalk_etl_offline_to_online__,
1534
1566
  class_max_staleness=cls.__chalk_max_staleness__,
1567
+ class_offline_ttl=cls.__chalk_offline_ttl__,
1535
1568
  class_cache_strategy=cls.__chalk_cache_strategy__,
1536
1569
  )
1537
1570
  if existing_feature is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chalkpy
3
- Version: 2.93.3
3
+ Version: 2.93.4
4
4
  Summary: Python SDK for Chalk
5
5
  Author: Chalk AI, Inc.
6
6
  Project-URL: Homepage, https://chalk.ai
@@ -1,5 +1,5 @@
1
1
  chalk/__init__.py,sha256=9YxwkAt3Im0OCMfpmnIB_4PKjZfBCcRmwATLXdHNRm4,2609
2
- chalk/_version.py,sha256=a8M8W7TWOUNnBbncydFQJ2EtW4CRYKZRaSSP5FM-rG0,23
2
+ chalk/_version.py,sha256=utCJDEQ9kRnlcF3Y3HW8XTiSD1NNySR-0CrYIG6jZyo,23
3
3
  chalk/cli.py,sha256=ckqqfOI-A2mT23-rnZzDMmblYj-2x1VBX8ebHlIEn9A,5873
4
4
  chalk/importer.py,sha256=hCEo7eqSfXZWklkFB2geeipGhiD0qNjPBpQJvOBW6N0,63083
5
5
  chalk/prompts.py,sha256=2H9UomLAamdfRTNUdKs9i3VTpiossuyRhntqsAXUhhg,16117
@@ -585,9 +585,9 @@ chalk/features/_last.py,sha256=IyYe0PVAKBu8FRhCZiK6Dy5afKbwDHEUTES5qVXbaZU,1163
585
585
  chalk/features/_tensor.py,sha256=2SQz9cnIywGjHL6LoWj4lrVBa854McFUttJSNV1hKp8,7111
586
586
  chalk/features/_vector.py,sha256=jtJmUTtCaUFru4Fw17PYWozl3pPEdIOCYAuZOqIaN3Y,7205
587
587
  chalk/features/feature_cache_strategy.py,sha256=bXV-tjHfPzUotMpZ3h_D9Xxq-V1CLj_UcVtGIGMpMkI,4942
588
- chalk/features/feature_field.py,sha256=tLP9iybcYa7eM2eJJ0iSRks-ptyabA0l_SAJ83t6nEw,93758
589
- chalk/features/feature_set.py,sha256=yNi0_J4CylAVkVp1Y67qV6i8vHMdE0p99DnyLPABPHI,12406
590
- chalk/features/feature_set_decorator.py,sha256=HMGnQdXQevpsTCNGIG2njViHDnm1ltFoZDhABFkp3Dw,65059
588
+ chalk/features/feature_field.py,sha256=A2QU5lKKo1QSKC6wWH6xLLgKjHzT2c_WJ3ZuA4XyHJM,93637
589
+ chalk/features/feature_set.py,sha256=Hhf2PhdaYbdfCdo6DmsXoFKHR-CUcI-FIGLM_pN4HFE,12453
590
+ chalk/features/feature_set_decorator.py,sha256=EqW8qDUZzzcSdHCg8sTjqIA1FmxQ3UuzXuliThr7KU4,66580
591
591
  chalk/features/feature_time.py,sha256=iUk8NDelig81jP7QT3tguyzx5eOZ-YC84OVgJRRKVwo,1639
592
592
  chalk/features/feature_wrapper.py,sha256=OolNWGGX67IAEMHCObFvOCpH5EmwjbMvMygRSBJJtu0,19259
593
593
  chalk/features/filter.py,sha256=2ldMbqvXC-nJ0jc-OZ36qHtrej-Jkx4TNQ1W_NZodAs,11177
@@ -764,8 +764,8 @@ chalk/utils/tracing.py,sha256=Glx8YrtjWy0zE5YbpgfgcsLDshAKnnYm9poiWNeCxXs,11075
764
764
  chalk/utils/weak_set_by_identity.py,sha256=VmikA_laYwFeOphCwXJIuyOIkrdlQe0bSzaXq7onoQw,953
765
765
  chalk/utils/pydanticutil/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
766
766
  chalk/utils/pydanticutil/pydantic_compat.py,sha256=O575lLYJ5GvZC4HMzR9yATxf9XwjC6NrDUXbNwZidlE,3031
767
- chalkpy-2.93.3.dist-info/METADATA,sha256=RSXT5f7CE9lqU59166jt7xmFAmch5JkwBKp18rgDgqs,27494
768
- chalkpy-2.93.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
769
- chalkpy-2.93.3.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
770
- chalkpy-2.93.3.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
771
- chalkpy-2.93.3.dist-info/RECORD,,
767
+ chalkpy-2.93.4.dist-info/METADATA,sha256=YmIFo4vQ1F-AsT9gysGlfwvEo_6yD_5QFHPfM-pUDKI,27494
768
+ chalkpy-2.93.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
769
+ chalkpy-2.93.4.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
770
+ chalkpy-2.93.4.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
771
+ chalkpy-2.93.4.dist-info/RECORD,,