From 6f91d7b59b69ccadeb50ee31e081cb78efe5faca Mon Sep 17 00:00:00 2001 From: Florian M Date: Mon, 26 Jul 2021 10:08:07 +0200 Subject: [PATCH] Call wk-worker nuclei inferral job (#5626) * [WIP] call wk-worker nuclei inferral job * add token, show result in job list view * changelog * remove unused import --- CHANGELOG.unreleased.md | 1 + app/controllers/JobsController.scala | 20 +++++++++++++ conf/messages | 1 + conf/webknossos.latest.routes | 1 + frontend/javascripts/admin/admin_rest_api.js | 1 + .../javascripts/admin/job/job_list_view.js | 28 +++++++++++++++++++ frontend/javascripts/types/api_flow_types.js | 1 + 7 files changed, 53 insertions(+) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 7d4cd63357..7d7b1fb604 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -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 - diff --git a/app/controllers/JobsController.scala b/app/controllers/JobsController.scala index 74854a6902..3081ca3722 100644 --- a/app/controllers/JobsController.scala +++ b/app/controllers/JobsController.scala @@ -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, diff --git a/conf/messages b/conf/messages index 97db5a6859..3130ead18f 100644 --- a/conf/messages +++ b/conf/messages @@ -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 diff --git a/conf/webknossos.latest.routes b/conf/webknossos.latest.routes index 411cff638f..b986b6dabf 100644 --- a/conf/webknossos.latest.routes +++ b/conf/webknossos.latest.routes @@ -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]) diff --git a/frontend/javascripts/admin/admin_rest_api.js b/frontend/javascripts/admin/admin_rest_api.js index b5c53cecb1..d4db81740d 100644 --- a/frontend/javascripts/admin/admin_rest_api.js +++ b/frontend/javascripts/admin/admin_rest_api.js @@ -838,6 +838,7 @@ export async function getJobs(): Promise> { 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, })); } diff --git a/frontend/javascripts/admin/job/job_list_view.js b/frontend/javascripts/admin/job/job_list_view.js index 97c78213f0..5c66ed6eb2 100644 --- a/frontend/javascripts/admin/job/job_list_view.js +++ b/frontend/javascripts/admin/job/job_list_view.js @@ -123,6 +123,20 @@ class JobListView extends React.PureComponent { {" "} ); + } else if ( + job.type === "infer_nuclei" && + job.organizationName && + job.datasetName && + job.layerName + ) { + return ( + + Nuclei inferral for layer {job.layerName} of{" "} + + {job.datasetName} + {" "} + + ); } else { return {job.type}; } @@ -154,6 +168,20 @@ class JobListView extends React.PureComponent { )} ); + } else if (job.type === "infer_nuclei") { + return ( + + {job.state === "SUCCESS" && job.result && this.props.activeUser && ( + + + View + + )} + + ); } else return null; }; diff --git a/frontend/javascripts/types/api_flow_types.js b/frontend/javascripts/types/api_flow_types.js index e4b59d53a2..f6357478bc 100644 --- a/frontend/javascripts/types/api_flow_types.js +++ b/frontend/javascripts/types/api_flow_types.js @@ -568,6 +568,7 @@ export type APIJob = { +type: string, +state: string, +manualState: string, + +result: ?string, +createdAt: number, };