2020import logging
2121import time
2222import warnings
23- from datetime import date , datetime , timedelta
23+ from datetime import date , datetime
2424from typing import (
2525 Any ,
2626 Dict ,
@@ -150,33 +150,8 @@ def __init__(
150150 ]
151151 ] = None ,
152152 storage_connector : Union [sc .StorageConnector , Dict [str , Any ]] = None ,
153- ttl : Optional [Union [int , float , timedelta ]] = None ,
154- ttl_enabled : Optional [bool ] = None ,
155153 ** kwargs ,
156154 ) -> None :
157- """Initialize a feature group object.
158-
159- # Arguments
160- name: Name of the feature group to create
161- version: Version number of the feature group
162- featurestore_id: ID of the feature store to create the feature group in
163- location: Location to store the feature group data
164- event_time: Event time column for the feature group
165- online_enabled: Whether to enable online serving for this feature group
166- id: ID of the feature group
167- embedding_index: Embedding index configuration for vector similarity search
168- expectation_suite: Great Expectations suite for data validation
169- online_topic_name: Name of the Kafka topic for online serving
170- topic_name: Name of the Kafka topic for streaming
171- notification_topic_name: Name of the Kafka topic for notifications
172- deprecated: Whether this feature group is deprecated
173- online_config: Configuration for online serving
174- data_source: Data source configuration
175- storage_connector: Storage connector configuration
176- ttl: Time-to-live (TTL) configuration for this feature group
177- ttl_enabled: Whether to enable time-to-live (TTL) for this feature group. Defaults to True if ttl is set.
178- **kwargs: Additional keyword arguments
179- """
180155 self ._version = version
181156 self ._name = name
182157 self .event_time = event_time
@@ -192,8 +167,6 @@ def __init__(
192167 self ._feature_store = None
193168 self ._variable_api : VariableApi = VariableApi ()
194169 self ._alert_api = alerts_api .AlertsApi ()
195- self .ttl = ttl
196- self ._ttl_enabled = ttl_enabled if ttl_enabled is not None else ttl is not None
197170
198171 if storage_connector is not None and isinstance (storage_connector , dict ):
199172 self ._storage_connector = sc .StorageConnector .from_response_json (
@@ -2411,128 +2384,6 @@ def features(self, new_features: List["feature.Feature"]) -> None:
24112384 def _get_project_name (self ) -> str :
24122385 return util .strip_feature_store_suffix (self .feature_store_name )
24132386
2414- @property
2415- def ttl (self ) -> Optional [int ]:
2416- """Get the time-to-live duration in seconds for features in this group.
2417-
2418- The TTL determines how long features should be retained before being automatically removed.
2419- The value is always returned in seconds, regardless of how it was originally specified.
2420-
2421- # Returns
2422- int: The TTL value in seconds, or None if no TTL is set.
2423- """
2424- return self ._ttl
2425-
2426- @ttl .setter
2427- def ttl (self , new_ttl : Optional [Union [int , float , timedelta ]]) -> None :
2428- """Set the time-to-live duration for features in this group.
2429-
2430- # Arguments
2431- new_ttl: The new TTL value. Can be specified as:
2432- - An integer or float representing seconds
2433- - A timedelta object
2434- - None to remove TTL
2435-
2436- The value will be stored internally in seconds.
2437- """
2438- if new_ttl is not None :
2439- if isinstance (new_ttl , timedelta ):
2440- self ._ttl = int (new_ttl .total_seconds ())
2441- else :
2442- self ._ttl = int (new_ttl )
2443- else :
2444- self ._ttl = None
2445-
2446- @property
2447- def ttl_enabled (self ) -> bool :
2448- """Get whether TTL (time-to-live) is enabled for this feature group.
2449-
2450- # Returns
2451- bool: True if TTL is enabled, False otherwise
2452- """
2453- return self ._ttl_enabled
2454-
2455- @ttl_enabled .setter
2456- def ttl_enabled (self , enabled : bool ) -> None :
2457- """Set whether TTL (time-to-live) is enabled for this feature group.
2458-
2459- # Arguments
2460- enabled: Boolean indicating whether TTL should be enabled
2461- """
2462- self ._ttl_enabled = enabled
2463-
2464- def enable_ttl (
2465- self ,
2466- ttl : Optional [Union [int , float , timedelta ]] = None ,
2467- ) -> Union [FeatureGroupBase , FeatureGroup , ExternalFeatureGroup , SpineGroup ]:
2468- """Enable or update the time-to-live (TTL) configuration of the feature group.
2469- If ttl is not set, the feature group will be enabled with the last TTL value being set.
2470-
2471- !!! example
2472- ```python
2473- # connect to the Feature Store
2474- fs = ...
2475-
2476- # get the Feature Group instance
2477- fg = fs.get_or_create_feature_group(...)
2478-
2479- # Enable TTL with a TTL of 7 days
2480- fg.enable_ttl(timedelta(days=7))
2481-
2482- # Disable TTL
2483- fg.disable_ttl()
2484-
2485- # Enable TTL again with a TTL of 7 days
2486- fg.enable_ttl()
2487- ```
2488-
2489- !!! info "Safe update"
2490- This method updates the TTL configuration safely. In case of failure
2491- your local metadata object will keep the old configuration.
2492-
2493- # Arguments
2494- ttl: Optional new TTL value. Can be specified as:
2495- - An integer or float representing seconds
2496- - A timedelta object
2497- - None to keep current value
2498-
2499- # Returns
2500- `FeatureGroup`. The updated feature group object.
2501-
2502- # Raises
2503- `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
2504- """
2505- self ._feature_group_engine .update_ttl (self , ttl , True )
2506- return self
2507-
2508- def disable_ttl (self ) -> "FeatureGroup" :
2509- """Disable the time-to-live (TTL) configuration of the feature group.
2510-
2511- !!! example
2512- ```python
2513- # connect to the Feature Store
2514- fs = ...
2515-
2516- # get the Feature Group instance
2517- fg = fs.get_or_create_feature_group(...)
2518-
2519- # Disable TTL
2520- fg.disable_ttl()
2521- ```
2522-
2523- !!! info "Safe update"
2524- This method updates the TTL configuration safely. In case of failure
2525- your local metadata object will keep the old configuration.
2526-
2527- # Returns
2528- `FeatureGroup`. The updated feature group object.
2529-
2530- # Raises
2531- `hopsworks.client.exceptions.RestAPIError`: If the backend encounters an error when handling the request
2532- """
2533- self ._feature_group_engine .update_ttl (self , None , False )
2534- return self
2535-
25362387
25372388@typechecked
25382389class FeatureGroup (FeatureGroupBase ):
@@ -2595,8 +2446,6 @@ def __init__(
25952446 Dict [str , Any ],
25962447 ]
25972448 ] = None ,
2598- ttl : Optional [Union [int , float , timedelta ]] = None ,
2599- ttl_enabled : Optional [bool ] = None ,
26002449 ** kwargs ,
26012450 ) -> None :
26022451 super ().__init__ (
@@ -2616,10 +2465,7 @@ def __init__(
26162465 online_config = online_config ,
26172466 storage_connector = storage_connector ,
26182467 data_source = data_source ,
2619- ttl = ttl ,
2620- ttl_enabled = ttl_enabled ,
26212468 )
2622-
26232469 self ._feature_store_name : Optional [str ] = featurestore_name
26242470 self ._description : Optional [str ] = description
26252471 self ._created = created
@@ -3549,7 +3395,7 @@ def insert_stream(
35493395 written to the sink every time there is some update. (3) `"update"`:
35503396 only the rows that were updated in the streaming DataFrame/Dataset will
35513397 be written to the sink every time there are some updates.
3552- If the query doesn' t contain aggregations, it will be equivalent to
3398+ If the query doesn’ t contain aggregations, it will be equivalent to
35533399 append mode. Defaults to `"append"`.
35543400 await_termination: Waits for the termination of this query, either by
35553401 query.stop() or by an exception. If the query has terminated with an
@@ -3989,8 +3835,6 @@ def to_dict(self) -> Dict[str, Any]:
39893835 "transformationFunctions" : [
39903836 tf .to_dict () for tf in self ._transformation_functions
39913837 ],
3992- "ttl" : self .ttl ,
3993- "ttlEnabled" : self ._ttl_enabled ,
39943838 }
39953839 if self ._data_source :
39963840 fg_meta_dict ["dataSource" ] = self ._data_source .to_dict ()
@@ -4229,8 +4073,6 @@ def __init__(
42294073 Dict [str , Any ],
42304074 ]
42314075 ] = None ,
4232- ttl : Optional [Union [int , float , timedelta ]] = None ,
4233- ttl_enabled : Optional [bool ] = None ,
42344076 ** kwargs ,
42354077 ) -> None :
42364078 super ().__init__ (
@@ -4250,8 +4092,6 @@ def __init__(
42504092 online_config = online_config ,
42514093 storage_connector = storage_connector ,
42524094 data_source = data_source ,
4253- ttl = ttl ,
4254- ttl_enabled = ttl_enabled ,
42554095 )
42564096
42574097 self ._feature_store_name = featurestore_name
@@ -4669,8 +4509,6 @@ def to_dict(self) -> Dict[str, Any]:
46694509 "topicName" : self .topic_name ,
46704510 "notificationTopicName" : self .notification_topic_name ,
46714511 "deprecated" : self .deprecated ,
4672- "ttl" : self .ttl ,
4673- "ttlEnabled" : self ._ttl_enabled ,
46744512 }
46754513 if self ._data_source :
46764514 fg_meta_dict ["dataSource" ] = self ._data_source .to_dict ()
0 commit comments