fsdb_rest_api
FSDB REST API - Serve Plant Database through RESTful Endpoints
This module provides a RESTful API server for interacting with a local plant database (FSDB). It is designed for the ROMI project and facilitates efficient data handling and retrieval of plant-related datasets. The server enables users to query and manage plant scans, images, point clouds, and other related data files.
Key Features
- Serve a local plant database (FSDB) through RESTful API endpoints.
- Manage plant scans and related data, including images, point clouds, and meshes.
- Retrieve and manage dataset files with various configurations.
- Run in test mode with optional preconfigured datasets or an empty test database.
- Lightweight server setup using Flask, with options for debugging and CORS support.
Usage Examples
To start the REST API server for a local plant database:
python fsdb_rest_api.py --db_location /path/to/your/database --host 127.0.0.1 --port 8080 --debug
To run the server with a temporary test database in debug mode:
python fsdb_rest_api.py --test --debug
RESTful endpoints include:
- /scans
: List all scans available in the database.
- /files/<path:path>
: Retrieve files from the database.
- /image/<scan_id>/<fileset_id>/<file_id>
: Access specific images.
- /pointcloud/<scan_id>/<fileset_id>/<file_id>
: Access specific point clouds.
- /mesh/<scan_id>/<fileset_id>/<file_id>
: Retrieve related meshes.
For detailed command-line parameters, use the --help
flag:
python fsdb_rest_api.py --help
main()
Link
Main function to initialize and execute the REST API server.
This function utilizes argument parsing to extract user-provided input values for configuring and running the REST API server.
Source code in plantdb/cli/fsdb_rest_api.py
235 236 237 238 239 240 241 242 243 |
|
rest_api(db_location, host='0.0.0.0', port=5000, debug=False, test=False, empty=False, models=False, log_level=DEFAULT_LOG_LEVEL)
Link
Initialize and configure a RESTful API server for Plant Database querying.
This function sets up a Flask application with various RESTful endpoints to enable interaction with a local Plant Database (FSDB). RESTful routes are added for managing and retrieving various datasets and configurations, providing an interface for working with plant scans and related files. The application can be run in test mode with optional configurations for using sample datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_location
|
str
|
The path to the local plant database to be served. If set to "/none", the server will raise an error and terminate unless the path is appropriately overridden in test mode. |
required |
host
|
str
|
The hostname or IP address on which the Flask application will listen for incoming requests.
Defaults to |
'0.0.0.0'
|
port
|
int
|
The port number to bind the Flask application for incoming HTTP requests.
Defaults to |
5000
|
debug
|
bool
|
A boolean flag indicating whether Flask debugging mode should be enabled.
Useful for debugging during development. Defaults to |
False
|
test
|
bool
|
A boolean flag to specify if the application should run in test mode. When enabled, a test
database will be instantiated with sample datasets or an empty configuration if specified.
Defaults to |
False
|
empty
|
bool
|
A boolean flag to specify whether the test database should be instantiated without any
datasets or configurations. Defaults to |
False
|
models
|
bool
|
A boolean flag to specify whether the test database should be populated with trained CNN models.
Defaults to |
False
|
log_level
|
str
|
The logging level to use for the application. Defaults to |
DEFAULT_LOG_LEVEL
|
Source code in plantdb/cli/fsdb_rest_api.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|