Add --input-format option#1269
Conversation
Add a common `--input-format` option which accepts the same values as the `--output-format` option, but indicates the expected format of the input file (as loaded by the `CommandLineHelper.updateInputOntology` method).
Update the `CommandLineHelper.getInputOntologies()` methods so that they too use the `--input-format` option if it is present in the command line.
Mention the `--input-format` option in the global documentation. Add a basic test in which we attempt to load a OFN-formatted file that imports a OWL file, first with the correct format, then with an incorrect format.
matentzn
left a comment
There was a problem hiding this comment.
It looks great to me, I left a few comments for the next reviewer (not for you @gouttegd). The diff is a bit suboptimal for an easy review, but i got it in the end
- You did not remove any method ✅
- Your changes are documented ✅
- The default behaviour appears to be preserved (based my reading of FileDocumentSource(x,y)) ✅
@balhoff can you also to a sweep?
| } else { | ||
| return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0))); | ||
| } | ||
| return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0)), catalogPath, inputFormat); |
There was a problem hiding this comment.
Note to myself - the catalog handling is pushed into the loadOntology function here
There was a problem hiding this comment.
This looked right to me, but now I'm seeing a bug in the OBI build process introduced since 1.9.8, and I think this is the source.
The usual path was that I do not specify a catalog file, and then we call loadOntology(ontologyPath) which would call guessCatalogFile(ontologyPath). But now this calls loadOntology(ontologyPath, catalogPath, inputFormat) with catalogPath = null which does not call guessCatalogPath(ontologyPath) and breaks my stuff. See new line 369 of IOHelper
There was a problem hiding this comment.
I believe you’re right.
One possible fix should be:
if (!inputOntologyPaths.isEmpty()) {
if (catalogPath != null) {
return ioHelper.loadOntology(inputOntologyPaths.get(0), catalogPath, inputFormat);
} else {
// Explicitly calls the variant of `IOHelper#loadOntology` that can
// guess the location of the catalog file
return ioHelper.loadOntology(inputOntologyPaths.get(0), true, inputFormat);
}
}|
Much appreciated! |
Resolves [#1038]
docs/have been added/updatedmvn verifysays all tests passmvn sitesays all JavaDocs correctCHANGELOG.mdhas been updatedThis PR is another attempt to implement the
--input-formatoption requested in #1038. The difference with #1056 is that instead of restricting the parsers available to the OWLManager (which has the side effect that imports cannot be parsed if they happen to be in a different format than the main ontology), here we simply explicitly pass aOWLDocumentFormatobject when constructing theOWLOntologyDocumentSource(as suggested by @balhoff here).