Workstations

Workstations are used to view, annotate and upload images to grand challenge. A workstation admin is able to upload a WorkstationImage, which is a docker container image. A WorkstationImage expose a http and, optionally, a websocket port. A workstation user can then launch a workstation Session for a particular WorkstationImage.

When a new session is started, a new container instance of the selected WorkstationImage is lauched on the docker host. The connection to the container will be proxied, and only accessible to the user that created the session. The proxy will map the http and websocket connections from the user to the running instance, which is mapped by the container hostname. The container instance will have the users API token set in the environment, so that it is able to interact with the grand challenge API as this user. The user is able to stop the container, otherwise it will be terminated after maxmium_duration is reached.

class grandchallenge.workstations.models.Session(*args, **kwargs)[source]

Tracks who has launched workstation images. The WorkstationImage will be launched as a Service. The Session is responsible for starting and stopping the Service.

Parameters
  • status – Stores what has happened with the service, is it running, errored, etc?

  • region – Stores which region this session runs in

  • creator – Who created the session? This is also the only user that should be able to access the launched service.

  • workstation_image – The container image that will be launched by this Session.

  • maximum_duration – The maximum time that the service can be active before it is terminated

  • user_finished – Indicates if the user has chosen to end the session early

  • history – The history of this Session

exception DoesNotExist
exception MultipleObjectsReturned
class Region(value)[source]

An enumeration.

property environment
Return type

dict

Returns

The environment variables that should be set on the container.

property expires_at
Return type

datetime

Returns

The time when this session expires.

property hostname
Return type

str

Returns

The unique hostname for this session

save(*args, **kwargs)[source]

Save the session instance, starting or stopping the service if needed.

Return type

None

save_without_historical_record(*args, **kwargs)

Save model without saving a historical record

Make sure you know what you’re doing before you use this method.

property service
Return type

Service

Returns

The service for this session, could be active or inactive.

start()[source]

Starts the service for this session, ensuring that the workstation_image is ready to be used and that WORKSTATIONS_MAXIMUM_SESSIONS has not been reached in this region.

Raises

ComponentException – If the service cannot be started.

Return type

None

stop()[source]

Stop the service for this session, cleaning up all of the containers.

Return type

None

property task_kwargs
Return type

dict

Returns

The kwargs that need to be passed to celery to get this object

update_status(*, status)[source]

Updates the status of this session.

Parameters

status (((0, 'Queued'), (1, 'Started'), (2, 'Running'), (3, 'Failed'), (4, 'Stopped'))) – The new status for this session.

Return type

None

property workstation_url
Return type

str

Returns

The url that users will use to access the workstation instance.

class grandchallenge.workstations.models.Workstation(*args, **kwargs)[source]

Store the title and description of a workstation.

exception DoesNotExist
exception MultipleObjectsReturned
property latest_ready_image
Returns

The most recent container image for this workstation

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.workstations.models.WorkstationImage(*args, **kwargs)[source]

A WorkstationImage is a docker container image of a workstation.

Parameters
  • workstation – A Workstation can have multiple WorkstationImage, that represent different versions of a workstation

  • http_port – This container will expose a http server on this port

  • websocket_port – This container will expose a websocket on this port. Any relative url that starts with /mlab4d4c4142 will be proxied to this port.

  • initial_path – The initial path that users will navigate to in order to load the workstation

exception DoesNotExist
exception MultipleObjectsReturned
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.

grandchallenge.workstations.models.delete_workstation_groups_hook(*_, instance, using, **__)[source]

Deletes the related groups.

We use a signal rather than overriding delete() to catch usages of bulk_delete.