Use the clone_filter() method to clone from another FilterManager instance into the current FilterManager.
Required Parameter
- source_filter_manager
- Specifies the source FilterManager to clone from.
Optional Parameters
- filter_id_to_apply
- Specifies which filter ID to set as active after cloning.
Default value: 1
ID must exist in the source FilterManager. - clone_mode
- Specifies the cloning strategy.
Default Value: 'soft'
Permitted Values: 'soft', 'hard'
- 'soft' — Links to the source filter manager's artifacts without copying data (shared reference).
- 'hard' — Creates independent artifacts in the current filter manager by copying data from the source (data duplication).
Example Setup
>>> from teradataml import load_example_data, DataFrame, FeatureStore, FilterManager
>>> load_example_data('dataframe', 'admissions_train')
>>> df = DataFrame("admissions_train")
Create a FeatureStore.
>>> fs = FeatureStore(repo='vfs_v1', data_domain='sales')
Repo vfs_v1 does not exist. Run FeatureStore.setup() to create the repo and setup FeatureStore.
>>> fs.setup()
Create a source FilterManager and load filter definitions.
>>> fm = FilterManager(repo='vfs_v1', name='stats_filter_manager')
Filter Manager 'stats_filter_manager' does not exist. Run FilterManager.load_filter() to create it.
>>> fm.load_filter(df=df.groupby('stats').count()[['stats']])
True
>>> fm.list_filters()
stats filter_id 3 Novice 2 Beginner 1 Advanced
>>> fm.get_current_filter()
stats 0 Advanced
Example 1: Create a New FilterManager and Perform a Soft Clone of Filters from the Source FilterManager
>>> fm2 = FilterManager(repo='vfs_v1', name='stats_filter_copy') >>> fm2.clone_filter(source_filter_manager=fm, clone_mode='soft')
FilterManager(repo=vfs_v1, name=stats_filter_copy, filters=3)
>>> fm2.list_filters()
stats filter_id 3 Novice 2 Beginner 1 Advanced
>>> fm2.get_current_filter()
stats 0 Advanced
Example 2: Create a New FilterManager and Perform a Hard Clone of Filters From the Source FilterManager and Point to Filter Scenario with filter_id = 2 After Cloning
>>> fm3 = FilterManager(repo='vfs_v1', name='stats_filter_hard_copy') >>> fm3.clone_filter(source_filter_manager=fm, filter_id_to_apply=2, clone_mode='hard')
FilterManager(repo=vfs_v1, name=stats_filter_hard_copy, filters=3)
>>> fm3.list_filters()
stats filter_id 3 Novice 2 Beginner 1 Advanced
>>> fm3.get_current_filter()
stats 0 Beginner