Skip to content

Remove YAML support for server-side custom models - #2672

Merged
karussell merged 4 commits into
masterfrom
remove_yml
Oct 11, 2022
Merged

karussell merged 4 commits into
masterfrom
remove_yml

Conversation

@karussell

@karussell karussell commented Oct 10, 2022 •

Copy link
Copy Markdown
Member

Fixes #2671.

For server-side JSON files still comments with // are allowed. See the example files.

Unfortunately this does not reduce the dependencies as dropwizard still uses (and has to use) the YAMLFactory

  • there is intrinsic support in jackson for JSON with comments: Feature.ALLOW_COMMENTS -> don't use it to make these files still simple to parse for other JSON tools.

@karussell
karussell temporarily deployed to benchmarks October 10, 2022 10:30 Inactive
@otbutz

otbutz commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

Wouldn't it be better to stick with vanilla JSON and rather use dedicated keys?

{
  "comment": "this is a little customized model used to benchmark routing with a customized weighting that is similar to the standard car profile",
  "priority": [
    {
      "if": "road_access == PRIVATE",
      "multiply_by": "0.1"
    },
    {
      "else_if": "road_access == DESTINATION",
      "multiply_by": "0.1"
    }
  ],
  "distance_influence": 0
}

@karussell

Copy link
Copy Markdown
Member Author

Not sure. Using comments this way is very verbose and please note that this would be only for the server-side config.

@karussell
karussell temporarily deployed to benchmarks October 10, 2022 11:57 Inactive
@karussell
karussell temporarily deployed to benchmarks October 10, 2022 12:02 Inactive
@karussell

Copy link
Copy Markdown
Member Author

In general using just JSON would be simple and sufficient (why couldn't they add comments to the spec!?).

But somehow this feels ugly and will get uglier the more complex these models get. E.g. see when you need multiple lines: 417d4c9

@otbutz

otbutz commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

why couldn't they add comments to the spec!?

Amen.

see when you need multiple lines:

Unique keys are not a hard requirement AFAIK. As long as our parser doesn't choke on it:

{
  "comment": "to use this custom model you need to set the following option in the config.yml",
  "comment": "graph.flag_encoders: roads|transportation_mode=HGV,car",
  "comment": "graph.encoded_values: toll,hgv,surface,max_width,max_height",
  "distance_influence": 1,
  "speed": [
    {
      "if": "true",
      "limit_to": "car_average_speed * 0.9"
    },
    {
      "if": "true",
      "limit_to": "95"
    }
  ],
  "priority": [
    {
      "if": "car_access == false || hgv == NO || max_width < 3 || max_height < 4",
      "multiply_by": "0"
    }
  ]
}

@easbar

easbar commented Oct 11, 2022

Copy link
Copy Markdown
Member

With the "comment" fields we can add some descriptions to the custom model, but we cannot comment out some of the rules. I think this might be even more important than being able to add descriptions.

Btw ideally, these comments:

  "comment": "to use this custom model you need to set the following option in the config.yml",
  "comment": "graph.flag_encoders: roads|transportation_mode=HGV,car",
  "comment": "graph.encoded_values: toll,hgv,surface,max_width,max_height",

won't be necessary anyway :)

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@karussell karussell added this to the 7.0 milestone Oct 11, 2022
@karussell
karussell merged commit 19f2757 into master Oct 11, 2022
@karussell
karussell deleted the remove_yml branch October 11, 2022 08:26

This branch was previously deployed

1 inactive deployment
benchmarks — 417d4c9a Deployed Oct 10, 2022 by karussell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use JSON for custom model files

3 participants