◐ Shell
clean mode source ↗

feat: Added CLI for features, get historical and online features by ntkathole · Pull Request #5197 · feast-dev/feast

# feast features --help
Usage: feast features [OPTIONS] COMMAND [ARGS]...

  Access features

Options:
  --help  Show this message and exit.

Commands:
  describe  Describe a specific feature by name
  list      List all features
# feast features list
Feature              Feature View                 Data Type
conv_rate            driver_hourly_stats_fresh    Float32
acc_rate             driver_hourly_stats_fresh    Float32
avg_daily_trips      driver_hourly_stats_fresh    Int64
conv_rate            driver_hourly_stats          Float32
acc_rate             driver_hourly_stats          Float32
avg_daily_trips      driver_hourly_stats          Int64
conv_rate_plus_val1  transformed_conv_rate_fresh  Float64
conv_rate_plus_val2  transformed_conv_rate_fresh  Float64
conv_rate_plus_val1  transformed_conv_rate        Float64
conv_rate_plus_val2  transformed_conv_rate        Float64
# feast features describe conv_rate
[
    {
        "Feature Name": "conv_rate",
        "Feature View": "driver_hourly_stats_fresh",
        "Data Type": "Float32",
        "Description": "",
        "Online Store": true,
        "Source": {
            "type": "BATCH_FILE",
            "timestampField": "event_timestamp",
            "createdTimestampColumn": "created",
            "fileOptions": {
                "uri": "data/driver_stats.parquet"
            },
            "name": "driver_hourly_stats_source"
        }
    },
    {
        "Feature Name": "conv_rate",
        "Feature View": "driver_hourly_stats",
        "Data Type": "Float32",
        "Description": "",
        "Online Store": true,
        "Source": {
            "type": "BATCH_FILE",
            "timestampField": "event_timestamp",
            "createdTimestampColumn": "created",
            "fileOptions": {
                "uri": "data/driver_stats.parquet"
            },
            "name": "driver_hourly_stats_source"
        }
    }
]
# feast get-online-features --help
Usage: feast get-online-features [OPTIONS]

  Fetch online feature values for a given entity ID

Options:
  -e, --entities TEXT  Entity key-value pairs (e.g., driver_id=1001)
                       [required]
  -f, --features TEXT  Features to retrieve. feater-view:feature-name ex:
                       driver_hourly_stats:conv_rate  [required]
  --help               Show this message and exit.
# feast get-online-features --entities driver_id=1001 --features driver_hourly_stats:conv_rate
{
    "driver_id": [
        1001
    ],
    "conv_rate": [
        0.1379641592502594
    ]
}
# feast get-historical-features --help
Usage: feast get-historical-features [OPTIONS]

  Fetch historical feature values for a given entity ID

Options:
  -d, --dataframe TEXT  JSON string containing entities and timestamps.
                        Example: '[{"event_timestamp": "2025-03-29T12:00:00",
                        "driver_id": 1001}]'  [required]
  -f, --features TEXT   Features to retrieve. feature-view:feature-name ex:
                        driver_hourly_stats:conv_rate  [required]
  --help                Show this message and exit.
# feast get-historical-features --dataframe '[{"event_timestamp": "2025-03-29T12:00:00", "driver_id": 1001}]' --features driver_hourly_stats:conv_rate
[
    {
        "event_timestamp":1743249600000,
        "driver_id":1001,
        "conv_rate":0.851655364
    }
]