Making Predictions in the CLI

Make predictions in the command line interface.

You can make predictions right in the command line.

Installing Function CLI

To install Function CLI, open a terminal and run the following command:

# Open a terminal and run the following command:
pip install --upgrade fxn

Logging in to Function

Next, head over to your Account page to generate an access key:

generate access key

Now, you can login to Function CLI with your access key:

# Open a terminal and run the following command
fxn auth login <ACCESS KEY>

Here is an example showing a successful login in the CLI:

login to CLI

Making Predictions

We'll need a predictor to make predictions with. You can either use a public predictor on Function, or make your own . In this guide, we'll be using the @samples/greeting predictor:

You can discover and use public predictors on Function.

We'll be using the greeting predictor in this guide.

The predictor accepts a name of the person to greet, optionally with their age and city. Let's make the prediction:

# Predict
fxn predict @samples/greeting --name Rhea --age 44 --city "Los Angeles"

Using File Inputs

For predictors that accept binary data (e.g. image, audio, video, binary files), pass in the file path prefixed with the @ character.

Here's an example that makes a prediction on an image file cat.jpg using a generic classifier predictor:

# Make a prediction using a file input
fxn predict @username/classifier --image @cat.jpg

The use of the @ character for working with files is similar to cURL.

Previous
Predict in Python