|
| 1 | +# Data Offloading |
| 2 | + |
| 3 | +We have a tool to automatically offload and sync your robot data to the AirLab internal storage server. |
| 4 | + |
| 5 | +## Setup Storage Tools Server Locally |
| 6 | + |
| 7 | +### Clone and install |
| 8 | + |
| 9 | +``` bash |
| 10 | +git clone https://github.com/castacks/storage_tools_server |
| 11 | +cd storage_tools_server |
| 12 | +python -m venv venv |
| 13 | +. venv/bin/activate |
| 14 | +pip install -r requirements.txt |
| 15 | +``` |
| 16 | + |
| 17 | +### Configure |
| 18 | + |
| 19 | +Edit the `config/config.yaml` file to match your configuration. |
| 20 | + |
| 21 | +### REQUIRED UPDATES |
| 22 | + |
| 23 | +- `upload_dir` is the location for uploads. This must be readable and writeable by the user running the Server. |
| 24 | +- `volume_root` sets the prefix for all entries in the `volume_map`. This must be readable and writeable by the user running the Server. |
| 25 | +- `volume_map` is a mapping from project name to `volume_root/{path}`. All projects must have a mapping. |
| 26 | + |
| 27 | +### Set Environment and Run |
| 28 | + |
| 29 | +- `CONFIG` is the full path to the `config.yaml` in use. By default, the app will use `$PWD/config/config.yaml` |
| 30 | +- `PORT` is the same port as define in the optional setup. The default is 8091. |
| 31 | + |
| 32 | +``` bash |
| 33 | +export CONFIG=$PWD/config/config.yaml |
| 34 | +export PORT=8091 |
| 35 | + |
| 36 | +gunicorn -k gevent -w 1 -b "0.0.0.0:${PORT}" --timeout 120 "server.app:app" |
| 37 | +``` |
| 38 | + |
| 39 | +Open a web browser to http://localhost:8091 (or the PORT you set). The default user is `admin` and the default password is `NodeNodeDevices`. |
| 40 | + |
| 41 | +### Create an API Key for your robot |
| 42 | + |
| 43 | +- Log into the Server |
| 44 | +- Go to Configure -> Keys |
| 45 | +- Enter a name for the device key in the "Add a new key name" field. |
| 46 | +- Click "Generate Key" |
| 47 | + |
| 48 | +## Set up Storage Tools Device on your Robot |
| 49 | + |
| 50 | +### Install Requirements |
| 51 | + |
| 52 | +- [Docker Compose](https://docs.docker.com/compose/install/standalone/) |
| 53 | + |
| 54 | +### Clone Device Repo |
| 55 | + |
| 56 | +```bash |
| 57 | +cd /opt |
| 58 | +git clone https://github.com/castacks/storage_tools_device |
| 59 | +cd stroage_tools_device |
| 60 | +``` |
| 61 | + |
| 62 | +### Update the config.yaml |
| 63 | + |
| 64 | +Update `config/config.yaml` to match your environment. Things you should update: |
| 65 | + |
| 66 | +- `API_KEY_TOKEN`. The api key that your admin gave you, or the key that you set up in the [Server Setup](#create-an-api-key-for-your-robot) |
| 67 | +- `watch`. The list of directories that have your robot's files. |
| 68 | + |
| 69 | +Update the `env.sh` to match your system. |
| 70 | + |
| 71 | +- `CONFIG_FILE`. If you have multiple config files, make sure `CONFIG_FILE` points to the one you want to use. |
| 72 | +- `DATA_DIR`. This is the top level data directory that all of the `watch` dirs share. For example, if you `watch` directories are `/mnt/data/processor_1` and `/mnt/data/processor_2`, set the `DATA_DIR` to `/mnt/data`. |
| 73 | + |
| 74 | +### Build and Run |
| 75 | + |
| 76 | +``` bash |
| 77 | +cd /opt/storage_tools_device |
| 78 | +. env.sh |
| 79 | +docker compose up --build |
| 80 | +``` |
0 commit comments