Hello, I am attempting to follow an example on the ORS website, but with my own self hosted instance of ORS on docker. The example I’m trying to follow is the Disaster Optimization guide.
All the code is essentially the same, except for this line:
ors_client = ors.Client(key='your_key') # Get an API key from https://openrouteservice.org/dev/#/signup
Which I have changed to:
ors_client = ors.Client(base_url='http://localhost:8080/ors')
The output I receive is below:
{
"name": "HTTPError",
"message": "HTTP Error: 404",
"stack": "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/requests/models.py:971\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 970\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 971\u001b[0m \u001b[39mreturn\u001b[39;00m complexjson\u001b[39m.\u001b[39;49mloads(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mtext, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 972\u001b[0m \u001b[39mexcept\u001b[39;00m JSONDecodeError \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 973\u001b[0m \u001b[39m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[1;32m 974\u001b[0m \u001b[39m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n\nFile \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py:346\u001b[0m, in \u001b[0;36mloads\u001b[0;34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[39mif\u001b[39;00m (\u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 344\u001b[0m parse_int \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m parse_float \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 345\u001b[0m parse_constant \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_pairs_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m kw):\n\u001b[0;32m--> 346\u001b[0m \u001b[39mreturn\u001b[39;00m _default_decoder\u001b[39m.\u001b[39;49mdecode(s)\n\u001b[1;32m 347\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\nFile \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py:337\u001b[0m, in \u001b[0;36mJSONDecoder.decode\u001b[0;34m(self, s, _w)\u001b[0m\n\u001b[1;32m 333\u001b[0m \u001b[39m\"\"\"Return the Python representation of ``s`` (a ``str`` instance\u001b[39;00m\n\u001b[1;32m 334\u001b[0m \u001b[39mcontaining a JSON document).\u001b[39;00m\n\u001b[1;32m 335\u001b[0m \n\u001b[1;32m 336\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m--> 337\u001b[0m obj, end \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mraw_decode(s, idx\u001b[39m=\u001b[39;49m_w(s, \u001b[39m0\u001b[39;49m)\u001b[39m.\u001b[39;49mend())\n\u001b[1;32m 338\u001b[0m end \u001b[39m=\u001b[39m _w(s, end)\u001b[39m.\u001b[39mend()\n\nFile \u001b[0;32m/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py:355\u001b[0m, in \u001b[0;36mJSONDecoder.raw_decode\u001b[0;34m(self, s, idx)\u001b[0m\n\u001b[1;32m 354\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mStopIteration\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n\u001b[0;32m--> 355\u001b[0m \u001b[39mraise\u001b[39;00m JSONDecodeError(\u001b[39m\"\u001b[39m\u001b[39mExpecting value\u001b[39m\u001b[39m\"\u001b[39m, s, err\u001b[39m.\u001b[39mvalue) \u001b[39mfrom\u001b[39;00m \u001b[39mNone\u001b[39m\n\u001b[1;32m 356\u001b[0m \u001b[39mreturn\u001b[39;00m obj, end\n\n\u001b[0;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\n\u001b[0;31mJSONDecodeError\u001b[0m Traceback (most recent call last)\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/openrouteservice/client.py:229\u001b[0m, in \u001b[0;36mClient._get_body\u001b[0;34m(response)\u001b[0m\n\u001b[1;32m 228\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 229\u001b[0m body \u001b[39m=\u001b[39m response\u001b[39m.\u001b[39;49mjson()\n\u001b[1;32m 230\u001b[0m \u001b[39mexcept\u001b[39;00m json\u001b[39m.\u001b[39mJSONDecodeError:\n\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/requests/models.py:975\u001b[0m, in \u001b[0;36mResponse.json\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 972\u001b[0m \u001b[39mexcept\u001b[39;00m JSONDecodeError \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 973\u001b[0m \u001b[39m# Catch JSON-related errors and raise as requests.JSONDecodeError\u001b[39;00m\n\u001b[1;32m 974\u001b[0m \u001b[39m# This aliases json.JSONDecodeError and simplejson.JSONDecodeError\u001b[39;00m\n\u001b[0;32m--> 975\u001b[0m \u001b[39mraise\u001b[39;00m RequestsJSONDecodeError(e\u001b[39m.\u001b[39mmsg, e\u001b[39m.\u001b[39mdoc, e\u001b[39m.\u001b[39mpos)\n\n\u001b[0;31mJSONDecodeError\u001b[0m: Expecting value: line 1 column 1 (char 0)\n\nDuring handling of the above exception, another exception occurred:\n\n\u001b[0;31mHTTPError\u001b[0m Traceback (most recent call last)\nCell \u001b[0;32mIn [34], line 80\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[38;5;66;03m# Initialize a client and make the request\u001b[39;00m\n\u001b[1;32m 79\u001b[0m ors_client \u001b[38;5;241m=\u001b[39m ors\u001b[38;5;241m.\u001b[39mClient(base_url\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mhttp://localhost:8080/ors\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m---> 80\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mors_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43moptimization\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 81\u001b[0m \u001b[43m \u001b[49m\u001b[43mjobs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdeliveries\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 82\u001b[0m \u001b[43m \u001b[49m\u001b[43mvehicles\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvehicles\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 83\u001b[0m \u001b[43m \u001b[49m\u001b[43mgeometry\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\n\u001b[1;32m 84\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 86\u001b[0m \u001b[38;5;66;03m# Add the output to the map\u001b[39;00m\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m color, route \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m([\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgreen\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mred\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mblue\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124myellow\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mpurple\u001b[39m\u001b[38;5;124m'\u001b[39m], result[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mroutes\u001b[39m\u001b[38;5;124m'\u001b[39m]):\n\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/openrouteservice/client.py:299\u001b[0m, in \u001b[0;36m_make_api_method.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 296\u001b[0m \u001b[39m@functools\u001b[39m\u001b[39m.\u001b[39mwraps(func)\n\u001b[1;32m 297\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mwrapper\u001b[39m(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m 298\u001b[0m args[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39m_extra_params \u001b[39m=\u001b[39m kwargs\u001b[39m.\u001b[39mpop(\u001b[39m\"\u001b[39m\u001b[39mextra_params\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39mNone\u001b[39;00m)\n\u001b[0;32m--> 299\u001b[0m result \u001b[39m=\u001b[39m func(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 300\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 301\u001b[0m \u001b[39mdel\u001b[39;00m args[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39m_extra_params\n\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/openrouteservice/optimization.py:97\u001b[0m, in \u001b[0;36moptimization\u001b[0;34m(client, jobs, vehicles, shipments, matrix, geometry, dry_run)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[39mif\u001b[39;00m matrix:\n\u001b[1;32m 95\u001b[0m params[\u001b[39m'\u001b[39m\u001b[39mmatrix\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m matrix\n\u001b[0;32m---> 97\u001b[0m \u001b[39mreturn\u001b[39;00m client\u001b[39m.\u001b[39;49mrequest(\u001b[39m\"\u001b[39;49m\u001b[39m/optimization\u001b[39;49m\u001b[39m\"\u001b[39;49m, {}, post_json\u001b[39m=\u001b[39;49mparams, dry_run\u001b[39m=\u001b[39;49mdry_run)\n\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/openrouteservice/client.py:204\u001b[0m, in \u001b[0;36mClient.request\u001b[0;34m(self, url, get_params, first_request_time, retry_counter, requests_kwargs, post_json, dry_run)\u001b[0m\n\u001b[1;32m 200\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mrequest(url, get_params, first_request_time,\n\u001b[1;32m 201\u001b[0m retry_counter \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m, requests_kwargs, post_json)\n\u001b[1;32m 203\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 204\u001b[0m result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_get_body(response)\n\u001b[1;32m 206\u001b[0m \u001b[39mreturn\u001b[39;00m result\n\u001b[1;32m 207\u001b[0m \u001b[39mexcept\u001b[39;00m exceptions\u001b[39m.\u001b[39m_RetriableRequest \u001b[39mas\u001b[39;00m e:\n\nFile \u001b[0;32m/opt/homebrew/lib/python3.10/site-packages/openrouteservice/client.py:231\u001b[0m, in \u001b[0;36mClient._get_body\u001b[0;34m(response)\u001b[0m\n\u001b[1;32m 229\u001b[0m body \u001b[39m=\u001b[39m response\u001b[39m.\u001b[39mjson()\n\u001b[1;32m 230\u001b[0m \u001b[39mexcept\u001b[39;00m json\u001b[39m.\u001b[39mJSONDecodeError:\n\u001b[0;32m--> 231\u001b[0m \u001b[39mraise\u001b[39;00m exceptions\u001b[39m.\u001b[39mHTTPError(response\u001b[39m.\u001b[39mstatus_code)\n\u001b[1;32m 233\u001b[0m \u001b[39m# error = body.get('error')\u001b[39;00m\n\u001b[1;32m 234\u001b[0m status_code \u001b[39m=\u001b[39m response\u001b[39m.\u001b[39mstatus_code\n\n\u001b[0;31mHTTPError\u001b[0m: HTTP Error: 404"
}
I am able to confirm that the instance is running correctly if I check ‘http://localhost:8080/ors/health’ and ‘http://localhost:8080/ors/status’, but I don’t know where to go from here.
Can anyone help please?