|
47 | 47 | from feast.utils import maybe_local_tz |
48 | 48 |
|
49 | 49 | _logger = logging.getLogger(__name__) |
| 50 | +tagsOption = click.option( |
| 51 | + "--tags", |
| 52 | + help="Filter by tags (e.g. --tags 'key:value' --tags 'key:value, key:value, ...'). Items return when ALL tags match.", |
| 53 | + default=[""], |
| 54 | + multiple=True, |
| 55 | +) |
50 | 56 |
|
51 | 57 |
|
52 | 58 | class NoOptionDefaultFormat(click.Command): |
@@ -226,14 +232,16 @@ def data_source_describe(ctx: click.Context, name: str): |
226 | 232 |
|
227 | 233 |
|
228 | 234 | @data_sources_cmd.command(name="list") |
| 235 | +@tagsOption |
229 | 236 | @click.pass_context |
230 | | -def data_source_list(ctx: click.Context): |
| 237 | +def data_source_list(ctx: click.Context, tags: list[str]): |
231 | 238 | """ |
232 | 239 | List all data sources |
233 | 240 | """ |
234 | 241 | store = create_feature_store(ctx) |
235 | 242 | table = [] |
236 | | - for datasource in store.list_data_sources(): |
| 243 | + tags_filter = utils.tags_list_to_dict(tags) |
| 244 | + for datasource in store.list_data_sources(tags=tags_filter): |
237 | 245 | table.append([datasource.name, datasource.__class__]) |
238 | 246 |
|
239 | 247 | from tabulate import tabulate |
@@ -272,14 +280,16 @@ def entity_describe(ctx: click.Context, name: str): |
272 | 280 |
|
273 | 281 |
|
274 | 282 | @entities_cmd.command(name="list") |
| 283 | +@tagsOption |
275 | 284 | @click.pass_context |
276 | | -def entity_list(ctx: click.Context): |
| 285 | +def entity_list(ctx: click.Context, tags: list[str]): |
277 | 286 | """ |
278 | 287 | List all entities |
279 | 288 | """ |
280 | 289 | store = create_feature_store(ctx) |
281 | 290 | table = [] |
282 | | - for entity in store.list_entities(): |
| 291 | + tags_filter = utils.tags_list_to_dict(tags) |
| 292 | + for entity in store.list_entities(tags=tags_filter): |
283 | 293 | table.append([entity.name, entity.description, entity.value_type]) |
284 | 294 |
|
285 | 295 | from tabulate import tabulate |
@@ -320,14 +330,16 @@ def feature_service_describe(ctx: click.Context, name: str): |
320 | 330 |
|
321 | 331 |
|
322 | 332 | @feature_services_cmd.command(name="list") |
| 333 | +@tagsOption |
323 | 334 | @click.pass_context |
324 | | -def feature_service_list(ctx: click.Context): |
| 335 | +def feature_service_list(ctx: click.Context, tags: list[str]): |
325 | 336 | """ |
326 | 337 | List all feature services |
327 | 338 | """ |
328 | 339 | store = create_feature_store(ctx) |
329 | 340 | feature_services = [] |
330 | | - for feature_service in store.list_feature_services(): |
| 341 | + tags_filter = utils.tags_list_to_dict(tags) |
| 342 | + for feature_service in store.list_feature_services(tags=tags_filter): |
331 | 343 | feature_names = [] |
332 | 344 | for projection in feature_service.feature_view_projections: |
333 | 345 | feature_names.extend( |
@@ -371,16 +383,18 @@ def feature_view_describe(ctx: click.Context, name: str): |
371 | 383 |
|
372 | 384 |
|
373 | 385 | @feature_views_cmd.command(name="list") |
| 386 | +@tagsOption |
374 | 387 | @click.pass_context |
375 | | -def feature_view_list(ctx: click.Context): |
| 388 | +def feature_view_list(ctx: click.Context, tags: list[str]): |
376 | 389 | """ |
377 | 390 | List all feature views |
378 | 391 | """ |
379 | 392 | store = create_feature_store(ctx) |
380 | 393 | table = [] |
| 394 | + tags_filter = utils.tags_list_to_dict(tags) |
381 | 395 | for feature_view in [ |
382 | | - *store.list_feature_views(), |
383 | | - *store.list_on_demand_feature_views(), |
| 396 | + *store.list_batch_feature_views(tags=tags_filter), |
| 397 | + *store.list_on_demand_feature_views(tags=tags_filter), |
384 | 398 | ]: |
385 | 399 | entities = set() |
386 | 400 | if isinstance(feature_view, FeatureView): |
@@ -434,14 +448,16 @@ def on_demand_feature_view_describe(ctx: click.Context, name: str): |
434 | 448 |
|
435 | 449 |
|
436 | 450 | @on_demand_feature_views_cmd.command(name="list") |
| 451 | +@tagsOption |
437 | 452 | @click.pass_context |
438 | | -def on_demand_feature_view_list(ctx: click.Context): |
| 453 | +def on_demand_feature_view_list(ctx: click.Context, tags: list[str]): |
439 | 454 | """ |
440 | 455 | [Experimental] List all on demand feature views |
441 | 456 | """ |
442 | 457 | store = create_feature_store(ctx) |
443 | 458 | table = [] |
444 | | - for on_demand_feature_view in store.list_on_demand_feature_views(): |
| 459 | + tags_filter = utils.tags_list_to_dict(tags) |
| 460 | + for on_demand_feature_view in store.list_on_demand_feature_views(tags=tags_filter): |
445 | 461 | table.append([on_demand_feature_view.name]) |
446 | 462 |
|
447 | 463 | from tabulate import tabulate |
|
0 commit comments