Skip to content

Configure each transit feed properties individually - #4399

Merged
vpaturet merged 25 commits into
opentripplanner:dev-2.xfrom
entur:otp2_per_feed_configuration
Sep 1, 2022
Merged

vpaturet merged 25 commits into
opentripplanner:dev-2.xfrom
entur:otp2_per_feed_configuration

Conversation

@vpaturet

@vpaturet vpaturet commented Aug 22, 2022 •

Copy link
Copy Markdown
Contributor

Summary

Extend the build-config JSON format to support per-feed configuration for OSM extracts, DEM extracts, NeTEx feeds and GTFS feeds.
This PR updates the format of the build-config.json file in order to support custom properties for OSM extracts, DEM extracts, NeTEx feeds and GTFS feeds.
It also makes use of these new properties for NeTEx feeds and GTFS feeds (overriding of feedId and file patterns)
Subsequent PRs will implement property overriding for OSM and DEM extracts.

Issue

Implements #4262 and #4263

Unit tests

✅

Documentation

Entur example, Configuration.md, BuildConfiguration.md and GoogleCloudStorage.md
and speed test configuration updated.

@codecov-commenter

codecov-commenter commented Aug 23, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #4399 (6f0aa70) into dev-2.x (ae10043) will increase coverage by 0.06%.
The diff coverage is 60.54%.

@@              Coverage Diff              @@
##             dev-2.x    #4399      +/-   ##
=============================================
+ Coverage      58.09%   58.15%   +0.06%     
- Complexity     11070    11138      +68     
=============================================
  Files           1454     1468      +14     
  Lines          58760    58955     +195     
  Branches        6771     6760      -11     
=============================================
+ Hits           34138    34287     +149     
- Misses         22586    22631      +45     
- Partials        2036     2037       +1     
Impacted Files Coverage Δ
...planner/ext/datastore/gs/AbstractGsDataSource.java 0.00% <0.00%> (ø)
.../org/opentripplanner/datastore/api/DataSource.java 9.09% <ø> (ø)
...ripplanner/datastore/base/ByteArrayDataSource.java 93.10% <0.00%> (-3.33%) ⬇️
...r/datastore/base/ZipStreamDataSourceDecorator.java 68.62% <0.00%> (-1.38%) ⬇️
...planner/datastore/file/ZipFileEntryDataSource.java 73.33% <0.00%> (-5.24%) ⬇️
...rg/opentripplanner/graph_builder/GraphBuilder.java 0.00% <0.00%> (ø)
...planner/graph_builder/GraphBuilderDataSources.java 0.00% <0.00%> (ø)
..._builder/module/configure/GraphBuilderModules.java 0.00% <0.00%> (ø)
.../graph_builder/module/osm/OpenStreetMapModule.java 84.65% <0.00%> (ø)
...in/java/org/opentripplanner/netex/NetexBundle.java 89.09% <ø> (ø)
... and 68 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@t2gran t2gran added this to the 2.2 milestone Aug 24, 2022
@t2gran t2gran added !New Feature A functional feature targeting the end user. +Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR labels Aug 24, 2022
@t2gran t2gran changed the title Otp2 per feed configuration Configure each fead individually Aug 24, 2022
@leonardehrenfried leonardehrenfried changed the title Configure each fead individually Configure each feed individually Aug 25, 2022
@vpaturet
vpaturet marked this pull request as ready for review August 25, 2022 13:32
@vpaturet
vpaturet requested a review from a team as a code owner August 25, 2022 13:32
@hannesj
hannesj requested review from hannesj and optionsome August 25, 2022 13:38

@optionsome optionsome 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.

I read through the code and didn't find any real issues. I tried testing this but the documentation is not there yet and I tried with roughly what was defined in #4263 but the structure of my config was probably wrong somehow and it complained that some of the defined config parameters were unused and the params were not taken into use based on testing:

12:34:35.578 WARN (NodeAdapter.java:492) Unexpected config parameter: 'osm.[1].timezone:"Europe/Helsinki"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[1].feedId:"hsl-test"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[1].source:"HSL-gtfs.zip"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[2].source:"HSLlautta-gtfs.zip"' in 'build-config.json'. Is the spelling correct?

This was how I defined the data sources in the build-config.json

"osm": [
        {
          "source": "hsl.pbf",
          "osmWayPropertySet": "finland",
          "timezone": "Europe/Helsinki"
        }
  ],
  "dem" : [
    {
       "source": "hsl.tif",
       "elevationUnitMultiplier": 0.1
    }
  ],
  "transitFeeds": [
        {
          "type": "gtfs",
          "feedId": "hsl-test",
          "source": "HSL-gtfs.zip"
        },
        {
          "type": "gtfs",
          "source": "HSLlautta-gtfs.zip"
        }
    ]

@leonardehrenfried

Copy link
Copy Markdown
Member

I always thought that the name osmWayPropertySet is a strange name that doesn't tell you what it does.

Would you be open to renaming it to locationProfile (just in JSON)?

vpaturet and others added 2 commits August 26, 2022 13:15
…tractConfigBuilder.java

Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
…tractConfig.java

Co-authored-by: Joel Lappalainen <lappalj8@gmail.com>
@vpaturet

Copy link
Copy Markdown
Contributor Author

I read through the code and didn't find any real issues. I tried testing this but the documentation is not there yet and I tried with roughly what was defined in #4263 but the structure of my config was probably wrong somehow and it complained that some of the defined config parameters were unused and the params were not taken into use based on testing:

12:34:35.578 WARN (NodeAdapter.java:492) Unexpected config parameter: 'osm.[1].timezone:"Europe/Helsinki"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[1].feedId:"hsl-test"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[1].source:"HSL-gtfs.zip"' in 'build-config.json'. Is the spelling correct?
12:34:35.579 WARN (NodeAdapter.java:492) Unexpected config parameter: 'transitFeeds.[2].source:"HSLlautta-gtfs.zip"' in 'build-config.json'. Is the spelling correct?

This was how I defined the data sources in the build-config.json

"osm": [
        {
          "source": "hsl.pbf",
          "osmWayPropertySet": "finland",
          "timezone": "Europe/Helsinki"
        }
  ],
  "dem" : [
    {
       "source": "hsl.tif",
       "elevationUnitMultiplier": 0.1
    }
  ],
  "transitFeeds": [
        {
          "type": "gtfs",
          "feedId": "hsl-test",
          "source": "HSL-gtfs.zip"
        },
        {
          "type": "gtfs",
          "source": "HSLlautta-gtfs.zip"
        }
    ]

Your configuration is correct. There are 2 issues here: there is a bug that causes a parameter to be mistakenly reported as unused even if it is properly read.
The other issue is that matching a datasource to its configuration is done by comparing the URI of the datasource to the source parameter of the configuration. This works only if the source parameter is a fully qualified URI like file:/path/to/HSL-gtfs.zip.

@vpaturet

Copy link
Copy Markdown
Contributor Author

I always thought that the name osmWayPropertySet is a strange name that doesn't tell you what it does.

Would you be open to renaming it to locationProfile (just in JSON)?

Sure, this can be done in the following PR that will implement property overriding for the OSM extracts.

@optionsome

Copy link
Copy Markdown
Member

Your configuration is correct. There are 2 issues here: there is a bug that causes a parameter to be mistakenly reported as unused even if it is properly read. The other issue is that matching a datasource to its configuration is done by comparing the URI of the datasource to the source parameter of the configuration. This works only if the source parameter is a fully qualified URI like file:/path/to/HSL-gtfs.zip.

OK, I got confused when it crashed the build when I tried to define a relative path from where I was running the OTP from instead of a relative path from the build-config file which didn't crash the build.

@vpaturet

Copy link
Copy Markdown
Contributor Author

@optionsome now this should work also when the source parameter is relative to the base directory.

@hannesj hannesj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code itself looks good, but the entur example should be updated to match the new behaviour. Same with Configuration.md, BuildConfiguration.md and GoogleCloudStorage.md

@hannesj hannesj changed the title Configure each feed individually Configure each transit feed properties individually Aug 30, 2022
@vpaturet

vpaturet commented Sep 1, 2022 •

Copy link
Copy Markdown
Contributor Author

Entur example, Configuration.md, BuildConfiguration.md and GoogleCloudStorage.md
and speed test configuration updated

| `writeCachedElevations` | If true, writes the calculated elevation data. | boolean | false | see [Elevation Data Calculation Optimizations](#elevation-data-calculation-optimizations) |

This list of parameters in defined in
| `buildReportDir` | Path to directory where the build issue report will be written. | uri | null | |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these be moved to keep alphabetical order?

@optionsome optionsome 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.

Should we also update the OTP2-MigrationGuide.md here?

| `blockBasedInterlining` | Whether to automatically insert an in-seat transfer between two trips with the same block id. | boolean | true | Consider using using [transfer types 4 and 5](https://github.com/google/transit/pull/303) |
| `boardingLocationTags` | The OSM tags to extract a stop's boarding location from. | list | `["ref"]` | [Detailed documentation](./BoardingLocations.md) |
| `dataImportReport` | Generate nice HTML report of Graph errors/warnings | boolean | false | |
| `dem` | Configure access to elevation data. | array | null | |

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.

Maybe we should link the appropriate chapter in this file from these new descriptions as otherwise it can be confusing to understand what type of an array you need to provide.

.

## Storage
## Transit Feeds

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.

Should we explain here if it is possible to define custom configuration for one data set while not defining other data sets in the transitFeeds and just trust on the default scanning?

@t2gran

t2gran commented Sep 1, 2022

Copy link
Copy Markdown
Member

The OTP2-MigrationGuide.md should have one line saying that the feed configuration is changed.

@vpaturet
vpaturet merged commit 6e3f76b into opentripplanner:dev-2.x Sep 1, 2022
t2gran pushed a commit that referenced this pull request Sep 1, 2022
@leonardehrenfried leonardehrenfried added the +Config Change This PR might require the configuration to be updated. label Sep 1, 2022
t2gran pushed a commit that referenced this pull request Sep 1, 2022
@t2gran
t2gran deleted the otp2_per_feed_configuration branch March 31, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Bump Serialization Id Add this label if you want the serialization id automatically bumped after merging the PR +Config Change This PR might require the configuration to be updated. !New Feature A functional feature targeting the end user.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants