Skip to content

Commit

Permalink
Don’t output stack trace unless --verbose is passed. Support option f…
Browse files Browse the repository at this point in the history
…or --disable-owl-nothing. (#102)
  • Loading branch information
balhoff authored Feb 8, 2022
1 parent c22748a commit 77ca24a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/org/renci/relationgraph/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ final case class Config(ontologyFile: String,
propertiesFile: Option[String],
outputSubclasses: BoolValue = FalseValue,
reflexiveSubclasses: BoolValue = TrueValue,
equivalenceAsSubclass: BoolValue = TrueValue) {

}
equivalenceAsSubclass: BoolValue = TrueValue,
disableOwlNothing: BoolValue = FalseValue,
verbose: Boolean = false)

object Config {

Expand Down
19 changes: 17 additions & 2 deletions src/main/scala/org/renci/relationgraph/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.{OWLNothing,
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model._
import org.semanticweb.owlapi.model.parameters.Imports
import scribe.Level
import scribe.filter.{packageName, select}
import zio._
import zio.blocking._
import zio.stream._
Expand All @@ -38,14 +40,22 @@ object Main extends ZCaseApp[Config] {
private val OWLOntology = OWL2.Ontology.asNode

override def run(config: Config, arg: RemainingArgs): ZIO[ZEnv, Nothing, ExitCode] = {
val configureLogging = ZIO.succeed {
scribe.Logger.root
.clearHandlers()
.clearModifiers()
.withModifier(select(packageName("org.renci.relationgraph")).boosted(Level.Info, Level.Warn))
.withHandler(minimumLevel = Some(if (config.verbose) Level.Info else Level.Warn))
.replace()
}
val program = createStreamRDF(config.outputFile).use { rdfWriter =>
for {
fileProperties <- config.propertiesFile.map(readPropertiesFile).getOrElse(ZIO.succeed(Set.empty[AtomicConcept]))
specifiedProperties = fileProperties ++ config.property.map(prop => AtomicConcept(prop)).to(Set)
ontology <- loadOntology(config.ontologyFile)
whelkOntology = Bridge.ontologyToAxioms(ontology)
_ <- ZIO.succeed(scribe.info("Running reasoner"))
whelk = Reasoner.assert(whelkOntology)
whelk = Reasoner.assert(whelkOntology, disableBottom = config.disableOwlNothing.bool)
indexedWhelk = IndexedReasonerState(whelk)
_ <- ZIO.succeed(scribe.info("Done running reasoner"))
_ <- ZIO.fail(new Exception("Ontology is incoherent; please correct unsatisfiable classes.")).when(isIncoherent(whelk))
Expand All @@ -60,7 +70,12 @@ object Main extends ZCaseApp[Config] {
_ <- ZIO.succeed(scribe.info(s"Computed relations in ${(stop - start) / 1000.0}s"))
} yield ()
}
program.exitCode
configureLogging *>
program.as(ExitCode.success)
.catchAll { e =>
if (config.verbose) ZIO.succeed(e.printStackTrace()).as(ExitCode.failure)
else ZIO.succeed(scribe.error(e.getMessage)).as(ExitCode.failure)
}
}

def computeRelations(ontology: OWLOntology, whelk: IndexedReasonerState, specifiedProperties: Set[AtomicConcept], outputSubclasses: Boolean, reflexiveSubclasses: Boolean, equivalenceAsSubclass: Boolean, mode: Config.OutputMode): UStream[TriplesGroup] = {
Expand Down

0 comments on commit 77ca24a

Please sign in to comment.