-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from ibi-group/threaded-validation
Threaded validation
- Loading branch information
Showing
7 changed files
with
128 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM maven:3.8.6-openjdk-11 | ||
FROM maven:3.8.7-openjdk-18-slim | ||
|
||
COPY . /datatools | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/conveyal/datatools/manager/jobs/ValidateMobilityDataFeedJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.conveyal.datatools.manager.jobs; | ||
|
||
import com.conveyal.datatools.common.status.FeedVersionJob; | ||
import com.conveyal.datatools.manager.auth.Auth0UserProfile; | ||
import com.conveyal.datatools.manager.models.FeedVersion; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This job handles the MobilityData validation of a given feed version. If the version is not new, it will simply | ||
* replace the existing version with the version object that has updated validation info. | ||
*/ | ||
public class ValidateMobilityDataFeedJob extends FeedVersionJob { | ||
public static final Logger LOG = LoggerFactory.getLogger(ValidateMobilityDataFeedJob.class); | ||
|
||
private final FeedVersion feedVersion; | ||
private final boolean isNewVersion; | ||
|
||
public ValidateMobilityDataFeedJob(FeedVersion version, Auth0UserProfile owner, boolean isNewVersion) { | ||
super(owner, "Validating Feed using MobilityData", JobType.VALIDATE_FEED); | ||
feedVersion = version; | ||
this.isNewVersion = isNewVersion; | ||
status.update("Waiting to begin MobilityData validation...", 0); | ||
} | ||
|
||
@Override | ||
public void jobLogic () { | ||
LOG.info("Running ValidateMobilityDataFeedJob for {}", feedVersion.id); | ||
feedVersion.validateMobility(status); | ||
} | ||
|
||
@Override | ||
public void jobFinished () { | ||
if (!status.error) { | ||
if (parentJobId != null && JobType.PROCESS_FEED.equals(parentJobType)) { | ||
// Validate stage is happening as part of an overall process feed job. | ||
// At this point all GTFS data has been loaded and validated, so we record | ||
// the FeedVersion into mongo. | ||
// This happens here because otherwise we would have to wait for other jobs, | ||
// such as BuildTransportNetwork, to finish. If those subsequent jobs fail, | ||
// the version won't get loaded into MongoDB (even though it exists in postgres). | ||
feedVersion.persistFeedVersionAfterValidation(isNewVersion); | ||
} | ||
status.completeSuccessfully("MobilityData validation finished!"); | ||
} else { | ||
// If the version was not stored successfully, call FeedVersion#delete to reset things to before the version | ||
// was uploaded/fetched. Note: delete calls made to MongoDB on the version ID will not succeed, but that is | ||
// expected. | ||
feedVersion.delete(); | ||
} | ||
} | ||
|
||
/** | ||
* Getter that allows a client to know the ID of the feed version that will be created as soon as the upload is | ||
* initiated; however, we will not store the FeedVersion in the mongo application database until the upload and | ||
* processing is completed. This prevents clients from manipulating GTFS data before it is entirely imported. | ||
*/ | ||
@JsonProperty | ||
public String getFeedVersionId () { | ||
return feedVersion.id; | ||
} | ||
|
||
@JsonProperty | ||
public String getFeedSourceId () { | ||
return feedVersion.parentFeedSource().id; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters