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

Silencing import errors does not seem to work for OBO files #1123

Open
reckart opened this issue Feb 11, 2024 · 6 comments
Open

Silencing import errors does not seem to work for OBO files #1123

reckart opened this issue Feb 11, 2024 · 6 comments

Comments

@reckart
Copy link

reckart commented Feb 11, 2024

When loading an OBO file that contains an import (such as the example1.obo file from this project's test data), it fails with an exception if network access is not available.

Using a AutoIRIMapper and/or MissingImportHandlingStrategy.SILENT (as suggested here) does not seem to work.

        var manager = OWLManager.createOWLOntologyManager();

        // Does not seem to work for imports in OBO files....
        var iriMappers = manager.getIRIMappers();
        iriMappers.add(
                new AutoIRIMapper(new File(kbRepositoriesRoot, "materializedOntologies"), true));
        manager.getOntologyLoaderConfiguration()
                .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT);
        manager.getOntologyConfigurator()
                .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT);

        var ontology = manager.loadOntologyFromOntologyDocument(... input stream for OBO file ...);
@ignazio1977
Copy link
Contributor

ignazio1977 commented Feb 11, 2024

OWLOntologyLoaderConfiguration is an immutable object. When you set a property on it, you need to tell the manager to use the new object:

manager.setOntologyLoaderConfiguration(
    manager.getOntologyConfigurator()
            .setMissingImportHandlingStrategy(
                 MissingImportHandlingStrategy.SILENT));

@reckart
Copy link
Author

reckart commented Feb 11, 2024

Thanks - doesn't help though unfortunately:

        var iriMappers = manager.getIRIMappers();
        iriMappers.add(
                new AutoIRIMapper(new File(kbRepositoriesRoot, "materializedOntologies"), true));
        manager.setOntologyLoaderConfiguration(manager.getOntologyLoaderConfiguration()
                .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT));
        manager.setOntologyConfigurator(manager.getOntologyConfigurator()
                .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT));

Stack trace:

Caused by: org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <http://purl.obolibrary.org/obo/po/imports/ncbitaxon_import.owl> Cause: OWLOntologyCreationIOException: java.net.SocketException: Bad file descriptor
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1710)
	at org.obolibrary.obo2owl.OWLAPIObo2Owl.tr(OWLAPIObo2Owl.java:505)
	at org.obolibrary.obo2owl.OWLAPIObo2Owl.convert(OWLAPIObo2Owl.java:445)
	at org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParser.parse(OBOFormatOWLAPIParser.java:47)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1005)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1025)
	at de.tudarmstadt.ukp.inception.kb.KnowledgeBaseServiceImpl.transduceOboToOwlFunctionalSyntax(KnowledgeBaseServiceImpl.java:690)
	at de.tudarmstadt.ukp.inception.kb.KnowledgeBaseServiceImpl.importData(KnowledgeBaseServiceImpl.java:650)
	... 5 more
Caused by: org.semanticweb.owlapi.io.OWLOntologyCreationIOException: OWLOntologyCreationIOException: java.net.SocketException: Bad file descriptor
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:216)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:955)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1663)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1703)
	... 15 more
Caused by: org.semanticweb.owlapi.io.OWLOntologyInputSourceException: java.net.SocketException: Bad file descriptor
	at org.semanticweb.owlapi.io.DocumentSources.getInputStream(DocumentSources.java:218)
	at org.semanticweb.owlapi.io.DocumentSources.wrapInput(DocumentSources.java:143)
	at org.semanticweb.owlapi.io.DocumentSources.wrapInputAsReader(DocumentSources.java:88)
	at org.semanticweb.owlapi.io.DocumentSources.wrapInputAsReader(DocumentSources.java:105)
	at org.semanticweb.owlapi.io.AbstractOWLParser.getInputSource(AbstractOWLParser.java:38)
	at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:49)
	at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
	... 20 more
Caused by: java.net.SocketException: Bad file descriptor
	at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:325)
	at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350)
	at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803)
	at java.base/java.net.Socket$SocketInputStream.read(Socket.java:976)
	at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244)
	at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
	at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:824)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:759)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:783)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1691)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1592)
	at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
	at org.semanticweb.owlapi.io.DocumentSources.connect(DocumentSources.java:229)
	at org.semanticweb.owlapi.io.DocumentSources.getInputStream(DocumentSources.java:209)
	... 26 more

@reckart
Copy link
Author

reckart commented Feb 11, 2024

I believe the OBO code is neither considering the IRI mapper nor the silence mode.

@ignazio1977
Copy link
Contributor

which OWLAPI version are you using?

@reckart
Copy link
Author

reckart commented Feb 11, 2024

5.5.0

@reckart
Copy link
Author

reckart commented Feb 11, 2024

When I walked through the stack trace in the code, I had the impression that the OBO import code should catch Exception, wrap it in an UnloadableImportException and throw that. But I'm not sure even that would be enough. Probably the OBO code would actually need to consider the silencing flag itself.

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

No branches or pull requests

2 participants