Feathr API
The API currently supports following functionality
- Get Feature by Qualified Name
- Get Feature by GUID
- Get List of Features
- Get Lineage for a Feature
Build and run locally
Install
NOTE: You can run the following command in your local python environment or in your Azure Virtual machine. You can install dependencies through the requirements file
$ pip install -r requirements.txt
Run
This command will start the uvicorn server locally and will dynamically load your changes.
uvicorn api:app --port 8080 --reload
Build and deploy on Azure
Here are the steps to build the API as a docker container, push it to Azure Container registry and then deploy it as webapp. The instructions below are for Mac/Linux but should work on Windows too. You might have to use sudo command or run docker as administrator on windows if you don’t have right privileges.
-
Install Azure CLI by following instructions here
-
Create Azure Container Registry. First create the resource group.
az group create --name <your_rg_name> --location <location example:westus>
Then create the container registry
az acr create --resource-group <your_rg_name> --name <registry-name> --sku Basic
-
Login to your Azure container registry (ACR) account.
$ az acr login --name <registry-name>
-
Clone the repository and navigate to api folder
$ git clone git@github.com:linkedin/feathr.git $ cd feathr_project/feathr/api
-
Build the docker container locally, you need to have docker installed locally and have it running. To set up docker on your machine follow the instructions here
**Note: Note:/image_name is not a mandatory format for specifying the name of the image.It’s just a useful convention to avoid tagging your image again when you need to push it to a registry. It can be anything you want in the format below** ```bash $ docker build -t feathr/api . ```
-
Run docker images command and you will see your newly created image
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE feathr/api latest a647ea749b9b 5 minutes ago 529MB
- Before you can push an image to your registry, you must tag it with the fully qualified name of your ACR login server. The login server name is in the format
.azurecr.io (all lowercase), for example, mycontainerregistry007.azurecr.io. Tag the image $ docker tag feathr/api:latest feathracr.azurecr.io/feathr/api:latest
- Push the image to the registry
$ docker push feathracr.azurecr.io/feathr/api:latest
- List the images from your registry to see your recently pushed image
az acr repository list --name feathracr --output table
Output:
Result ---------- feathr/api
Deploy image to Azure WebApp for Containers
- Go to Azure portal and search for your container registry
-
Select repositories from the left pane and click latest tag. Click on the three dots on right side of the tag and select Deploy to WebApp option. If you see the Deploy to WebApp option greyed out, you would have to enable Admin User on the registry by Updating it.
-
Provide a name for the deployed webapp, along with the subscription to deploy app into, the resource group and the appservice plan
-
You will get the notification that your app has been successfully deployed, click on Go to Resource button.
-
On the App overview page go to the URL (https://
.azurewebsites.net/docs) for deployed app (it's under URL on the app overview page) and you should see the API documentation.
Congratulations you have successfully deployed the Feathr API.