Skip to content

Commit

Permalink
Send baseMappingName when forwarding FullMeshRequest from TS to DS (#…
Browse files Browse the repository at this point in the history
…7887)

* correctly use base mapping in FullMeshRequest when forwarding from TS to DS

* changelog

---------

Co-authored-by: MichaelBuessemeyer <39529669+MichaelBuessemeyer@users.noreply.github.com>
  • Loading branch information
fm3 and MichaelBuessemeyer authored Jun 19, 2024
1 parent c36b647 commit cf59ad0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 50 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where sometimes old mismatching javascript code would be served after upgrades. [#7854](https://github.com/scalableminds/webknossos/pull/7854)
- Fixed a bug where dataset uploads of zipped tiff data via the UI would be rejected. [#7856](https://github.com/scalableminds/webknossos/pull/7856)
- Fixed a bug with incorrect valiation of layer names in the animation modal. [#7882](https://github.com/scalableminds/webknossos/pull/7882)
- Fixed a bug in the fullMesh.stl route used by the render_animation worker job, where some meshes in proofreading annotations could not be loaded. [#7887](https://github.com/scalableminds/webknossos/pull/7887)

### Removed
- If the datasource-properties.json file for a dataset is missing or contains errors, WEBKNOSSOS no longer attempts to guess its contents from the raw data. Exploring remote datasets will still create the file. [#7697](https://github.com/scalableminds/webknossos/pull/7697)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class DSMeshController @Inject()(
the oversegmentation. Collect mesh chunks of all *unmapped* segment ids
belonging to the supplied agglomerate id.
If it is not set, use meshfile as is, assume passed id is present in meshfile
Note: in case of an editable mapping, targetMappingName is its baseMapping name.
*/
targetMappingName: Option[String],
editableMappingTracingId: Option[String]): Action[ListMeshChunksRequest] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,59 @@ trait MeshMappingHelper {
mappingNameForMeshFile: Option[String],
omitMissing: Boolean, // If true, failing lookups in the agglomerate file will just return empty list.
token: Option[String])(implicit ec: ExecutionContext): Fox[List[Long]] =
targetMappingName match {
case None =>
(targetMappingName, editableMappingTracingId) match {
case (None, None) =>
// No mapping selected, assume id matches meshfile
Fox.successful(List(agglomerateId))
case Some(mappingName) if mappingNameForMeshFile.contains(mappingName) =>
case (Some(mappingName), None) if mappingNameForMeshFile.contains(mappingName) =>
// Mapping selected, but meshfile has the same mapping name in its metadata, assume id matches meshfile
Fox.successful(List(agglomerateId))
case Some(mappingName) =>
case (Some(mappingName), None) =>
// Mapping selected, but meshfile does not have matching mapping name in its metadata,
// assume agglomerate id, fetch oversegmentation segment ids for it
val agglomerateFileKey = AgglomerateFileKey(
organizationName,
datasetName,
dataLayerName,
mappingName
)
editableMappingTracingId match {
case Some(tracingId) =>
for {
tracingstoreUri <- dsRemoteWebknossosClient.getTracingstoreUri
segmentIdsResult <- dsRemoteTracingstoreClient.getEditableMappingSegmentIdsForAgglomerate(tracingstoreUri,
tracingId,
agglomerateId,
token)
segmentIds <- if (segmentIdsResult.agglomerateIdIsPresent)
Fox.successful(segmentIdsResult.segmentIds)
else
for {
agglomerateService <- binaryDataServiceHolder.binaryDataService.agglomerateServiceOpt.toFox
localSegmentIds <- agglomerateService.segmentIdsForAgglomerateId(
agglomerateFileKey,
agglomerateId
)
} yield localSegmentIds
} yield segmentIds
case _ =>
for {
agglomerateService <- binaryDataServiceHolder.binaryDataService.agglomerateServiceOpt.toFox
segmentIdsBox <- agglomerateService
.segmentIdsForAgglomerateId(
AgglomerateFileKey(
organizationName,
datasetName,
dataLayerName,
mappingName
),
agglomerateId
)
.futureBox
segmentIds <- segmentIdsBox match {
case Full(segmentIds) => Fox.successful(segmentIds)
case _ => if (omitMissing) Fox.successful(List.empty) else segmentIdsBox.toFox
}
} yield segmentIds
case (Some(mappingName), Some(tracingId)) =>
// An editable mapping tracing id is supplied. Ask the tracingstore for the segment ids. If it doesn’t know,
// use the mappingName (here the editable mapping’s base mapping) to look it up from file.
for {
tracingstoreUri <- dsRemoteWebknossosClient.getTracingstoreUri
segmentIdsResult <- dsRemoteTracingstoreClient.getEditableMappingSegmentIdsForAgglomerate(tracingstoreUri,
tracingId,
agglomerateId,
token)
segmentIds <- if (segmentIdsResult.agglomerateIdIsPresent)
Fox.successful(segmentIdsResult.segmentIds)
else // the agglomerate id is not present in the editable mapping. Fetch its info from the base mapping.
for {
agglomerateService <- binaryDataServiceHolder.binaryDataService.agglomerateServiceOpt.toFox
segmentIdsBox <- agglomerateService
.segmentIdsForAgglomerateId(
agglomerateFileKey,
agglomerateId
)
.futureBox
segmentIds <- segmentIdsBox match {
case Full(segmentIds) => Fox.successful(segmentIds)
case _ => if (omitMissing) Fox.successful(List.empty) else segmentIdsBox.toFox
}
} yield segmentIds
}
localSegmentIds <- agglomerateService.segmentIdsForAgglomerateId(
AgglomerateFileKey(
organizationName,
datasetName,
dataLayerName,
mappingName
),
agglomerateId
)
} yield localSegmentIds
} yield segmentIds
case _ => Fox.failure("Cannot determine segment ids for editable mapping without base mapping")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class TSRemoteDatastoreClient @Inject()(
def querySegmentIndex(remoteFallbackLayer: RemoteFallbackLayer,
segmentId: Long,
mag: Vec3Int,
mappingName: Option[String],
mappingName: Option[String], // should be the baseMappingName in case of editable mappings
editableMappingTracingId: Option[String],
userToken: Option[String]): Fox[Seq[Vec3Int]] =
for {
Expand All @@ -152,12 +152,13 @@ class TSRemoteDatastoreClient @Inject()(
indices = positions.map(_.scale(1f / DataLayer.bucketLength)) // Route returns positions to use the same interface as tracing store, we want indices
} yield indices

def querySegmentIndexForMultipleSegments(remoteFallbackLayer: RemoteFallbackLayer,
segmentIds: Seq[Long],
mag: Vec3Int,
mappingName: Option[String],
editableMappingTracingId: Option[String],
userToken: Option[String]): Fox[Seq[(Long, Seq[Vec3Int])]] =
def querySegmentIndexForMultipleSegments(
remoteFallbackLayer: RemoteFallbackLayer,
segmentIds: Seq[Long],
mag: Vec3Int,
mappingName: Option[String], // should be the baseMappingName in case of editable mappings
editableMappingTracingId: Option[String],
userToken: Option[String]): Fox[Seq[(Long, Seq[Vec3Int])]] =
for {
remoteLayerUri <- getRemoteLayerUri(remoteFallbackLayer)
result <- rpc(s"$remoteLayerUri/segmentIndex")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class TSFullMeshService @Inject()(volumeTracingService: VolumeTracingService,
fullMeshRequest: FullMeshRequest)(implicit ec: ExecutionContext): Fox[Array[Byte]] =
for {
remoteFallbackLayer <- remoteFallbackLayerFromVolumeTracing(tracing, tracingId)
baseMappingName <- volumeTracingService.baseMappingName(tracing)
fullMeshRequestAdapted = if (tracing.mappingIsEditable.getOrElse(false))
fullMeshRequest.copy(mappingName = tracing.mappingName,
fullMeshRequest.copy(mappingName = baseMappingName,
editableMappingTracingId = Some(tracingId),
mappingType = Some("HDF5"))
else fullMeshRequest
Expand Down

0 comments on commit cf59ad0

Please sign in to comment.