Skip to content

Commit

Permalink
Call wk-worker nuclei inferral job (#5626)
Browse files Browse the repository at this point in the history
* [WIP] call wk-worker nuclei inferral job

* add token, show result in job list view

* changelog

* remove unused import
  • Loading branch information
fm3 authored Jul 26, 2021
1 parent b1bbaff commit 6f91d7b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Added
- Fixed a bug where non-existing resolutions could be selected for wk-worker-based meshfile computations [#5631](https://github.com/scalableminds/webknossos/pull/5631)
- Added a route to call new webknossos-worker job for nuclei inferral. [#5626](https://github.com/scalableminds/webknossos/pull/5626)

### Changed
-
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/JobsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ class JobsController @Inject()(jobDAO: JobDAO,
} yield Ok(js)
}

def runInferNucleiJob(organizationName: String, dataSetName: String, layerName: Option[String]): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
log(Some(slackNotificationService.noticeFailedJobRequest)) {
for {
organization <- organizationDAO.findOneByName(organizationName) ?~> Messages("organization.notFound",
organizationName)
_ <- bool2Fox(request.identity._organization == organization._id) ?~> "job.export.notAllowed.organization" ~> FORBIDDEN
command = "infer_nuclei"
commandArgs = Json.obj(
"organization_name" -> organizationName,
"dataset_name" -> dataSetName,
"layer_name" -> layerName,
"webknossos_token" -> TracingStoreRpcClient.webKnossosToken,
)
job <- jobService.runJob(command, commandArgs, request.identity) ?~> "job.couldNotRunNucleiInferral"
js <- jobService.publicWrites(job)
} yield Ok(js)
}
}

def runExportTiffJob(organizationName: String,
dataSetName: String,
bbox: String,
Expand Down
1 change: 1 addition & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ job.notFound = Job with id {0} could not be found.
job.couldNotRunCubing = Failed to start WKW conversion job.
job.couldNotRunTiffExport = Failed to start Tiff export job.
job.couldNotRunComputeMeshFile = Failed to start mesh file computation job.
job.couldNotRunNucleiInferral = Failed to start nuclei inferral job.
job.disabled = Long-running jobs are not enabled for this webKnossos instance.
job.export.fileNotFound = Exported file not found. The link may be expired.
job.export.tiff.invalidBoundingBox = The selected bounding box could not be parsed, must be x,y,z,width,height,depth
Expand Down
1 change: 1 addition & 0 deletions conf/webknossos.latest.routes
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@ GET /jobs/:id/downloadExport/:exportFileName c
GET /jobs/run/convertToWkw/:organizationName/:dataSetName controllers.JobsController.runConvertToWkwJob(organizationName: String, dataSetName: String, scale: String)
GET /jobs/run/computeMeshFile/:organizationName/:dataSetName controllers.JobsController.runComputeMeshFileJob(organizationName: String, dataSetName: String, layerName: String, mag: String, agglomerateView: Option[String])
GET /jobs/run/exportTiff/:organizationName/:dataSetName controllers.JobsController.runExportTiffJob(organizationName: String, dataSetName: String, bbox: String, layerName: Option[String], tracingId: Option[String], tracingVersion: Option[String], annotationId: Option[String], annotationType: Option[String], hideUnmappedIds: Option[Boolean], mappingName: Option[String], mappingType: Option[String])
GET /jobs/run/inferNuclei/:organizationName/:dataSetName controllers.JobsController.runInferNucleiJob(organizationName: String, dataSetName: String, layerName: Option[String])
1 change: 1 addition & 0 deletions frontend/javascripts/admin/admin_rest_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ export async function getJobs(): Promise<Array<APIJob>> {
annotationType: job.commandArgs.kwargs.annotation_type,
state: adaptJobState(job.command, job.celeryInfo.state, job.manualState),
manualState: job.manualState,
result: job.celeryInfo.result,
createdAt: job.created,
}));
}
Expand Down
28 changes: 28 additions & 0 deletions frontend/javascripts/admin/job/job_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ class JobListView extends React.PureComponent<Props, State> {
</Link>{" "}
</span>
);
} else if (
job.type === "infer_nuclei" &&
job.organizationName &&
job.datasetName &&
job.layerName
) {
return (
<span>
Nuclei inferral for layer {job.layerName} of{" "}
<Link to={`/datasets/${job.organizationName}/${job.datasetName}/view`}>
{job.datasetName}
</Link>{" "}
</span>
);
} else {
return <span>{job.type}</span>;
}
Expand Down Expand Up @@ -154,6 +168,20 @@ class JobListView extends React.PureComponent<Props, State> {
)}
</span>
);
} else if (job.type === "infer_nuclei") {
return (
<span>
{job.state === "SUCCESS" && job.result && this.props.activeUser && (
<Link
to={`/datasets/${this.props.activeUser.organization}/${job.result}/view`}
title="View Segmentation"
>
<EyeOutlined />
View
</Link>
)}
</span>
);
} else return null;
};

Expand Down
1 change: 1 addition & 0 deletions frontend/javascripts/types/api_flow_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export type APIJob = {
+type: string,
+state: string,
+manualState: string,
+result: ?string,
+createdAt: number,
};

Expand Down

0 comments on commit 6f91d7b

Please sign in to comment.