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

Update to ZIO 2 release version. #139

Merged
merged 1 commit into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lazy val zioVersion = "2.0.0-RC5"
lazy val zioVersion = "2.0.0"
lazy val gitCommitString = SettingKey[String]("gitCommit")

lazy val commonSettings = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ object RelationGraph extends StrictLogging {
.when(outputConfig.mode == OWLMode)
val classesTasks = if (outputConfig.outputSubclasses) {
allClasses(ontology).map(c => ZIO.succeed(processSubclasses(c, indexedWhelk.state, outputConfig.reflexiveSubclasses, outputConfig.equivalenceAsSubclass, outputConfig.outputClasses, outputConfig.outputIndividuals)))
} else Stream.empty
} else ZStream.empty
val streamZ = for {
queue <- Queue.unbounded[Restriction]
activeRestrictions <- Ref.make(0)
seenRefs <- ZIO.foreach(allProperties)(p => Ref.make(Set.empty[AtomicConcept]).map(p -> _)).map(_.toMap)
_ <- traverse(specifiedProperties, properties, classes, queue, activeRestrictions, seenRefs)
restrictionsStream = Stream.fromQueue(queue).map(r => processRestrictionAndExtendQueue(r, properties, classes, indexedWhelk, outputConfig.mode, specifiedProperties.isEmpty, outputConfig.outputClasses, outputConfig.outputIndividuals, queue, activeRestrictions, seenRefs))
restrictionsStream = ZStream.fromQueue(queue).map(r => processRestrictionAndExtendQueue(r, properties, classes, indexedWhelk, outputConfig.mode, specifiedProperties.isEmpty, outputConfig.outputClasses, outputConfig.outputIndividuals, queue, activeRestrictions, seenRefs))
allTasks = ontologyDeclarationStream ++ classesTasks ++ restrictionsStream
} yield allTasks.mapZIOParUnordered(JRuntime.getRuntime.availableProcessors)(identity)
Stream.unwrap(streamZ)
ZStream.unwrap(streamZ)
}

def allClasses(ont: OWLOntology): ZStream[Any, Nothing, OWLClass] = Stream.fromIterable(ont.getClassesInSignature(Imports.INCLUDED).asScala.to(Set) - OWLThing - OWLNothing)
def allClasses(ont: OWLOntology): ZStream[Any, Nothing, OWLClass] = ZStream.fromIterable(ont.getClassesInSignature(Imports.INCLUDED).asScala.to(Set) - OWLThing - OWLNothing)

def traverse(specifiedProperties: Set[AtomicConcept], properties: Hierarchy, classes: Hierarchy, queue: Queue[Restriction], activeRestrictions: Ref[Int], seenRefs: Map[Role, Ref[Set[AtomicConcept]]]): UIO[Unit] = {
val descendProperties = specifiedProperties.isEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object RelationGraphUtil {
/**
* @param ontology
* @param specifiedProperties properties for which to compute relations; an empty collection signifies all
* @param outputConfig configuration for RelationGraph; `mode` is ignored, since results are converted to OWL axioms
* @param outputConfig configuration for RelationGraph; `mode` is ignored, since results are converted to OWL axioms
* @return
*/
def computeRelationGraph(ontology: OWLOntology, specifiedProperties: util.Collection[IRI], outputConfig: Config): util.Set[OWLClassAxiom] = {
Expand All @@ -41,7 +41,9 @@ object RelationGraphUtil {
.runCollect
.map(_.toSet.flatten[OWLClassAxiom])
.map(_.asJava)
Runtime.default.unsafeRun(owlZ)
Unsafe.unsafe { implicit u =>
Runtime.default.unsafe.run(owlZ).getOrThrow()
}
}

}