Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom ORS Server Configuration Not Working in PyVroom 1.14.0 #117

Open
denis-rodriguez opened this issue Nov 7, 2024 · 9 comments
Open

Comments

@denis-rodriguez
Copy link

Issue: Custom ORS Server Configuration Not Working in PyVroom 1.14.0

Description

First, I want to thank the vroom-project community for the excellent work on this project.

However, I’ve encountered an issue when trying to configure a custom ORS (OpenRouteService) server in version pyvroom==1.14.0. The setup does not appear to work as expected, and the application does not connect to the specified server. Using the same code with the previous version, pyvroom==1.13.6, the configuration works perfectly, and the connection to the custom ORS server is successful.

I believe this issue may be related to the change introduced in vroom version 1.14.0: (ORS: (previously) hard-coded /ors/v2 slug now has to be added to the path using -a (#1036)). This adjustment may affect the way custom ORS servers are defined and accessed.

I also tried adding /ors/v2 manually to the server host path, as suggested by the change in version 1.14.0, but the setup still did not work as expected.

Steps to Reproduce

  1. Install pyvroom version 1.14.0:

    pip install pyvroom==1.14.0
  2. Run the following code to configure a custom ORS server:

    import vroom
    
    PORT = "8080"
    ORS_IP = 'my_ip'
    problem_instance = vroom.Input(
        router=vroom._vroom.ROUTER.ORS,
        servers={
            "driving-car": vroom._vroom.Server(host=f"{ORS_IP}/ors/v2", port=PORT)  # Attempted to add /ors/v2
        }
    )
    
    problem_instance.add_vehicle([
        vroom.Vehicle(47, start=(4.680125845580168, -74.05976371858429), end=(4.677730595321412, -74.05362682452656), profile="driving-car"),
        vroom.Vehicle(48, start=(4.680125845580168, -74.05976371858429), end=(4.677730595321412, -74.05362682452656), profile="driving-car")
    ])
    
    problem_instance.add_job([
        vroom.Job(1414, location=(4.687613233940918, -74.10073339593728)),
        vroom.Job(1515, location=(4.704355047101732, -74.0500361180842)),
        vroom.Job(1616, location=(4.702243489218623, -74.04473938756222)),
        vroom.Job(1717, location=(4.705259998520047, -74.06244560102137))
    ])
    
    solution = problem_instance.solve(exploration_level=5, nb_threads=4)
    print(solution.to_dict())
  3. Note that in version pyvroom==1.14.0, even with the /ors/v2 path added, the code does not connect to the custom ORS server. However, when switching to version pyvroom==1.13.6, the same code works correctly without this modification.

Additional Information

  • Python version: 3.10
  • Environment: Google Colab (using default configurations)

Comments

Any assistance or guidance on resolving this issue would be greatly appreciated. Thank you!

@jonathf
Copy link
Collaborator

jonathf commented Nov 8, 2024

Looking at the code diff between the two versions, VROOM-Project/vroom#1036 seems like a likely suspect, but this isn't my expertise.

@jcoupey do you have any thoughts on this?

@jcoupey
Copy link
Contributor

jcoupey commented Nov 8, 2024

Yes, this is where the above mentioned changelog entry comes from and that is likely the reason of the change in behavior. What I don't get is why just adding the missing bit does not work.

Can you share the {ORS_IP} value or at least how it looks more precisely? In particular if there are additional / characters in it?

@denis-rodriguez
Copy link
Author

Thank you very much for your quick response!

When I try to specify the IP with the /ors/v2 path, I use something like my_ip/ors/v2, but I receive the following result (see attached image).

script_colab

Seeing this error, I even tried modifying the PORT to include 8080/ors/v2, but unfortunately, that didn’t work either.

Thank you again for your help and support with this!

@jcoupey
Copy link
Contributor

jcoupey commented Nov 8, 2024

Can you share the similar "Failed to connect..." error when using:

PORT = "8080"
ORS_IP = 'my_ip'

@denis-rodriguez
Copy link
Author

Of course, here is the test case using my_ip and 8080.
script_colab

@jcoupey
Copy link
Contributor

jcoupey commented Nov 11, 2024

OK, in the latter case, the request is done to my_ip:8080 but no path is set so you probably get an error response, then we fail to find matrices in it.

The thing is that when using the command-line, there is no way to use ORS without going through the -a option. The call would have something like -a driving-car:my_ip/ors/v2 -p driving-car:8080. Upon parsing command-line flags, we update the servers config. The logic is a bit convoluted in fact, but with the previous options, it ends up doing a POST request to my_ip:8080 using path /ors/v2/matrix/driving-car. Without this call, the server path is not correctly set.

It is in fact not possible to get the same behavior from pyvroom currently by just setting a different host. The way to reproduce the same behavior as when parsing flags would be to somehow expose the update_host function and call it from python with update_host(servers, "driving-car:my_ip/ors/v2").

A cleaner long-term approach would be to extend the Server struct ctor to allow directly passing an explicit path, then one could simply use something like:

servers={
    "driving-car": vroom._vroom.Server(host=f"{ORS_IP}", port=PORT, path="/ors/v2")
}

@jonathf
Copy link
Collaborator

jonathf commented Nov 15, 2024

I have looked at it, and it would be possible to hack an interface through Python, but proper exposing the path as an input to a Server struct constructor is the obvious way to go that should be easy to implement upstream and here.

Shall we aim for that @jcoupey?

@jcoupey
Copy link
Contributor

jcoupey commented Nov 15, 2024

@jonathf sure, I just opened a PR, can you please simply confirm the added ctor in VROOM-Project/vroom#1192 will allow to fix the problem for pyvroom?

@jonathf
Copy link
Collaborator

jonathf commented Dec 6, 2024

@denis-rodriguez, I have made a preview version 1.14.1.dev8 with updates.

Do you mind trying the server string format {ors_ip}:{port}:{path} and let me know if that works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants