Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into update-semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jun 12, 2024
2 parents bf90d79 + b9e54d2 commit dfce217
Show file tree
Hide file tree
Showing 100 changed files with 7,651 additions and 3,263 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:

- name: Build GTFS GraphQL API documentation
run: |
npm install -g @magidoc/cli@4.0.0
npm install -g @magidoc/cli@4.1.4
magidoc generate
- name: Deploy compiled HTML to Github pages
Expand Down
5 changes: 2 additions & 3 deletions client-next/src/hooks/useServerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useEffect, useState } from 'react';
import { graphql } from '../gql';
import { request } from 'graphql-request'; // eslint-disable-line import/no-unresolved
import { QueryType } from '../gql/graphql.ts';

const endpoint = import.meta.env.VITE_API_URL;
import { getApiUrl } from '../util/getApiUrl.ts';

const query = graphql(`
query serverInfo {
Expand All @@ -22,7 +21,7 @@ export const useServerInfo = () => {
const [data, setData] = useState<QueryType | null>(null);
useEffect(() => {
const fetchData = async () => {
setData((await request(endpoint, query)) as QueryType);
setData((await request(getApiUrl(), query)) as QueryType);
};
fetchData();
}, []);
Expand Down
7 changes: 3 additions & 4 deletions client-next/src/hooks/useTripQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
import { graphql } from '../gql';
import { request } from 'graphql-request'; // eslint-disable-line import/no-unresolved
import { QueryType, TripQueryVariables } from '../gql/graphql.ts';

const endpoint = import.meta.env.VITE_API_URL;
import { getApiUrl } from '../util/getApiUrl.ts';

/**
General purpose trip query document for debugging trip searches
Expand Down Expand Up @@ -96,9 +95,9 @@ export const useTripQuery: TripQueryHook = (variables) => {
if (variables) {
setLoading(true);
if (pageCursor) {
setData((await request(endpoint, query, { ...variables, pageCursor })) as QueryType);
setData((await request(getApiUrl(), query, { ...variables, pageCursor })) as QueryType);
} else {
setData((await request(endpoint, query, variables)) as QueryType);
setData((await request(getApiUrl(), query, variables)) as QueryType);
}
setLoading(false);
} else {
Expand Down
12 changes: 12 additions & 0 deletions client-next/src/util/getApiUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const endpoint = import.meta.env.VITE_API_URL;

export const getApiUrl = () => {
try {
// the URL constructor will throw exception if endpoint is not a valid URL,
// e.g. if it is a relative path
new URL(endpoint);
return endpoint;
} catch (e) {
return `${window.location.origin}${endpoint}`;
}
};
1 change: 0 additions & 1 deletion docs/Analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Much of the analysis code present in the v1.x legacy branch of OTP is essentiall

OTP2's new transit router is quite similar to R5 (indeed it was directly influenced by R5) and would not face the same technical problems. Nonetheless, we have decided not to port the OTP1 analysis features over to OTP2 since it would broaden the scope of OTP2 away from passenger information and draw the finite amount of available attention and resources away from existing open source analytics tools. If you would like to apply the routing innovations present in OTP2 in analytics situations, we recommend taking a look at projects like R5 or the R and Python language wrappers for it created by the community.

Some analytics features may still be available as optional "sandbox" features in OTP2 (such as [Travel Time](sandbox/TravelTime.md)), but these do not work in the same way as the features you may have used or read about in OTP1. They are unmaintained and unsupported, and may be removed in the near future.

## Terminology Note

Expand Down
3 changes: 3 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Fix SIRI update travel back in time [#5867](https://github.com/opentripplanner/OpenTripPlanner/pull/5867)
- Limit result size and execution time in TransModel GraphQL API [#5883](https://github.com/opentripplanner/OpenTripPlanner/pull/5883)
- Fix real-time added patterns persistence with DIFFERENTIAL updates [#5726](https://github.com/opentripplanner/OpenTripPlanner/pull/5726)
- Add plan query that follows the relay connection specification [#5185](https://github.com/opentripplanner/OpenTripPlanner/pull/5185)
- Fix debug client after breaking change in dependency graphql-request [#5899](https://github.com/opentripplanner/OpenTripPlanner/pull/5899)
- Remove TravelTime API [#5890](https://github.com/opentripplanner/OpenTripPlanner/pull/5890)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.5.0 (2024-03-13)
Expand Down
1 change: 0 additions & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ Here is a list of all features which can be toggled on/off and their default val
| `SandboxAPIGeocoder` | Enable the Geocoder API. | | ✓️ |
| `SandboxAPIMapboxVectorTilesApi` | Enable Mapbox vector tiles API. | | ✓️ |
| `SandboxAPIParkAndRideApi` | Enable park-and-ride endpoint. | | ✓️ |
| `SandboxAPITravelTime` | Enable the isochrone/travel time surface API. | | ✓️ |
| `TransferAnalyzer` | Analyze transfers during graph build. | | ✓️ |

<!-- OTP-FEATURE-TABLE END -->
Expand Down
61 changes: 0 additions & 61 deletions docs/sandbox/TravelTime.md

This file was deleted.

1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ nav:
- Data Overlay: 'sandbox/DataOverlay.md'
- Vehicle Parking Updaters: 'sandbox/VehicleParking.md'
- Geocoder API: 'sandbox/GeocoderAPI.md'
- Travel Time Isochrones: 'sandbox/TravelTime.md'
- IBI Accessibility Score: 'sandbox/IBIAccessibilityScore.md'
- Fares: 'sandbox/Fares.md'
- Ride Hailing: 'sandbox/RideHailing.md'
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
<!-- This make sure all google libraries are using compatible versions. -->
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.34.0</version>
<version>26.40.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -852,12 +852,12 @@
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>21.5</version>
<version>22.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>21.0</version>
<version>22.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/client/debug-client-preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-10T05:54/assets/index-BXeRZq-B.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-10T05:54/assets/index-CrZjV0cy.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-11T11:54/assets/index-DYQwFvLR.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/06/2024-06-11T11:54/assets/index-CrZjV0cy.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters;
import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters;
import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters;
import graphql.execution.instrumentation.parameters.InstrumentationValidationParameters;
import graphql.language.Document;
import graphql.schema.GraphQLTypeUtil;
Expand All @@ -22,7 +21,6 @@
import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.Timer;
import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
* Using this instrumentation we can precisely measure how queries and data fetchers are executed
Expand Down Expand Up @@ -107,21 +105,13 @@ public ExecutionStrategyInstrumentationContext beginExecutionStrategy(
) {
return new ExecutionStrategyInstrumentationContext() {
@Override
public void onDispatched(CompletableFuture<ExecutionResult> result) {}
public void onDispatched() {}

@Override
public void onCompleted(ExecutionResult result, Throwable t) {}
};
}

@Override
public InstrumentationContext<ExecutionResult> beginField(
InstrumentationFieldParameters parameters,
InstrumentationState state
) {
return noOp();
}

@Override
public InstrumentationContext<Object> beginFieldFetch(
InstrumentationFieldFetchParameters parameters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.annotation.Nullable;
import org.opentripplanner.model.Timetable;
import org.opentripplanner.model.TimetableSnapshot;
import org.opentripplanner.model.TimetableSnapshotProvider;
import org.opentripplanner.transit.model.framework.DataValidationException;
import org.opentripplanner.transit.model.framework.Result;
import org.opentripplanner.transit.model.network.TripPattern;
Expand All @@ -29,7 +30,7 @@
import org.opentripplanner.updater.spi.UpdateError;
import org.opentripplanner.updater.spi.UpdateResult;
import org.opentripplanner.updater.spi.UpdateSuccess;
import org.opentripplanner.updater.trip.AbstractTimetableSnapshotSource;
import org.opentripplanner.updater.trip.TimetableSnapshotManager;
import org.opentripplanner.updater.trip.UpdateIncrementality;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -41,7 +42,7 @@
* necessary to provide planning threads a consistent constant view of a graph with real-time data at
* a specific point in time.
*/
public class SiriTimetableSnapshotSource extends AbstractTimetableSnapshotSource {
public class SiriTimetableSnapshotSource implements TimetableSnapshotProvider {

private static final Logger LOG = LoggerFactory.getLogger(SiriTimetableSnapshotSource.class);

Expand All @@ -59,15 +60,18 @@ public class SiriTimetableSnapshotSource extends AbstractTimetableSnapshotSource

private final TransitService transitService;

private final TimetableSnapshotManager snapshotManager;

public SiriTimetableSnapshotSource(
TimetableSnapshotSourceParameters parameters,
TransitModel transitModel
) {
super(
transitModel.getTransitLayerUpdater(),
parameters,
() -> LocalDate.now(transitModel.getTimeZone())
);
this.snapshotManager =
new TimetableSnapshotManager(
transitModel.getTransitLayerUpdater(),
parameters,
() -> LocalDate.now(transitModel.getTimeZone())
);
this.transitModel = transitModel;
this.transitService = new DefaultTransitService(transitModel);
this.tripPatternCache =
Expand Down Expand Up @@ -100,10 +104,10 @@ public UpdateResult applyEstimatedTimetable(

List<Result<UpdateSuccess, UpdateError>> results = new ArrayList<>();

withLock(() -> {
snapshotManager.withLock(() -> {
if (incrementality == FULL_DATASET) {
// Remove all updates from the buffer
buffer.clear(feedId);
snapshotManager.clearBuffer(feedId);
}

for (var etDelivery : updates) {
Expand All @@ -118,12 +122,17 @@ public UpdateResult applyEstimatedTimetable(

LOG.debug("message contains {} trip updates", updates.size());

purgeAndCommit();
snapshotManager.purgeAndCommit();
});

return UpdateResult.ofResults(results);
}

@Override
public TimetableSnapshot getTimetableSnapshot() {
return snapshotManager.getTimetableSnapshot();
}

private Result<UpdateSuccess, UpdateError> apply(
EstimatedVehicleJourney journey,
TransitModel transitModel,
Expand Down Expand Up @@ -228,7 +237,7 @@ private Result<TripUpdate, UpdateError> handleModifiedTrip(
estimatedVehicleJourney,
entityResolver,
this::getCurrentTimetable,
buffer::getRealtimeAddedTripPattern
snapshotManager::getRealtimeAddedTripPattern
);

if (tripAndPattern == null) {
Expand Down Expand Up @@ -271,7 +280,7 @@ private Result<TripUpdate, UpdateError> handleModifiedTrip(

// Also check whether trip id has been used for previously ADDED/MODIFIED trip message and
// remove the previously created trip
this.buffer.revertTripToScheduledTripPattern(trip.getId(), serviceDate);
this.snapshotManager.revertTripToScheduledTripPattern(trip.getId(), serviceDate);

return updateResult;
}
Expand All @@ -290,7 +299,7 @@ private Result<UpdateSuccess, UpdateError> addTripToGraphAndBuffer(TripUpdate tr
serviceDate
);
// Add new trip times to buffer, making protective copies as needed. Bubble success/error up.
var result = buffer.update(pattern, tripUpdate.tripTimes(), serviceDate);
var result = snapshotManager.updateBuffer(pattern, tripUpdate.tripTimes(), serviceDate);
LOG.debug("Applied real-time data for trip {} on {}", trip, serviceDate);
return result;
}
Expand All @@ -315,7 +324,7 @@ private boolean markScheduledTripAsDeleted(Trip trip, final LocalDate serviceDat
} else {
final RealTimeTripTimes newTripTimes = tripTimes.copyScheduledTimes();
newTripTimes.deleteTrip();
buffer.update(pattern, newTripTimes, serviceDate);
snapshotManager.updateBuffer(pattern, newTripTimes, serviceDate);
success = true;
}
}
Expand Down
Loading

0 comments on commit dfce217

Please sign in to comment.