Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add call to MTCValidator #297

Merged
merged 4 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
<dependency>
<groupId>com.conveyal</groupId>
<artifactId>gtfs-lib</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
<!-- Exclusions added in order to silence SLF4J warnings about multiple bindings:
http://www.slf4j.org/codes.html#multiple_bindings
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.conveyal.gtfs.GTFS;
import com.conveyal.gtfs.loader.Feed;
import com.conveyal.gtfs.loader.FeedLoadResult;
import com.conveyal.gtfs.validator.MTCValidator;
import com.conveyal.gtfs.validator.ValidationResult;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand All @@ -32,6 +33,7 @@
import java.util.Set;
import java.util.UUID;

import static com.conveyal.datatools.manager.DataManager.isExtensionEnabled;
import static com.conveyal.datatools.manager.utils.StringUtils.getCleanName;
import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
Expand Down Expand Up @@ -226,7 +228,7 @@ public void load(MonitorableJob.Status status, boolean isNewVersion) {
File gtfsFile;
// STEP 1. LOAD GTFS feed into relational database
try {
status.update(false,"Unpacking feed...", 15.0);
status.update("Unpacking feed...", 15.0);
// Get SQL schema namespace for the feed version. This is needed for reconnecting with feeds
// in the database.
gtfsFile = retrieveGtfsFile();
Expand All @@ -241,19 +243,15 @@ public void load(MonitorableJob.Status status, boolean isNewVersion) {
this.namespace = feedLoadResult.uniqueIdentifier;
LOG.info("Loaded GTFS into SQL {}", feedLoadResult.uniqueIdentifier);
} catch (Exception e) {
String errorString = String.format("Error loading GTFS feed for version: %s", this.id);
LOG.warn(errorString, e);
status.update(true, errorString, 0);
status.fail(String.format("Error loading GTFS feed for version: %s", this.id), e);
// FIXME: Delete local copy of feed version after failed load?
return;
}

// FIXME: is this the right approach?
// if load was unsuccessful, update status and return
if(this.feedLoadResult == null) {
String errorString = String.format("Could not load GTFS for FeedVersion %s", id);
LOG.error(errorString);
status.update(true, errorString, 0);
status.fail(String.format("Could not load GTFS for FeedVersion %s", id));
// FIXME: Delete local copy of feed version after failed load?
return;
}
Expand Down Expand Up @@ -310,14 +308,18 @@ public void validate(MonitorableJob.Status status) {
// VALIDATE GTFS feed
try {
LOG.info("Beginning validation...");
// run validation on feed version
// FIXME: pass status to validate? Or somehow listen to events?
status.update("Validating feed...", 33);
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE);

// Validate the feed version.
// Certain extensions, if enabled, have extra validators
if (isExtensionEnabled("mtc")) {
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE, MTCValidator::new);
} else {
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE);
}
} catch (Exception e) {
String message = String.format("Unable to validate feed %s", this.id);
LOG.error(message, e);
status.update(true, message, 100, true);
status.fail(String.format("Unable to validate feed %s", this.id), e);
// FIXME create validation result with new constructor?
validationResult = new ValidationResult();
validationResult.fatalException = "failure!";
Expand Down
Loading