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 2 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
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 Down Expand Up @@ -226,7 +227,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 +242,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 @@ -313,11 +310,9 @@ public void validate(MonitorableJob.Status status) {
// 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);
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE, MTCValidator::new);
Copy link
Contributor

@landonreed landonreed Apr 14, 2020

Choose a reason for hiding this comment

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

@binh-dam-ibigroup, I think we should only run the MTCValidator if the MTC extension is enabled isExtensionEnabled("mtc"). We only want the MTC-specific checks running on MTC instances of Data Tools, not for everyone. We should also add some commentary about this.

} 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