pfs-client 0.1.1
photon feature store client
Requires Python: >=3.8,<4.0
Keywords: photon,feature store,feature derive,machine learning

# pfs-client
The client of pfs(photon feature store), including SDK in python and command line client.

## Install
Install pfs-client from pypi:
```shell
pip install pfs-client
```

Install pfs-client from source:
```
pip install --upgrade pip
pip install --editable ./
```
## SDK in python
### Play with the demo entityset
Refer to notebook [demo entityset](./doc/tutorial/play_with_the_demo_entityset.ipynb)

### Create entity from external data source
Refer to notebook [external entity](./doc/tutorial/create_external_entity.ipynb)

### Create entity by upload local data
Refer to notebook [uploaded entity](./doc/tutorial/create_uploaded_entity.ipynb)

### Create entity by deriving using deep feature synthesis
Refer to notebook [derivied entity](./doc/tutorial/create_derived_entity.ipynb)

## CLI
Run the following command to show the usage of pfs command line client.
```
pfs -h
```

```
Usage: pfs [OPTIONS] COMMAND [ARGS]...

Options:
  --host TEXT  grpc host of the photon featruestore API service to connect.
               [default: localhost:3009]
  -h, --help   Show this message and exit.

Commands:
  entity
  entityset
```

pfs-apiserver provides an entityset `demo_retail` for demonstration purposes. In the following, we will show the usage about cli with the help of `demo_retail`。

Get the information about entityset：
``` shell
pfs entityset get -n demo_retail
```

```
name: "demo_retail"
entities {
  key: "customers"
  value {
    name: "customers"
    data_source_type: DATA_SOURCE_TYPE_CONNECT
    source_connection: "demo_retail"
    source_name: "customers"
    index: "customer_name"
    time_index: "first_orders_time"
    state: ENTITY_STATE_ACTIVE
  }
}
entities {
  key: "order_products"
  value {
    name: "order_products"
    data_source_type: DATA_SOURCE_TYPE_CONNECT
    source_connection: "demo_retail"
    source_name: "order_products"
    index: "order_product_id"
    time_index: "order_date"
    state: ENTITY_STATE_ACTIVE
  }
}
entities {
  key: "orders"
  value {
    name: "orders"
    data_source_type: DATA_SOURCE_TYPE_CONNECT
    source_connection: "demo_retail"
    source_name: "orders"
    index: "order_id"
    time_index: "first_order_products_time"
    state: ENTITY_STATE_ACTIVE
  }
}
entities {
  key: "products"
  value {
    name: "products"
    data_source_type: DATA_SOURCE_TYPE_CONNECT
    source_connection: "demo_retail"
    source_name: "products"
    index: "product_id"
    time_index: "first_order_products_time"
    state: ENTITY_STATE_ACTIVE
  }
}
relationships {
  entity_name: "order_products"
  feature_name: "order_id"
  foreign_entity_name: "orders"
  foreign_feature_name: "order_id"
}
relationships {
  entity_name: "order_products"
  feature_name: "product_id"
  foreign_entity_name: "products"
  foreign_feature_name: "product_id"
}
relationships {
  entity_name: "orders"
  feature_name: "customer_name"
  foreign_entity_name: "customers"
  foreign_feature_name: "customer_name"
}
```

Get the information of entity `customers`：
``` shell
pfs entity get -n customers --entityset demo_retail 
```

```
name: "customers"
data_source_type: DATA_SOURCE_TYPE_CONNECT
source_connection: "demo_retail"
source_name: "customers"
index: "customer_name"
time_index: "first_orders_time"
state: ENTITY_STATE_ACTIVE
```

Preview the data of entity `customers`：
```
pfs entity preview --entityset demo_retail  -n customers
```

```
                       customer_name   first_orders_time       _ft_last_time
Andrea Brown            Andrea Brown 2010-12-01 08:26:00 2011-02-10 14:38:00
Krista Maddox          Krista Maddox 2010-12-01 08:34:00 2011-11-08 12:10:00
Micheal Nicholson  Micheal Nicholson 2010-12-01 08:45:00 2011-12-07 08:07:00
Tara Mccall              Tara Mccall 2010-12-01 09:00:00 2011-09-05 09:45:00
Vicki Gilbert          Vicki Gilbert 2010-12-01 09:09:00 2011-01-13 17:09:00
Michael Schroeder  Michael Schroeder 2010-12-01 09:32:00 2011-11-14 11:02:00
Michael Hamilton    Michael Hamilton 2010-12-01 09:37:00 2011-12-02 12:26:00
Mark Jordan              Mark Jordan 2010-12-01 09:41:00 2011-11-23 13:00:00
Bryce Stewart          Bryce Stewart 2010-12-01 09:41:00 2011-12-09 12:00:00
Aaron Harrison        Aaron Harrison 2010-12-01 09:41:00 2011-12-07 12:19:00
```