FØCAL device farm

Quick start

1
2
3
4
5
6
7
8
9
10
11
python3 -m venv _venv && souce _venv/bin/activate
pip install --upgrade pip
git clone https://github.com/f0cal/f0cal.farm.client && \
  cd f0cal.farm.client
pip install ./ -r requirements.txt -c constraints.txt
f0cal farm config set api_key ${API_KEY}
f0cal farm instance create my_pi \
  --device rpi3b+ \
  --os ubuntu-18.04:latest
f0cal farm instance access my_pi \
  --ssh

Note: Your ${API_KEY} can be retrieved by logging in here.

Basics

The f0cal.farm.client Python package implements a simple API client and a command line interface (CLI), both capable of running key workflows on the device farm:

Both the CLI and client use a simple “noun-verb” interaction model to enable these workflows. For the sake of brevity, example code in this document will use the CLI. Documentation for the Python client can be found here.

The CLI’s nou-verb model interaction model takes the form f0cal farm {noun} {verb} {args}. User-facing nouns mirror those found in typical virtual machine workflows:

Other nouns are specific to the farm:

Every noun has basic CRUD verb semantics. In addition, “special” verbs provide the core functionality of the device farm.

Getting started

Accessing the f0cal farm CLI requires the installtion of the f0cal.farm.client Python package. The established best-practice for installing third-party Python packages like ours is to use a virtual environment. You can quickly create and activate a Python virtual environment – or “venv” for short – as follows:

1
python3 -m venv ${VENV_PATH} && source ${VENV_PATH}/bin/activate

If Python complains about not having venv support, you may need to use your system-wide package manager to get it. (Learn more.)

Once your new venv is active, you can install the f0cal.farm.client package from Github.

1
2
3
4
5
pip install --upgrade pip
git clone https://github.com/f0cal/f0cal.farm.client && \
  cd f0cal.farm.client
pip install ./ -r requirements.txt -c constraints.txt
f0cal farm config set api_key ${API_KEY}

All the workflows that we exhibit in the remainder of the document will require an API key. API keys can’t be generated programmatically; you will need to visit our web dashboard to get yours. API keys are, effectively, passwords; please take reasonable measures to keep yours secure.

Examples

Available devices

1
f0cal farm device_type list

This is the basic entrypoing for making queries about what kinds of devices are in the farm.

1
f0cal farm device_type list --query "manufacturer==NVidia"

More detailed queries can be made using the --query flag. The query syntax is

1
f0cal farm device_type list --query "hourly_price<0.25"

Availabled images

1
f0cal farm image list

This is the basic entrypoing for making queries about what kinds of devices are in the farm.

1
f0cal farm image list --query "manufacturer==NVidia"

More detailed queries can be made using the --query flag. The query syntax is

1
f0cal farm image list --query "hourly_price<0.25"
Start here