Skip to content

Allow adding CH preparations to existing graph folder #2453

Closed

Description

@easbar

We cannot add CH preparations to an existing graph folder. However, this does work for LM preparations. I'd like to get rid of this asymmetry. There are three levels to support this kind of 'delta import' that I can think of:

  1. Do not allow adding anything to an existing graph folder. This is the simplest approach, but also the most frustrating one for users. To change anything about the preparations one needs to remove the graph folder and run the import again.
  2. Allow adding CH (LM) preparations to an existing graph folder, but only as long as there are no CH (LM) preparations.
  3. Allow adding CH (LM) preparations no matter whether there are some already or not.

Currently we support 3) for LM (we can just add more LM preparations), but under no circumstances can we add CH preparations.

I would not have mentioned 2) if there weren't these prepare.ch/lm.done flags in the properties file. These flags imply that LM or CH preparation is either "done" or not, so adding preparations would only be possible if there weren't any others yet (case 2)). However, the flag for LM is only written, but never read. The flag for CH is written and read, but I think before it is read adding CH preparations already fails in checkIfConfiguredAndLoadedWeightingsCompatible() which checks the graph.ch.profiles field of the properties file during GraphHopperStorage#loadExisting.

We also have these version flags like graph.profiles.car.version=-1833937352, which, are used for LM and CH and overwrite each other:

for (LMProfile profile : lmPreparationHandler.getLMProfiles()) {
// potentially overwrite existing keys from CH
setProfileVersion(profile.getProfile(), profilesByName.get(profile.getProfile()).getVersion());
}

I think we should just use graph.profiles.ch/lm.car.version (store one separate version hash for each CH and LM preparation, if not just store the actual profile) instead of graph.profiles.car.version that is currently used for both CH and LM. We should also remove prepare.lm.done because it is never read anyway and then we should also remove prepare.ch.done so we can add CH preparations just like LM. graph.ch.profiles we should also just get rid of.

Here is a little todo list:

  • decide whether or not we want to support this whole idea of 'delta imports' -> we do

if yes:

  • remove prepare.lm.done because it is not used anyway
  • replace graph.profiles.car.version with graph.profiles.ch.car.version and graph.profiles.lm.car.version
  • remove prepare.ch.done and use graph.profiles.ch.car.version instead
  • get rid of graph.ch.profiles and no longer require adding CHs to GraphHopperStorage before the CH preparation
  • maybe store the actual profiles instead of the version hashs for each preparation so we can load each preparation without providing the original profile that was used during import

I think adding CH preparation to an existing folder can come in handy, but the main reason I ran into this issue is that all these prepare flags unecessarily entangle the code in GraphHopper, CH/LMPreparationHandler and GraphHopperStorage and make it hard to separate import and loading code (c.f. #1895).

Activity

  1. michaz commented on Nov 11, 2021

    @michaz
    Member

    +1 This would be (long-term) super-useful for transit.

  2. easbar commented on Dec 8, 2021

    @easbar
    MemberAuthor

    Fixed by #2481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions