Skip to content

Shanoir Challenge scores microservice design

Nunien edited this page Nov 8, 2016 · 25 revisions

The need

First, I assume the global data model issued from ontology will not change and that shanoir-ng will have the same functionalities (expandable study tree, ...) Then, considering this : http://microservices.io/patterns/data/database-per-service.html , I assume that each micro-service database is independent and might has to call other micro-services. After that I think I need to imagine the use cases of the score microservice to see clearly.

  1. [PUT] The segPerf has ran and a xml result is ready to be created or overwrited if exist.
    • input : id of a dataset which is an output of the segmentation processing to be linked with the new score set
    • input : set of pairs ( metric label / value )
  2. [GET] The shanoir front end application tries to render scores from a given processing / dataset
    • input : dataset id (output of segmentation)
  3. [GET] The shanoir front end application tries to render the final score board for a given challenge
    • input : study id
    • output : 3 dimensional matrix with float values defined by the tuple (subject, challenger, metric)
  4. [GET] Download the score xls file
    • input : study id
    • output : xls file
  5. [DELETE] The user deletes a score set from the study tree view
    • input : study id
    • input : challenger id
    • input : patient id
  6. [PUT] The challenge is evolving and we must add a metric variable
    • input : metric properties (name, behaviour when NaN, …)
  7. [DELETE] The challenge is evolving and we delete a metric variable
    • input : metric id

Swagger Yaml

That leads to the following API Swagger definition in Yaml format : Challenge Score Microservice Swagger Let's see what interactions with other microservices we will have for each endpoint.

Output format

Here is an exemple of the json output for the score overview request :

/** CHALLENGE SCORE MICROSERVICE RETURN EXAMPLE
 *
 * This is an example of return for the endpoint GET /scores/{studyId}.
 * Here, there are :
 *     - 2 metrics           (Dice, Jaccard)
 *     - 2 challengers       (Julien LOUIS, Michael KAIN)
 *     - 3 subjects          (Patient1, Patient2, Patient3)
 */

{
	[
		{
			"metricName": "Dice",
			"challengers": [
				{
					"challengerName": "Julien LOUIS",
					"subjects": [
						{
							"subjectName": "Patient1",
							0.84571
						},
						{
							"subjectName": "Patient2",
							0.75512
						},
						{
							"subjectName": "Patient3",
							0.71452
						}
					]
				},
				{
					"challengerName": "Michael KAIN",
					"subjects": [
						{
							"subjectName": "Patient1",
							0.95471
						},
						{
							"subjectName": "Patient2",
							0.75457
						},
						{
							"subjectName": "Patient3",
							0.65478
						}
					]
				}
			]
		},
		{
			"metricName": "Jaccard",
			"challengers": [
				{
					"challengerName": "Julien LOUIS",
					"subjects": [
						{
							"subjectName": "Patient1",
							0.45789
						},
						{
							"subjectName": "Patient2",
							0.75512
						},
						{
							"subjectName": "Patient3",
							0.98745
						}
					]
				},
				{
					"challengerName": "Michael KAIN",
					"subjects": [
						{
							"subjectName": "Patient1",
							0.95994
						},
						{
							"subjectName": "Patient2",
							0.87988
						},
						{
							"subjectName": "Patient3",
							0.0
						}
					]
				}
			]
		}
	]
}

Interactions with other microservices

/score/{datasetId} [PUT][GET][DELETE] : ask a service (dataset?) to know challenger, patient and study. For PET challenge we must know the input dataset as well.

Data Model

Since we must display studies names, challengers names and patients names possibly often, we must store this data, as well as metrics and scores.

Java changes

  • org.shanoir.core.model.processing.score.ProcessingScoreValue : Main model, rewrited as hibernate configuration will not be the same

  • org.shanoir.core.model.processing.score.ProcessingScoreVariable : Main model, rewrited as hibernate configuration will not be the same

  • org.shanoir.toolkit.importChallengeScore.ImportChallengeScore : ShanoirTK command line, will either disappear or change a lot because of the new architecture (we will no longer use SOAP web-services, will we?)

  • DatasetProcessingHome and IDatasetProcessingHome : We will not need for the method public void removeScore(DatasetProcessing processing) anymore. To be deleted.

  • IProcessingScoreValueHome and ProcessingScoreValueHome : To be deleted

  • org.shanoir.core.action.lists.ChallengeScoreVariableList : To be deleted

  • org.shanoir.core.model.processing.DatasetProcessing : Will probably not keep scores as a class attribute anymore

  • org.shanoir.presentation.subject.ProcessingScoreTreeNode : To be deleted

  • org.shanoir.presentation.subject.ProcessingScoreValueTreeNode : To be deleted

  • org.shanoir.webservices.impl.importer.ScoreSaver and org.shanoir.webservices.interfaces.importer.IScoreSaver : To be deleted, but the code can probably transfered to the corresponding REST request

  • org.shanoir.core.action.bean.ChallengeScoreExporterBean : Creates the xls file, code remains

  • org.shanoir.util.ScoreTriplet : Utility class, remains

Database Design

It is difficult to manage our scores with a strong and shinning solution. We want to store objects containing an attribute list that can be remodeled at any time. After many thoughts I think there is maybe a very clean solution, but probably much complicated and I don’t think we want to spend too much time on this. Also I went to see if NoSQL or other alternative databases could help us but from what I have read the flexibility of such solutions doesn’t fit with our need of delimiting a strict list of authorized metrics. Furthermore, the microservice architecture allows us to improve the solution in the future if needed. So I recommend to stick with the database design we have now.

As I explained it earlier, I think we should stick to the present model and use a MySQL (or any SQL) database.

Clone this wiki locally