Working with Python

Hi, I am new to development and there is a thing I am practicing where I want to customize the code using python but I am not able to figure out how to use the python client given in the github. couldnt see the code to attach my data nor any code to generate the job id. What should be the process flow of running this?

You need to create the route optimization problem as JSON body and then call this method:

Creating the body is explained here.

Hi karussell thank for this, by JSON body you meant JSON object right?? Kindly see if this code is correct:

route_data = {
“vehicles” : [ {
“vehicle_id” : “traveling_salesman”,
“start_address” : {
“location_id” : “0”,
“lon” : -88.014426,
“lat” : 30.681803
},
“type_id” : “default”,
} ],
“vehicle_types” : [ {
“type_id” : “default”,
“profile” : “car”
} ],
“services” : [ {
“id” : “44”,
“name” : “no-name”,
“address” : {
“location_id” : “44”,
“lon” : -71.298265,
“lat” : 41.469858
}
}, {
“id” : “45”,
“name” : “no-name”,
“address” : {
“location_id” : “45”,
“lon” : -79.874692,
“lat” : 32.752348
}
}, {
“id” : “46”,
“name” : “no-name”,
“address” : {
“location_id” : “46”,
“lon” : -103.459067,
“lat” : 43.879102
}
}, {
“id” : “47”,
“name” : “no-name”,
“address” : {
“location_id” : “47”,
“lon” : -90.026049,
“lat” : 35.047691
}
}, {
“id” : “48”,
“name” : “no-name”,
“address” : {
“location_id” : “48”,
“lon” : -98.486142,
“lat” : 29.425967
}
}, {
“id” : “49”,
“name” : “no-name”,
“address” : {
“location_id” : “49”,
“lon” : -112.18709,
“lat” : 37.593038
}
}, {
“id” : “10”,
“name” : “no-name”,
“address” : {
“location_id” : “10”,
“lon” : -86.617524,
“lat” : 38.566697
}
}, {
“id” : “11”,
“name” : “no-name”,
“address” : {
“location_id” : “11”,
“lon” : -93.648542,
“lat” : 41.583218
}
}, {
“id” : “12”,
“name” : “no-name”,
“address” : {
“location_id” : “12”,
“lon” : -94.909536,
“lat” : 39.317245
}
}, {
“id” : “13”,
“name” : “no-name”,
“address” : {
“location_id” : “13”,
“lon” : -86.100528,
“lat” : 37.186998
}
}, {
“id” : “14”,
“name” : “no-name”,
“address” : {
“location_id” : “14”,
“lon” : -90.064411,
“lat” : 29.958443
}
}, {
“id” : “15”,
“name” : “no-name”,
“address” : {
“location_id” : “15”,
“lon” : -68.273335,
“lat” : 44.338556
}
}, {
“id” : “16”,
“name” : “no-name”,
“address” : {
“location_id” : “16”,
“lon” : -76.490974,
“lat” : 38.978828
}
}, {
“id” : “17”,
“name” : “no-name”,
“address” : {
“location_id” : “17”,
“lon” : -111.939697,
“lat” : 36.004673
}
}, {
“id” : “18”,
“name” : “no-name”,
“address” : {
“location_id” : “18”,
“lon” : -92.065143,
“lat” : 34.647037
}
}, {
“id” : “19”,
“name” : “no-name”,
“address” : {
“location_id” : “19”,
“lon” : -120.987632,
“lat” : 36.576088
}
}, {
“id” : “1”,
“name” : “no-name”,
“address” : {
“location_id” : “1”,
“lon” : -73.247227,
“lat” : 44.408948
}
}, {
“id” : “2”,
“name” : “no-name”,
“address” : {
“location_id” : “2”,
“lon” : -77.107386,
“lat” : 38.729314
}
}, {
“id” : “3”,
“name” : “no-name”,
“address” : {
“location_id” : “3”,
“lon” : -119.488974,
“lat” : 46.550684
}
}, {
“id” : “4”,
“name” : “no-name”,
“address” : {
“location_id” : “4”,
“lon” : -80.44563,
“lat” : 37.801788
}
}, {
“id” : “5”,
“name” : “no-name”,
“address” : {
“location_id” : “5”,
“lon” : -90.070467,
“lat” : 43.141031
}
}, {
“id” : “6”,
“name” : “no-name”,
“address” : {
“location_id” : “6”,
“lon” : -110.647602,
“lat” : 44.433412
}
}, {
“id” : “7”,
“name” : “no-name”,
“address” : {
“location_id” : “7”,
“lon” : -82.272327,
“lat” : 31.056794
}
}, {
“id” : “8”,
“name” : “no-name”,
“address” : {
“location_id” : “8”,
“lon” : -113.563131,
“lat” : 43.461858
}
}, {
“id” : “9”,
“name” : “no-name”,
“address” : {
“location_id” : “9”,
“lon” : -89.646184,
“lat” : 39.797519
}
}, {
“id” : “20”,
“name” : “no-name”,
“address” : {
“location_id” : “20”,
“lon” : -122.411715,
“lat” : 37.794781
}
}, {
“id” : “21”,
“name” : “no-name”,
“address” : {
“location_id” : “21”,
“lon” : -105.04226,
“lat” : 38.840871
}
}, {
“id” : “22”,
“name” : “no-name”,
“address” : {
“location_id” : “22”,
“lon” : -72.701173,
“lat” : 41.766759
}
}, {
“id” : “23”,
“name” : “no-name”,
“address” : {
“location_id” : “23”,
“lon” : -75.52767,
“lat” : 38.910832
}
}, {
“id” : “24”,
“name” : “no-name”,
“address” : {
“location_id” : “24”,
“lon” : -77.03653,
“lat” : 38.897676
}
}, {
“id” : “25”,
“name” : “no-name”,
“address” : {
“location_id” : “25”,
“lon” : -80.603611,
“lat” : 28.388333
}
}, {
“id” : “26”,
“name” : “no-name”,
“address” : {
“location_id” : “26”,
“lon” : -71.056575,
“lat” : 42.37247
}
}, {
“id” : “27”,
“name” : “no-name”,
“address” : {
“location_id” : “27”,
“lon” : -83.084943,
“lat” : 42.387579
}
}, {
“id” : “28”,
“name” : “no-name”,
“address” : {
“location_id” : “28”,
“lon” : -93.180627,
“lat” : 44.89285
}
}, {
“id” : “29”,
“name” : “no-name”,
“address” : {
“location_id” : “29”,
“lon” : -90.84985,
“lat” : 32.34655
}
}, {
“id” : “30”,
“name” : “no-name”,
“address” : {
“location_id” : “30”,
“lon” : -90.184776,
“lat” : 38.624691
}
}, {
“id” : “31”,
“name” : “no-name”,
“address” : {
“location_id” : “31”,
“lon” : -113.787023,
“lat” : 48.759613
}
}, {
“id” : “32”,
“name” : “no-name”,
“address” : {
“location_id” : “32”,
“lon” : -98.158611,
“lat” : 42.425
}
}, {
“id” : “33”,
“name” : “no-name”,
“address” : {
“location_id” : “33”,
“lon” : -114.737732,
“lat” : 36.016066
}
}, {
“id” : “34”,
“name” : “no-name”,
“address” : {
“location_id” : “34”,
“lon” : -71.441189,
“lat” : 44.25812
}
}, {
“id” : “35”,
“name” : “no-name”,
“address” : {
“location_id” : “35”,
“lon” : -74.924184,
“lat” : 38.931843
}
}, {
“id” : “36”,
“name” : “no-name”,
“address” : {
“location_id” : “36”,
“lon” : -104.58745,
“lat” : 32.123169
}
}, {
“id” : “37”,
“name” : “no-name”,
“address” : {
“location_id” : “37”,
“lon” : -74.0445,
“lat” : 40.689249
}
}, {
“id” : “38”,
“name” : “no-name”,
“address” : {
“location_id” : “38”,
“lon” : -75.67573,
“lat” : 35.908226
}
}, {
“id” : “39”,
“name” : “no-name”,
“address” : {
“location_id” : “39”,
“lon” : -104.041483,
“lat” : 48.00016
}
}, {
“id” : “40”,
“name” : “no-name”,
“address” : {
“location_id” : “40”,
“lon” : -84.524997,
“lat” : 39.174331
}
}, {
“id” : “41”,
“name” : “no-name”,
“address” : {
“location_id” : “41”,
“lon” : -97.012213,
“lat” : 34.457043
}
}, {
“id” : “42”,
“name” : “no-name”,
“address” : {
“location_id” : “42”,
“lon” : -121.519633,
“lat” : 45.711564
}
}, {
“id” : “43”,
“name” : “no-name”,
“address” : {
“location_id” : “43”,
“lon” : -75.150282,
“lat” : 39.94961
}
} ]
}

so instead of body I pass here route_data, is that correct like
JobId post_vrp(key, route_data)

You can use the route editor to see how to create valid JSON (that you should be able to use for the python client): https://www.graphhopper.com/blog/2015/07/21/graphhoppers-new-route-optimization-editor/