Back to Feast

02 Demo

examples/operator-quickstart/02-Demo.ipynb

0.63.03.3 KB
Original Source

Run the "Real-time Credit Scoring" tutorial

We'll use the following tutorial as a demonstration.

https://github.com/feast-dev/feast-credit-score-local-tutorial/tree/598a270353d8a83b37535f849a0fa000a07be8b5

Check the init container to ensure the repo was successfully cloned with git.

python
!kubectl logs -f deploy/feast-example -c feast-init

Verify the client feature_store.yaml.

python
!kubectl exec deploy/feast-example -itc online -- cat feature_store.yaml

Apply the tutorial feature store definitions

Update the feature store definitions for the tutorial and load data from feature views into the online store, beginning from either the previous materialize or materialize-incremental end date, or the beginning of time.

We'll do this by using the CronJob created by the operator which, by default, will execute the following commands when run -

  • feast apply
  • feast materialize-incremental $(date -u +'%Y-%m-%dT%H:%M:%S')

Before we run the Job, let's ensure our FeatureStore CR is configured accordingly.

python
!kubectl get feast/example -o jsonpath='{.status.applied.cronJob.containerConfigs.commands}'

Now let's run a Job from the existing CronJob, wait for its completion, and then check the logs.

python
!kubectl create job --from=cronjob/feast-example feast-example-apply
!kubectl wait --for=condition=complete --timeout=8m job/feast-example-apply
!kubectl logs job/feast-example-apply --all-containers=true

Execute feast commands inside the client Pod

List the registered feast projects, feature views, & entities.

python
!kubectl exec deploy/feast-example -itc online -- feast projects list
!kubectl exec deploy/feast-example -itc online -- feast feature-views list
!kubectl exec deploy/feast-example -itc online -- feast entities list

Train and test the model

Install the required packages, then train and test the model.

We'll do this by leveraging the same Operator created CronJob. We'll modify it to run the following commands for us -

  • pip install -r ../requirements.txt
  • cd ../ && python run.py
python
!kubectl patch feast/example --patch '{"spec":{"cronJob":{"containerConfigs":{"commands":["pip install -r ../requirements.txt","cd ../ && python run.py"]}}}}' --type=merge

Again, before we run the Job, let's ensure our FeatureStore CR is configured accordingly.

python
!kubectl get feast/example -o jsonpath='{.status.applied.cronJob.containerConfigs.commands}'

Now let's run another Job from the modified CronJob, wait for its completion, and then check the logs. The completed Job logs should show all necessary python installs and end with "Loan rejected!".

python
!kubectl create job --from=cronjob/feast-example feast-example-demo
!kubectl wait --for=condition=complete --timeout=8m job/feast-example-demo
!kubectl logs job/feast-example-demo --all-containers=true

Interactive demo (using Streamlit)

In a new terminal, run the following command and leave it active.

bash
$ kubectl port-forward deploy/feast-example 8501:8501

Start the Streamlit application

python
!kubectl exec deploy/feast-example -itc online -- bash -c 'cd ../ && streamlit run --server.port 8501 streamlit_app.py'

Then navigate to the local URL on which Streamlit is being served.

http://localhost:8501