Components¶
- class grandchallenge.components.models.ComponentImage(*args, **kwargs)[source]¶
- Parameters:
image (FileField) – Image. .tar.gz archive of the container image produced from the command ‘docker save IMAGE | gzip -c > IMAGE.tar.gz’. See https://docs.docker.com/engine/reference/commandline/save/
image_sha256 (CharField) – Image sha256
latest_shimmed_version (CharField) – Latest shimmed version
import_status (PositiveSmallIntegerField) – Import status
is_manifest_valid (BooleanField) – Is manifest valid. Is this image’s manifest valid?
is_in_registry (BooleanField) – Is in registry. Is this image in the container registry?
status (TextField) – Status
size_in_storage (PositiveBigIntegerField) – Size in storage. The number of bytes stored in the storage backend
size_in_registry (PositiveBigIntegerField) – Size in registry. The number of bytes stored in the registry
comment (TextField) – Comment. Add any information (e.g. version ID) about this image here.
is_desired_version (BooleanField) – Is desired version
Relationship fields:
- Parameters:
creator (
ForeignKey
toUser
) – Creatoruser_upload (
ForeignKey
toUserUpload
) – User upload
- class GPUTypeChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
- class ImportStatusChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
- property original_repo_tag¶
The tag of this image in the container repository
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class grandchallenge.components.models.ComponentInterface(id, overlay_segments, look_up_table, title, slug, description, default_value, schema, kind, relative_path, store_in_database)[source]¶
- Parameters:
id (AutoField) – Primary key: ID
overlay_segments (JSONField) – Overlay segments. The schema that defines how categories of values in the overlay images are differentiated.
title (CharField) – Title. Human readable name of this input/output field.
slug (AutoSlugField) – Slug
description (TextField) – Description. Description of this input/output field.
default_value (JSONField) – Default value. Default value for this field, only valid for inputs.
schema (JSONField) – Schema. Additional JSON schema that the values for this interface must satisfy. See https://json-schema.org/. Only Draft 7, 6, 4 or 3 are supported.
kind (CharField) – Kind. What is the type of this interface? Used to validate interface values and connections between components.
relative_path (CharField) – Relative path. The path to the entity that implements this interface relative to the input or output directory.
store_in_database (BooleanField) – Store in database. Should the value be saved in a database field, only valid for outputs.
Relationship fields:
- Parameters:
look_up_table (
ForeignKey
toLookUpTable
) – Look up table. The look-up table that is applied when an overlay image is first shown (related name:componentinterface
)
Reverse relationships:
- Parameters:
evaluation_inputs (Reverse
ManyToManyField
fromPhase
) – All evaluation inputs of this component interface (related name ofinputs
)evaluation_outputs (Reverse
ManyToManyField
fromPhase
) – All evaluation outputs of this component interface (related name ofoutputs
)algorithm_inputs (Reverse
ManyToManyField
fromAlgorithm
) – All algorithm inputs of this component interface (related name ofinputs
)algorithm_outputs (Reverse
ManyToManyField
fromAlgorithm
) – All algorithm outputs of this component interface (related name ofoutputs
)example_value (Reverse
OneToOneField
fromComponentInterfaceExampleValue
) – The example value of this component interface (related name ofinterface
)componentinterfacevalue (Reverse
ForeignKey
fromComponentInterfaceValue
) – All component interface values of this component interface (related name ofinterface
)question (Reverse
ForeignKey
fromQuestion
) – All questions of this component interface (related name ofinterface
)
- exception DoesNotExist¶
- Kind¶
alias of
InterfaceKindChoices
- exception MultipleObjectsReturned¶
- SuperKind¶
alias of
InterfaceSuperKindChoices
- property allowed_file_types¶
The allowed file types of the interface that is relevant when uploading
- clean()[source]¶
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- property file_extension¶
The dot filename extension (e.g. ‘.jpg’) of an interface that is relevant when writing
- class grandchallenge.components.models.ComponentInterfaceExampleValue(id, created, modified, interface, value, extra_info)[source]¶
- Parameters:
id (UUIDField) – Primary key: Id
created (DateTimeField) – Created
modified (DateTimeField) – Modified
value (JSONField) – Value. Example value for an interface
extra_info (TextField) – Extra info. Extra information about the example value
Relationship fields:
- Parameters:
interface (
OneToOneField
toComponentInterface
) – Interface (related name:example_value
)
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- clean()[source]¶
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- class grandchallenge.components.models.ComponentInterfaceValue(*args, **kwargs)[source]¶
Encapsulates the value of an interface at a certain point in the graph.
- Parameters:
id (BigAutoField) – Primary key: Id
value (JSONField) – Value
file (FileField) – File
size_in_storage (PositiveBigIntegerField) – Size in storage. The number of bytes stored in the storage backend
Relationship fields:
- Parameters:
interface (
ForeignKey
toComponentInterface
) – Interface (related name:componentinterfacevalue
)image (
ForeignKey
toImage
) – Image (related name:componentinterfacevalue
)
Reverse relationships:
- Parameters:
evaluation_evaluations_as_input (Reverse
ManyToManyField
fromEvaluation
) – All evaluation evaluations as input of this component interface value (related name ofinputs
)evaluation_evaluations_as_output (Reverse
ManyToManyField
fromEvaluation
) – All evaluation evaluations as output of this component interface value (related name ofoutputs
)algorithms_jobs_as_input (Reverse
ManyToManyField
fromJob
) – All algorithms jobs as input of this component interface value (related name ofinputs
)algorithms_jobs_as_output (Reverse
ManyToManyField
fromJob
) – All algorithms jobs as output of this component interface value (related name ofoutputs
)archive_items (Reverse
ManyToManyField
fromArchiveItem
) – All archive items of this component interface value (related name ofvalues
)display_sets (Reverse
ManyToManyField
fromDisplaySet
) – All display sets of this component interface value (related name ofvalues
)download (Reverse
ForeignKey
fromDownload
) – All downloads of this component interface value (related name ofcomponent_interface_value
)
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- clean()[source]¶
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- property decompress¶
Should the CIV be decompressed?
This is only for legacy support of zip file submission for prediction evaluation. We should not support this anywhere else as it clobbers the input directory.
- image_file¶
- property relative_path¶
Where should the file be located?
Images need special handling as their names are fixed.
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class grandchallenge.components.models.ComponentJob(*args, **kwargs)[source]¶
- Parameters:
id (UUIDField) – Primary key: Id
created (DateTimeField) – Created
modified (DateTimeField) – Modified
status (PositiveSmallIntegerField) – Status
attempt (PositiveSmallIntegerField) – Attempt
stdout (TextField) – Stdout
stderr (TextField) – Stderr
runtime_metrics (JSONField) – Runtime metrics
error_message (CharField) – Error message
detailed_error_message (JSONField) – Detailed error message
started_at (DateTimeField) – Started at
completed_at (DateTimeField) – Completed at
compute_cost_euro_millicents (PositiveIntegerField) – Compute cost euro millicents. The total compute cost for this job in Euro Cents, including Tax
input_prefixes (JSONField) – Input prefixes. Map of the ComponentInterfaceValue id to the path prefix to use for this input, e.g. {‘1’: ‘foo/bar/’} will place CIV 1 at /input/foo/bar/<relative_path>
task_on_success (JSONField) – Task on success. Serialized task that is run on job success
task_on_failure (JSONField) – Task on failure. Serialized task that is run on job failure
time_limit (PositiveIntegerField) – Time limit. Time limit for the job in seconds
requires_gpu_type (CharField) – Requires gpu type. What GPU is required by this job?
requires_memory_gb (PositiveSmallIntegerField) – Requires memory gb. How much memory is required by this job?
Relationship fields:
- Parameters:
inputs (
ManyToManyField
toComponentInterfaceValue
) – Inputsoutputs (
ManyToManyField
toComponentInterfaceValue
) – Outputs
- property container: ComponentImage¶
Returns the container object associated with this instance, which should be a foreign key to an object that is a subclass of ComponentImage
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
- class grandchallenge.components.models.ComponentJobManager(model=None, query=None, using=None, hints=None)[source]¶
- class grandchallenge.components.models.GPUTypeChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- class grandchallenge.components.models.ImportStatusChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- class grandchallenge.components.models.InterfaceKind[source]¶
Interface kind choices.
- class InterfaceKindChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Interface kind choices.
- static interface_type_file()[source]¶
Interface kinds that are files:
CSV file
ZIP file
PDF file
SQREG file
Thumbnail JPG
Thumbnail PNG
OBJ file
MP4 file
Newick file
- static interface_type_image()[source]¶
Interface kinds that are images:
Image
Heat Map
Segmentation
Displacement Field
- static interface_type_json()[source]¶
Interface kinds that are json serializable:
String
Integer
Float
Bool
Anything that is JSON serializable (any object)
Chart
2D bounding box
Multiple 2D bounding boxes
Distance measurement
Multiple distance measurements
Point
Multiple points
Polygon
Multiple polygons
Lines
Multiple lines
Angle
Multiple angles
Ellipse
Multiple ellipses
Affine transform registration
Choice (string)
Multiple choice (array of strings)
import json import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') django.setup() from grandchallenge.components.models import INTERFACE_TYPE_JSON_EXAMPLES for key, example in INTERFACE_TYPE_JSON_EXAMPLES.items(): title = f"Example JSON file contents for {key.label}" if example.extra_info: title += f" ({example.extra_info})" print(f"{title}:") print(json.dumps(example.value, indent=2)) print("")
Example JSON file contents for String: "Example String" Example JSON file contents for Integer: 42 Example JSON file contents for Float: 42.0 Example JSON file contents for Bool: true Example JSON file contents for Anything: { "key": "value", "None": null } Example JSON file contents for Chart (For more examples, see https://vega.github.io/vega-lite/examples/ and https://grand-challenge.org/blogs/visualisations-for-challenges/): { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "width": 300, "height": 300, "data": { "values": [ { "target": "Negative", "prediction": "Negative", "value": 198 }, { "target": "Negative", "prediction": "Positive", "value": 9 }, { "target": "Positive", "prediction": "Negative", "value": 159 }, { "target": "Positive", "prediction": "Positive", "value": 376 } ], "format": { "type": "json" } }, "layer": [ { "mark": "rect", "encoding": { "y": { "field": "target", "type": "ordinal" }, "x": { "field": "prediction", "type": "ordinal" }, "color": { "field": "value", "type": "quantitative", "title": "Count of Records", "legend": { "direction": "vertical", "gradientLength": 300 } } } }, { "mark": "text", "encoding": { "y": { "field": "target", "type": "ordinal" }, "x": { "field": "prediction", "type": "ordinal" }, "text": { "field": "value", "type": "quantitative" }, "color": { "condition": { "test": "datum['value'] < 40", "value": "black" }, "value": "white" } } } ], "config": { "axis": { "grid": true, "tickBand": "extent" } } } Example JSON file contents for 2D bounding box (Optional fields: "name" and "probability"): { "name": "Region of interest", "type": "2D bounding box", "corners": [ [ 130.8, 148.8, 0.5 ], [ 69.7, 148.8, 0.5 ], [ 69.7, 73.1, 0.5 ], [ 130.8, 73.1, 0.5 ] ], "probability": 0.95, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple 2D bounding boxes (Optional fields: "name" and "probability"): { "name": "Regions of interest", "type": "Multiple 2D bounding boxes", "boxes": [ { "name": "ROI 1", "corners": [ [ 92.6, 136.0, 0.5 ], [ 54.8, 136.0, 0.5 ], [ 54.8, 95.5, 0.5 ], [ 92.6, 95.5, 0.5 ] ], "probability": 0.95 }, { "name": "ROI 2", "corners": [ [ 92.6, 136.0, 0.5 ], [ 54.8, 136.0, 0.5 ], [ 54.8, 95.5, 0.5 ], [ 92.6, 95.5, 0.5 ] ], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Distance measurement (Optional fields: "name" and "probability"): { "name": "Distance between areas", "type": "Distance measurement", "start": [ 59.8, 78.8, 0.5 ], "end": [ 69.4, 143.8, 0.5 ], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple distance measurements (Optional fields: "name" and "probability"): { "name": "Distances between areas", "type": "Multiple distance measurements", "lines": [ { "name": "Distance 1", "start": [ 49.7, 103.3, 0.5 ], "end": [ 55.1, 139.3, 0.5 ], "probability": 0.92 }, { "name": "Distance 2", "start": [ 49.7, 103.3, 0.5 ], "end": [ 55.1, 139.3, 0.5 ], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Point (Optional fields: "name" and "probability"): { "name": "Point of interest", "type": "Point", "point": [ 152.1, 111.0, 0.5 ], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple points (Optional fields: "name" and "probability"): { "name": "Points of interest", "type": "Multiple points", "points": [ { "name": "Point 1", "point": [ 96.0, 79.8, 0.5 ], "probability": 0.92 }, { "name": "Point 2", "point": [ 130.1, 115.5, 0.5 ], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Polygon (Optional fields: "name" and "probability"): { "name": "Area of interest", "type": "Polygon", "seed_point": [ 76.4, 124.0, 0.5 ], "path_points": [ [ 76.41, 124.01, 0.5 ], [ 76.41, 124.05, 0.5 ], [ 76.42, 124.08, 0.5 ] ], "sub_type": "brush", "groups": [], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple polygons (Optional fields: "name" and "probability"): { "name": "Areas of interest", "type": "Multiple polygons", "polygons": [ { "name": "Area 1", "seed_point": [ 55.82, 90.46, 0.5 ], "path_points": [ [ 55.82, 90.46, 0.5 ], [ 55.93, 90.88, 0.5 ], [ 56.24, 91.19, 0.5 ], [ 56.66, 91.3, 0.5 ] ], "sub_type": "brush", "groups": [ "manual" ], "probability": 0.67 }, { "name": "Area 2", "seed_point": [ 90.22, 96.06, 0.5 ], "path_points": [ [ 90.22, 96.06, 0.5 ], [ 90.33, 96.48, 0.5 ], [ 90.64, 96.79, 0.5 ] ], "sub_type": "brush", "groups": [], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Line (Optional fields: "name" and "probability"): { "name": "Some annotation", "type": "Line", "seed_points": [ [ 1, 2, 3 ], [ 1, 2, 3 ] ], "path_point_lists": [ [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ], [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ] ], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple lines (Optional fields: "name" and "probability"): { "name": "Some annotations", "type": "Multiple lines", "lines": [ { "name": "Annotation 1", "seed_points": [ [ 1, 2, 3 ], [ 1, 2, 3 ] ], "path_point_lists": [ [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ], [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ] ], "probability": 0.78 }, { "name": "Annotation 2", "seed_points": [ [ 1, 2, 3 ], [ 1, 2, 3 ] ], "path_point_lists": [ [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ], [ [ 5, 6, 7 ], [ 8, 9, 10 ], [ 1, 0, 10 ], [ 2, 4, 2 ] ] ], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Angle (Optional fields: "name" and "probability"): { "name": "Some angle", "type": "Angle", "lines": [ [ [ 180, 10, 0.5 ], [ 190, 10, 0.5 ] ], [ [ 180, 25, 0.5 ], [ 190, 15, 0.5 ] ] ], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple angles (Optional fields: "name" and "probability"): { "name": "Some angles", "type": "Multiple angles", "angles": [ { "name": "First angle", "lines": [ [ [ 110, 135, 0.5 ], [ 60, 165, 0.5 ] ], [ [ 70, 25, 0.5 ], [ 85, 65, 0.5 ] ] ], "probability": 0.82 }, { "name": "Second angle", "lines": [ [ [ 130, 210, 0.5 ], [ 160, 130, 0.5 ] ], [ [ 140, 40, 0.5 ], [ 180, 75, 0.5 ] ] ], "probability": 0.52 }, { "name": "Third angle", "lines": [ [ [ 20, 30, 0.5 ], [ 20, 100, 0.5 ] ], [ [ 180, 200, 0.5 ], [ 210, 200, 0.5 ] ] ], "probability": 0.98 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Ellipse (Optional fields: "name" and "probability"): { "name": "Some ellipse", "type": "Ellipse", "major_axis": [ [ -10, 606, 0.5 ], [ 39, 559, 0.5 ] ], "minor_axis": [ [ 2, 570, 0.5 ], [ 26, 595, 0.5 ] ], "probability": 0.92, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple ellipses (Optional fields: "name" and "probability"): { "name": "Some ellipse", "type": "Multiple ellipses", "ellipses": [ { "major_axis": [ [ -44, 535, 0.5 ], [ -112, 494, 0.5 ] ], "minor_axis": [ [ -88, 532, 0.5 ], [ -68, 497, 0.5 ] ], "probability": 0.69 }, { "major_axis": [ [ -17, 459, 0.5 ], [ -94, 436, 0.5 ] ], "minor_axis": [ [ -61, 467, 0.5 ], [ -50, 428, 0.5 ] ], "probability": 0.92 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Three-point angle (Optional fields: "name" and "probability"): { "name": "Some 3-point angle", "type": "Three-point angle", "angle": [ [ 177, 493, 0.5 ], [ 22, 489, 0.5 ], [ 112, 353, 0.5 ] ], "probability": 0.003, "version": { "major": 1, "minor": 0 } } Example JSON file contents for Multiple three-point angles (Optional fields: "name" and "probability"): { "name": "Multiple 3-point angles", "type": "Multiple three-point angles", "angles": [ { "name": "first", "angle": [ [ 300, 237, 0.5 ], [ 263, 282, 0.5 ], [ 334, 281, 0.5 ] ], "probability": 0.92 }, { "name": "second", "angle": [ [ 413, 237, 0.5 ], [ 35, 160, 0.5 ], [ 367, 293, 0.5 ] ], "probability": 0.69 } ], "version": { "major": 1, "minor": 0 } } Example JSON file contents for Affine transform registration: { "3d_affine_transform": [ [ 1, 0, 0, 0 ], [ 0, 1, 0, 0 ], [ 0, 0, 1, 0 ], [ 0, 0, 0, 1 ] ] } Example JSON file contents for Choice: "Choice 1" Example JSON file contents for Multiple choice: [ "Choice 1", "Choice 2" ]
- class grandchallenge.components.models.InterfaceKindChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Interface kind choices.
- class grandchallenge.components.models.InterfaceSuperKindChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- class grandchallenge.components.models.OverlaySegmentsMixin(*args, **kwargs)[source]¶
- Parameters:
overlay_segments (JSONField) – Overlay segments. The schema that defines how categories of values in the overlay images are differentiated.
Relationship fields:
- Parameters:
look_up_table (
ForeignKey
toLookUpTable
) – Look up table. The look-up table that is applied when an overlay image is first shown
- class grandchallenge.components.models.Tarball(*args, **kwargs)[source]¶
- Parameters:
id (UUIDField) – Primary key: Id
created (DateTimeField) – Created
modified (DateTimeField) – Modified
import_status (PositiveSmallIntegerField) – Import status
status (TextField) – Status
sha256 (CharField) – Sha256
size_in_storage (PositiveBigIntegerField) – Size in storage. The number of bytes stored in the storage backend
comment (TextField) – Comment. Add any information (e.g. version ID) about this object here.
is_desired_version (BooleanField) – Is desired version
Relationship fields:
- Parameters:
creator (
ForeignKey
toUser
) – Creatoruser_upload (
ForeignKey
toUserUpload
) – User upload
- class ImportStatusChoices(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
- save(*args, **kwargs)[source]¶
Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.