Repository: comic/grand-challenge.org

Issue:
Provide entrypoint for algorithm results endpoint in Cirrus Core
An algorithm result can produce multiple overlays. At the moment, these can only be viewed one by one from Grand Challenge. It would be nice if there's a single entry to an algorithm result.

Related to https://github.com/DIAGNijmegen/rse-cirrus-core/issues/654





Discussion:

Resolving patch:
diff --git a/app/config/settings.py b/app/config/settings.py
--- a/app/config/settings.py
+++ b/app/config/settings.py
@@ -642,6 +642,7 @@ def strtobool(val) -> bool:
 WORKSTATIONS_BASE_IMAGE_QUERY_PARAM = "image"
 WORKSTATIONS_OVERLAY_QUERY_PARAM = "overlay"
 WORKSTATIONS_READY_STUDY_QUERY_PARAM = "readerStudy"
+WORKSTATIONS_ALGORITHM_RESULT_QUERY_PARAM = "algorithmResult"
 WORKSTATIONS_CONFIG_QUERY_PARAM = "config"
 # The name of the network that the workstations will be attached to
 WORKSTATIONS_NETWORK_NAME = os.environ.get(
diff --git a/app/grandchallenge/workstations/templatetags/workstations.py b/app/grandchallenge/workstations/templatetags/workstations.py
--- a/app/grandchallenge/workstations/templatetags/workstations.py
+++ b/app/grandchallenge/workstations/templatetags/workstations.py
@@ -7,7 +7,11 @@
 
 @register.simple_tag()
 def workstation_query(
-    image=None, overlay=None, reader_study=None, config=None
+    image=None,
+    overlay=None,
+    reader_study=None,
+    algorithm_result=None,
+    config=None,
 ):
     """
     Generate the workstation query string.
@@ -32,6 +36,10 @@ def workstation_query(
         query = {
             settings.WORKSTATIONS_READY_STUDY_QUERY_PARAM: reader_study.pk
         }
+    elif algorithm_result:
+        query = {
+            settings.WORKSTATIONS_ALGORITHM_RESULT_QUERY_PARAM: algorithm_result.pk
+        }
     else:
         query = {}
 


Test patch:
diff --git a/app/tests/workstations_tests/test_templatetags.py b/app/tests/workstations_tests/test_templatetags.py
--- a/app/tests/workstations_tests/test_templatetags.py
+++ b/app/tests/workstations_tests/test_templatetags.py
@@ -3,6 +3,7 @@
 from grandchallenge.workstations.templatetags.workstations import (
     workstation_query,
 )
+from tests.algorithms_tests.factories import AlgorithmResultFactory
 from tests.factories import ImageFactory, WorkstationConfigFactory
 from tests.reader_studies_tests.factories import ReaderStudyFactory
 
@@ -13,6 +14,7 @@ def test_workstation_query(settings):
     reader_study = ReaderStudyFactory(
         workstation_config=WorkstationConfigFactory()
     )
+    algorithm_result = AlgorithmResultFactory()
     config = WorkstationConfigFactory()
 
     qs = workstation_query(image=image)
@@ -70,3 +72,18 @@ def test_workstation_query(settings):
         in qs
     )
     assert f"{settings.WORKSTATIONS_CONFIG_QUERY_PARAM}" not in qs
+
+    qs = workstation_query(algorithm_result=algorithm_result)
+    assert "&" not in qs
+    assert (
+        f"{settings.WORKSTATIONS_ALGORITHM_RESULT_QUERY_PARAM}={algorithm_result.pk}"
+        in qs
+    )
+
+    qs = workstation_query(algorithm_result=algorithm_result, config=config)
+    assert "&" in qs
+    assert (
+        f"{settings.WORKSTATIONS_ALGORITHM_RESULT_QUERY_PARAM}={algorithm_result.pk}"
+        in qs
+    )
+    assert f"{settings.WORKSTATIONS_CONFIG_QUERY_PARAM}={config.pk}" in qs