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

Fix start of osrm-contract #469

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

greenscientist
Copy link
Collaborator

osrm-contract expect the file prefix when starting. I don't know how the previous command worked

@tahini
Copy link
Collaborator

tahini commented Nov 25, 2022

Really? Here's the output of osrm-contract --help:

$ osrm-contract --help
Usage: osrm-contract <input.osrm> [options]:
[...]
$ osrm-contract --version
v5.27.1

@greenscientist
Copy link
Collaborator Author

Yep, that's wrong

@tahini
Copy link
Collaborator

tahini commented Nov 25, 2022

What's wrong? the osrm-contract help? If so, since when? Was there a recent change? Would this fix fail on some versions?

It works here because the file is called ${mode}.osrm after extract, so by setting [mode] for <input.osrm> it looks for <mode>.osrm?

@greenscientist
Copy link
Collaborator Author

So I don't have a file $mode.osrm anymore here. Might be a new version thing.
I guess we should test with older version of osrm.
I based this on the output of osrm-extract which said:
"To prepare the data for routing, run: ./osrm-contract "/app/examples/runtime/osrm/walking/walking""
Need to go check the code histoire in osrm

@greenscientist
Copy link
Collaborator Author

So checking the behavior of the osrm code:
It takes the parameter and first strip out any known extention before using it as a base path

So basically, mode.osrm is the same as mode or mode.osm
It does not check that the specific file actually exist, but the rebuild the path to require file base in this base path.

We can still investigate why we do not have an "mode".osrm file generated anymore.

Otherwise, we can keep the diff as is, or we can make it so the cmd is with "$mode.osrm" instead of just "$mode".

@greenscientist
Copy link
Collaborator Author

commit 21888334dd1e0fbbd25cc62c725eb33bb7968147
Author: Siarhei Fedartsou siarhei.fedartsou@gmail.com
Date: Fri Sep 30 14:29:10 2022 +0200

Do not generate intermediate .osrm file in osrm-extract. (#6354)

@greenscientist
Copy link
Collaborator Author

@greenscientist
Copy link
Collaborator Author

it's super confusing and documentation is not well updated yet.

So I'll change this PR to be mode.osrm

@tahini
Copy link
Collaborator

tahini commented Nov 25, 2022

With version 5.25, both the current and preceding version work. With 5.27, the contraction works, but the runtime doesn't. Don't you need to update also the osrm-routed path in the OSRMProcessManager.ts file?

@greenscientist
Copy link
Collaborator Author

hum, probably yes

@greenscientist
Copy link
Collaborator Author

updated, @tahini if you have the chance to test on your side, let me know

// contract parameter need to match the prefix of the osm file passed to extract
// in our case it's the mode name. The .osrm is not generated in the latest osrm-extract
// but the name is still accepted as a base path
const osrmProcess = spawn('osrm-contract', [`${mode}.osrm`], {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another one in the restart function, which is the one that used. But I confirm that ${mode}.osrm works with both 5.25 and 5.27.1, but *.osrm fails with 5.27.1. Maybe call the start from the restart, or do we need both?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess might have a leftover .osrm file locally that made my test pass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a subtle difference between them. But I've now put the args in a common function.

@@ -130,7 +130,7 @@ const start = function(parameters = {} as any): Promise<any> {
return new Promise((resolve, reject) => {
const command = 'osrm-routed';
const commandArgs = [
osrmDirectoryPath + '/*.osrm',
osrmDirectoryPath + `/${mode}.osrm`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other comment applies to this line, not the one from OSRMServicePreparation, sorry.

@greenscientist
Copy link
Collaborator Author

I've made sure to erase the old .osrm in my latest test round.

Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It corresponds to what was working here when tested with both 5.25 and 5.27.1.

Just remove the whitespace so we don't need to add a commit to run yarn format later and it's good

@@ -118,6 +118,14 @@ const configureAllOsrmServers = async function(startServers = true): Promise<voi
}
};

function getOsrmRoutedStartArgs(osrmDirectory: string, mode: string, port: string) : string[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn format would remove a whitespace before the ':' on this line

osrm-contract expect the file prefix when starting. The latest osrm-extract
don't generate a .osrm file anymore by default (only in debug mode)
so we cannot use the *.osrm trick anymore. We have to pass the actual file name
prefix
@greenscientist
Copy link
Collaborator Author

Fixed my yarn format command, so should be good

@tahini tahini merged commit 80b895a into chairemobilite:main Nov 28, 2022
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

Successfully merging this pull request may close these issues.

2 participants