Fetch online feature values for a given entity ID
(ctx: click.Context, entities: List[str], features: List[str])
| 111 | ) |
| 112 | @click.pass_context |
| 113 | def get_online_features(ctx: click.Context, entities: List[str], features: List[str]): |
| 114 | """ |
| 115 | Fetch online feature values for a given entity ID |
| 116 | """ |
| 117 | store = create_feature_store(ctx) |
| 118 | entity_dict: dict[str, List[str]] = {} |
| 119 | for entity in entities: |
| 120 | try: |
| 121 | key, value = entity.split("=") |
| 122 | if key not in entity_dict: |
| 123 | entity_dict[key] = [] |
| 124 | entity_dict[key].append(value) |
| 125 | except ValueError: |
| 126 | click.echo(f"Invalid entity format: {entity}. Use key=value format.") |
| 127 | return |
| 128 | entity_rows = [ |
| 129 | dict(zip(entity_dict.keys(), values)) for values in zip(*entity_dict.values()) |
| 130 | ] |
| 131 | feature_vector = store.get_online_features( |
| 132 | features=list(features), |
| 133 | entity_rows=entity_rows, |
| 134 | ).to_dict() |
| 135 | |
| 136 | click.echo(json.dumps(feature_vector, indent=4)) |
| 137 | |
| 138 | |
| 139 | @click.command(name="get-historical-features") |
nothing calls this directly
no test coverage detected