Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 1.77 KB

File metadata and controls

64 lines (45 loc) · 1.77 KB

Deploying Applications

Agricultural Forecasting API (FastAPI)

ag_forecasting_api is a FastAPI application that provides crop disease forecasting models for corn and soybean in Wisconsin, developed by University of Wisconsin-Madison plant pathology experts.

Initialize a worker with the min image:

./ol worker init -i ol-min

Edit myworker/config.json to increase memory limit (512MB needed for this app):

"limits": {
    "mem_mb": 512,
    ...
}

Start the worker:

./ol worker up -d

Create ol.yaml to configure the app for OpenLambda:

triggers:
  http:
    - method: "*"
environment:
  OL_ENTRY_FILE: app.py
  OL_ASGI_ENTRY: app
  MEASUREMENTS_CACHE_DIR: /host/tmp/cache
  STATIONS_CACHE_FILE: /host/tmp/cache/wisconsin_stations_cache.csv

Install pip-compile and pin requirements.txt to versions suitable for OpenLambda:

./ol admin install examples/pip-compile
curl -X POST -d 'https://raw.githubusercontent.com/tylerharter/ag_forecasting_api/main/requirements.txt' http://localhost:5000/run/pip-compile/url > requirements.txt

Install and test:

./ol admin install -c ol.yaml -r requirements.txt https://github.com/tylerharter/ag_forecasting_api.git

# simple test
curl http://localhost:5000/run/ag_forecasting_api/

# get a forecast for the ALTN station
curl "http://localhost:5000/run/ag_forecasting_api/ag_models_wrappers/wisconet?forecasting_date=2024-07-01&risk_days=1&station_id=ALTN"

Note, the first request may take minutes because OpenLambda will install all the packages in requirements.txt upon the first call.

TODO: update ag_forecasting_api URLs from tylerharter fork to UW-Madison-DSI once env option is merged upstream.

TODO: add more example apps