Skip to content

Add --input-format option#1269

Merged
jamesaoverton merged 5 commits intoontodev:masterfrom
gouttegd:add-input-format-option
Oct 30, 2025
Merged

Add --input-format option#1269
jamesaoverton merged 5 commits intoontodev:masterfrom
gouttegd:add-input-format-option

Conversation

@gouttegd
Copy link
Contributor

Resolves [#1038]

  • docs/ have been added/updated
  • tests have been added/updated
  • mvn verify says all tests pass
  • mvn site says all JavaDocs correct
  • CHANGELOG.md has been updated

This PR is another attempt to implement the --input-format option 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 a OWLDocumentFormat object when constructing the OWLOntologyDocumentSource (as suggested by @balhoff here).

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.
@gouttegd gouttegd self-assigned this Oct 26, 2025
@gouttegd gouttegd requested review from balhoff and matentzn October 26, 2025 21:10
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

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

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

  1. You did not remove any method ✅
  2. Your changes are documented ✅
  3. 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to myself - the catalog handling is pushed into the loadOntology function here

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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);
      }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I’m a bit late to the game. 😅 #1274

Copy link
Contributor

@balhoff balhoff left a comment

Choose a reason for hiding this comment

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

Thanks @gouttegd! I approve, but check my one code comment.

@jamesaoverton jamesaoverton merged commit 73c2ba3 into ontodev:master Oct 30, 2025
3 checks passed
@jamesaoverton
Copy link
Member

Much appreciated!

@gouttegd gouttegd deleted the add-input-format-option branch February 18, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments