MCPcopy
hub / github.com/feast-dev/feast / delete

Function delete

sdk/python/feast/cli/cli.py:154–200  ·  view source on GitHub ↗

Delete Feast Object

(ctx: click.Context, object_id: str)

Source from the content-addressed store, hash-verified

152@click.argument("object_id")
153@click.pass_context
154def delete(ctx: click.Context, object_id: str):
155 """
156 Delete Feast Object
157 """
158 repo = ctx.obj["CHDIR"]
159 fs_yaml_file = ctx.obj["FS_YAML_FILE"]
160 cli_check_repo(repo, fs_yaml_file)
161 store = create_feature_store(ctx)
162
163 e = None
164 object_type = None
165
166 # Order matters if names can overlap between types,
167 # though typically they shouldn't in a well-structured feature store.
168 object_getters_and_types = [
169 (store.get_entity, "Entity"),
170 (store.get_feature_view, "FeatureView"),
171 (store.get_feature_service, "FeatureService"),
172 (store.get_data_source, "DataSource"),
173 (store.get_saved_dataset, "SavedDataset"),
174 (store.get_validation_reference, "ValidationReference"),
175 (store.get_stream_feature_view, "StreamFeatureView"),
176 (store.get_on_demand_feature_view, "OnDemandFeatureView"),
177 # Add other get_* methods here if needed
178 ]
179
180 for getter, obj_type_str in object_getters_and_types:
181 try:
182 potential_e = getter(object_id) # type: ignore[operator]
183 if potential_e:
184 e = potential_e
185 object_type = obj_type_str
186 break
187 except Exception:
188 pass
189
190 if isinstance(e, list):
191 e = e[0]
192 if e:
193 store.apply([e], objects_to_delete=[e], partial=False)
194 print(
195 f"{Style.BRIGHT + Fore.RED}Deleted {Style.BRIGHT + Fore.GREEN}{object_type} {Fore.YELLOW}{object_id} from {Fore.GREEN}{store.project}.{Style.RESET_ALL}"
196 )
197 else:
198 print(
199 f"{Style.BRIGHT + Fore.GREEN}Object not found. Deletion skipped.{Style.RESET_ALL}"
200 )
201
202
203@cli.command()

Calls 4

cli_check_repoFunction · 0.90
create_feature_storeFunction · 0.90
getterFunction · 0.85
applyMethod · 0.80

Tested by 1

createInvalidOidcSecretFunction · 0.68